From 56bb6962d13058d8109ba0ab49acfc97ebbbe26d Mon Sep 17 00:00:00 2001 From: root Date: Wed, 24 Jun 2026 11:32:25 +0000 Subject: [PATCH 1/8] chore: update Flutter SDK to 25.2.0 --- CHANGELOG.md | 6 + README.md | 2 +- docs/examples/account/create.md | 2 +- docs/examples/account/update-password.md | 4 +- docs/examples/account/update-recovery.md | 2 +- lib/appwrite.dart | 2 +- lib/channel.dart | 20 +- lib/client_browser.dart | 2 +- lib/client_io.dart | 2 +- lib/operator.dart | 11 +- lib/query.dart | 103 +- lib/realtime_browser.dart | 2 +- lib/realtime_io.dart | 2 +- lib/role.dart | 2 +- lib/services/account.dart | 1992 ++++++------ lib/services/avatars.dart | 401 ++- lib/services/databases.dart | 688 ++--- lib/services/functions.dart | 153 +- lib/services/graphql.dart | 54 +- lib/services/locale.dart | 174 +- lib/services/messaging.dart | 75 +- lib/services/presences.dart | 237 +- lib/services/storage.dart | 391 ++- lib/services/tables_db.dart | 644 ++-- lib/services/teams.dart | 532 ++-- lib/src/client.dart | 12 +- lib/src/client_base.dart | 18 +- lib/src/client_browser.dart | 33 +- lib/src/client_io.dart | 42 +- lib/src/client_mixin.dart | 10 +- lib/src/cookie_manager.dart | 9 +- 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/browser_permission.dart | 50 +- lib/src/enums/browser_theme.dart | 14 +- lib/src/enums/credit_card.dart | 44 +- lib/src/enums/execution_method.dart | 24 +- lib/src/enums/execution_status.dart | 20 +- lib/src/enums/execution_trigger.dart | 16 +- 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 | 96 +- lib/src/enums/timezone.dart | 848 +++--- lib/src/exception.dart | 2 +- lib/src/models/algo_argon2.dart | 62 +- lib/src/models/algo_bcrypt.dart | 26 +- lib/src/models/algo_md5.dart | 26 +- lib/src/models/algo_phpass.dart | 26 +- lib/src/models/algo_scrypt.dart | 86 +- lib/src/models/algo_scrypt_modified.dart | 62 +- lib/src/models/algo_sha.dart | 26 +- lib/src/models/continent.dart | 36 +- lib/src/models/continent_list.dart | 41 +- lib/src/models/country.dart | 33 +- lib/src/models/country_list.dart | 41 +- lib/src/models/currency.dart | 110 +- lib/src/models/currency_list.dart | 41 +- lib/src/models/document.dart | 102 +- lib/src/models/document_list.dart | 45 +- lib/src/models/execution.dart | 250 +- lib/src/models/execution_list.dart | 41 +- lib/src/models/file.dart | 194 +- lib/src/models/file_list.dart | 36 +- lib/src/models/headers.dart | 36 +- lib/src/models/identity.dart | 122 +- lib/src/models/identity_list.dart | 41 +- lib/src/models/jwt.dart | 26 +- lib/src/models/language.dart | 44 +- lib/src/models/language_list.dart | 41 +- lib/src/models/locale.dart | 110 +- lib/src/models/locale_code.dart | 36 +- lib/src/models/locale_code_list.dart | 41 +- lib/src/models/log.dart | 290 +- lib/src/models/log_list.dart | 36 +- lib/src/models/membership.dart | 206 +- lib/src/models/membership_list.dart | 41 +- lib/src/models/mfa_challenge.dart | 62 +- lib/src/models/mfa_factors.dart | 62 +- lib/src/models/mfa_recovery_codes.dart | 28 +- lib/src/models/mfa_type.dart | 36 +- lib/src/models/model.dart | 2 +- lib/src/models/phone.dart | 52 +- lib/src/models/phone_list.dart | 36 +- lib/src/models/preferences.dart | 26 +- lib/src/models/presence.dart | 112 +- lib/src/models/presence_list.dart | 41 +- lib/src/models/row.dart | 102 +- lib/src/models/row_list.dart | 40 +- lib/src/models/session.dart | 360 +-- lib/src/models/session_list.dart | 41 +- lib/src/models/subscriber.dart | 112 +- lib/src/models/target.dart | 112 +- lib/src/models/team.dart | 98 +- lib/src/models/team_list.dart | 36 +- lib/src/models/token.dart | 98 +- lib/src/models/transaction.dart | 98 +- lib/src/models/transaction_list.dart | 41 +- lib/src/models/user.dart | 332 +- lib/src/realtime.dart | 6 +- lib/src/realtime_browser.dart | 9 + lib/src/realtime_io.dart | 21 +- lib/src/realtime_message.dart | 2 +- lib/src/realtime_mixin.dart | 179 +- lib/src/realtime_response.dart | 32 +- lib/src/realtime_response_connected.dart | 10 +- lib/src/realtime_stub.dart | 4 +- pubspec.yaml | 2 +- test/channel_test.dart | 91 +- test/query_test.dart | 17 +- test/services/account_test.dart | 2663 +++++++++-------- test/services/avatars_test.dart | 207 +- test/services/databases_test.dart | 588 ++-- test/services/functions_test.dart | 198 +- test/services/graphql_test.dart | 80 +- test/services/locale_test.dart | 245 +- test/services/messaging_test.dart | 135 +- test/services/presences_test.dart | 206 +- test/services/storage_test.dart | 351 +-- test/services/tables_db_test.dart | 588 ++-- test/services/teams_test.dart | 548 ++-- test/src/cookie_manager_test.dart | 25 +- test/src/exception_test.dart | 4 +- test/src/input_file_test.dart | 24 +- test/src/models/algo_argon2_test.dart | 10 +- test/src/models/algo_bcrypt_test.dart | 8 +- test/src/models/algo_md5_test.dart | 8 +- test/src/models/algo_phpass_test.dart | 8 +- .../src/models/algo_scrypt_modified_test.dart | 16 +- test/src/models/algo_scrypt_test.dart | 12 +- test/src/models/algo_sha_test.dart | 8 +- test/src/models/continent_list_test.dart | 11 +- test/src/models/continent_test.dart | 11 +- test/src/models/country_list_test.dart | 11 +- test/src/models/country_test.dart | 11 +- test/src/models/currency_list_test.dart | 11 +- test/src/models/currency_test.dart | 16 +- test/src/models/document_list_test.dart | 11 +- test/src/models/document_test.dart | 16 +- test/src/models/execution_list_test.dart | 11 +- test/src/models/execution_test.dart | 36 +- test/src/models/file_list_test.dart | 11 +- test/src/models/file_test.dart | 30 +- test/src/models/headers_test.dart | 11 +- test/src/models/identity_list_test.dart | 11 +- test/src/models/identity_test.dart | 22 +- test/src/models/jwt_test.dart | 10 +- test/src/models/language_list_test.dart | 11 +- test/src/models/language_test.dart | 8 +- test/src/models/locale_code_list_test.dart | 11 +- test/src/models/locale_code_test.dart | 11 +- test/src/models/locale_test.dart | 16 +- test/src/models/log_list_test.dart | 11 +- test/src/models/log_test.dart | 46 +- test/src/models/membership_list_test.dart | 11 +- test/src/models/membership_test.dart | 32 +- test/src/models/mfa_challenge_test.dart | 10 +- test/src/models/mfa_factors_test.dart | 10 +- test/src/models/mfa_recovery_codes_test.dart | 8 +- test/src/models/mfa_type_test.dart | 12 +- test/src/models/phone_list_test.dart | 11 +- test/src/models/phone_test.dart | 8 +- test/src/models/preferences_test.dart | 5 +- test/src/models/presence_list_test.dart | 11 +- test/src/models/presence_test.dart | 14 +- test/src/models/row_list_test.dart | 11 +- test/src/models/row_test.dart | 16 +- test/src/models/session_list_test.dart | 11 +- test/src/models/session_test.dart | 60 +- test/src/models/subscriber_test.dart | 36 +- test/src/models/target_test.dart | 18 +- test/src/models/team_list_test.dart | 11 +- test/src/models/team_test.dart | 12 +- test/src/models/token_test.dart | 14 +- test/src/models/transaction_list_test.dart | 11 +- test/src/models/transaction_test.dart | 14 +- test/src/models/user_test.dart | 32 +- .../src/realtime_response_connected_test.dart | 4 +- test/src/realtime_response_test.dart | 4 +- test/src/realtime_subscription_test.dart | 19 +- test/src/upload_progress_test.dart | 2 +- 183 files changed, 9173 insertions(+), 9437 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7bd8b55b..9413e707 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## 25.2.0 + +* Added: Realtime connections now authenticate with the configured JWT. +* Added: Forwarded `impersonateUserId` on `avatars` and `storage` file requests. +* Fixed: URL-encode path parameters across all services. + ## 25.1.0 * Added: Email metadata fields to `User` (`emailCanonical`, `emailIsFree`, `emailIsDisposable`, `emailIsCorporate`, `emailIsCanonical`). diff --git a/README.md b/README.md index bc73e6c2..a4cf00a8 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Add this to your package's `pubspec.yaml` file: ```yml dependencies: - appwrite: ^25.1.0 + appwrite: ^25.2.0 ``` You can install packages from the command line: diff --git a/docs/examples/account/create.md b/docs/examples/account/create.md index d4bf5757..8343f628 100644 --- a/docs/examples/account/create.md +++ b/docs/examples/account/create.md @@ -10,7 +10,7 @@ Account account = Account(client); User result = await account.create( userId: '', email: 'email@example.com', - password: '', + password: 'password', name: '', // optional ); ``` diff --git a/docs/examples/account/update-password.md b/docs/examples/account/update-password.md index 46fa5a1d..c2604a9c 100644 --- a/docs/examples/account/update-password.md +++ b/docs/examples/account/update-password.md @@ -8,7 +8,7 @@ Client client = Client() Account account = Account(client); User result = await account.updatePassword( - password: '', - oldPassword: '', // optional + password: 'password', + oldPassword: 'password', // optional ); ``` diff --git a/docs/examples/account/update-recovery.md b/docs/examples/account/update-recovery.md index 87ff07bd..809aa044 100644 --- a/docs/examples/account/update-recovery.md +++ b/docs/examples/account/update-recovery.md @@ -10,6 +10,6 @@ Account account = Account(client); Token result = await account.updateRecovery( userId: '', secret: '', - password: '', + password: 'password', ); ``` diff --git a/lib/appwrite.dart b/lib/appwrite.dart index ae51be5e..6615de8a 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.9.x. +/// This SDK is compatible with Appwrite server version 1.9.x. /// For older versions, please check /// [previous releases](https://github.com/appwrite/sdk-for-flutter/releases). library appwrite; diff --git a/lib/channel.dart b/lib/channel.dart index afc68efa..d511f5a4 100644 --- a/lib/channel.dart +++ b/lib/channel.dart @@ -2,33 +2,19 @@ part of appwrite; // Marker classes for type safety class _Root {} - class _Database {} - class _Collection {} - class _Document {} - class _TablesDB {} - class _Table {} - class _Row {} - class _Bucket {} - class _File {} - class _Func {} - class _Execution {} - class _Team {} - class _Membership {} - class _Presence {} - class _Resolved {} // Helper function for normalizing ID @@ -113,15 +99,15 @@ extension DatabaseChannel on Channel<_Database> { /// Only available on Channel<_Collection> extension CollectionChannel on Channel<_Collection> { - Channel<_Document> document([String? id]) => - _next<_Document>('documents', id); + Channel<_Document> document([String? id]) => _next<_Document>('documents', id); } // --- TABLESDB ROUTE --- /// Only available on Channel<_TablesDB> extension TablesDBChannel on Channel<_TablesDB> { - Channel<_Table> table(String id) => _next<_Table>('tables', id); + Channel<_Table> table(String id) => + _next<_Table>('tables', id); } /// Only available on Channel<_Table> 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/operator.dart b/lib/operator.dart index 337dda30..9dd7f4c7 100644 --- a/lib/operator.dart +++ b/lib/operator.dart @@ -31,7 +31,7 @@ class Operator { result['method'] = method; - if (values != null) { + if(values != null) { result['values'] = values is List ? values : [values]; } @@ -147,7 +147,8 @@ class Operator { Operator._('arrayRemove', [value]).toString(); /// Remove duplicate values from an array attribute. - static String arrayUnique() => Operator._('arrayUnique', []).toString(); + static String arrayUnique() => + Operator._('arrayUnique', []).toString(); /// Keep only values that exist in both the current array and the provided array. static String arrayIntersect(List values) => @@ -172,7 +173,8 @@ class Operator { Operator._('stringReplace', [search, replace]).toString(); /// Toggle a boolean attribute. - static String toggle() => Operator._('toggle', []).toString(); + static String toggle() => + Operator._('toggle', []).toString(); /// Add days to a date attribute. static String dateAddDays(int days) => @@ -183,5 +185,6 @@ class Operator { Operator._('dateSubDays', [days]).toString(); /// Set a date attribute to the current date and time. - static String dateSetNow() => Operator._('dateSetNow', []).toString(); + static String dateSetNow() => + Operator._('dateSetNow', []).toString(); } diff --git a/lib/query.dart b/lib/query.dart index 1a41ba82..95365bf7 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. @@ -140,46 +140,50 @@ class Query { Query._('notEndsWith', attribute, value).toString(); /// Filter resources where document was created before [value]. - static String createdBefore(String value) => lessThan('\$createdAt', value); + static String createdBefore(String value) => + lessThan('\$createdAt', value); /// Filter resources where document was created after [value]. - static String createdAfter(String value) => greaterThan('\$createdAt', value); + static String createdAfter(String value) => + greaterThan('\$createdAt', value); /// Filter resources where document was created between [start] and [end] (inclusive). static String createdBetween(String start, String end) => between('\$createdAt', start, end); /// Filter resources where document was updated before [value]. - static String updatedBefore(String value) => lessThan('\$updatedAt', value); + static String updatedBefore(String value) => + lessThan('\$updatedAt', value); /// Filter resources where document was updated after [value]. - static String updatedAfter(String value) => greaterThan('\$updatedAt', value); + static String updatedAfter(String value) => + greaterThan('\$updatedAt', value); /// Filter resources where document was updated between [start] and [end] (inclusive). static String updatedBetween(String start, String end) => between('\$updatedAt', start, end); static String or(List queries) => Query._( - 'or', - null, - queries.map((query) => jsonDecode(query)).toList(), - ).toString(); + 'or', + null, + queries.map((query) => jsonDecode(query)).toList(), + ).toString(); static String and(List queries) => Query._( - 'and', - null, - queries.map((query) => jsonDecode(query)).toList(), - ).toString(); + 'and', + null, + queries.map((query) => jsonDecode(query)).toList(), + ).toString(); /// Filter array elements where at least one element matches all the specified queries. /// /// [attribute] The attribute containing the array to filter on. /// [queries] The list of query strings to match against array elements. static String elemMatch(String attribute, List queries) => Query._( - 'elemMatch', - attribute, - queries.map((query) => jsonDecode(query)).toList(), - ).toString(); + 'elemMatch', + attribute, + queries.map((query) => jsonDecode(query)).toList(), + ).toString(); /// Specify which attributes should be returned by the API call. static String select(List attributes) => @@ -194,17 +198,18 @@ class Query { Query._('orderDesc', attribute).toString(); /// Sort results randomly. - static String orderRandom() => Query._('orderRandom').toString(); + static String orderRandom() => + Query._('orderRandom').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) => @@ -214,55 +219,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, - 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) => @@ -295,4 +272,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 391b0d63..9c021e93 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,21 +9,18 @@ class Account extends Service { Future get() async { final String apiPath = '/account'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -33,35 +30,29 @@ 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 { final String apiPath = '/account'; - final Map apiParams = { - 'userId': userId, - 'email': email, - 'password': password, - if (name != null) 'name': name, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.User.fromMap(res.data); + final Map apiParams = { + 'userId': userId, + + 'email': email, + + 'password': password, + + if (name != null) 'name': name, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 @@ -71,83 +62,66 @@ 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 { final String apiPath = '/account/email'; - final Map apiParams = { - 'email': email, - 'password': password, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.User.fromMap(res.data); + final Map apiParams = { + 'email': email, + + 'password': password, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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, - bool? total, - }) async { + Future listIdentities({List? queries, bool? total}) async { final String apiPath = '/account/identities'; - final Map apiParams = { - if (queries != null) 'queries': queries, - if (total != null) 'total': total, - }; + final Map apiParams = { + if (queries != null) 'queries': queries, + + if (total != null) 'total': total, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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 Map apiParams = {}; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; - - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return res.data; + final String apiPath = '/account/identities/{identityId}'.replaceAll('{identityId}', identityId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; + + 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 @@ -158,24 +132,20 @@ class Account extends Service { Future createJWT({int? duration}) async { final String apiPath = '/account/jwts'; - final Map apiParams = { - if (duration != null) 'duration': duration, - }; + final Map apiParams = { + if (duration != null) 'duration': duration, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 @@ -183,278 +153,212 @@ class Account extends Service { Future listLogs({List? queries, bool? total}) async { final String apiPath = '/account/logs'; - final Map apiParams = { - if (queries != null) 'queries': queries, - if (total != null) 'total': total, - }; + final Map apiParams = { + if (queries != null) 'queries': queries, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + if (total != null) 'total': total, - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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 { final String apiPath = '/account/mfa'; - final Map apiParams = {'mfa': mfa}; + final Map apiParams = { + 'mfa': mfa, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 Map apiParams = {}; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; - - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return res.data; + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; + + 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 Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; - - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return res.data; + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; + + 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 { final String apiPath = '/account/mfa/challenges'; - final Map apiParams = {'factor': factor.value}; + final Map apiParams = { + 'factor': factor.value, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 { final String apiPath = '/account/mfa/challenges'; - final Map apiParams = {'factor': factor.value}; + final Map apiParams = { + 'factor': factor.value, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 @@ -462,34 +366,26 @@ 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 { final String apiPath = '/account/mfa/challenges'; - final Map apiParams = { - 'challengeId': challengeId, - 'otp': otp, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Session.fromMap(res.data); + final Map apiParams = { + 'challengeId': challengeId, + + 'otp': otp, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 @@ -497,103 +393,84 @@ 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 { final String apiPath = '/account/mfa/challenges'; - final Map apiParams = { - 'challengeId': challengeId, - 'otp': otp, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Session.fromMap(res.data); + final Map apiParams = { + 'challengeId': challengeId, + + 'otp': otp, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 { final String apiPath = '/account/mfa/factors'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 { final String apiPath = '/account/mfa/factors'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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 { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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 @@ -603,21 +480,18 @@ class Account extends Service { Future getMFARecoveryCodes() async { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -625,28 +499,22 @@ 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 { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 @@ -657,50 +525,40 @@ class Account extends Service { Future createMFARecoveryCodes() async { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 @@ -710,74 +568,62 @@ class Account extends Service { Future updateMFARecoveryCodes() async { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 { final String apiPath = '/account/name'; - final Map apiParams = {'name': name}; + final Map apiParams = { + 'name': name, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 { final String apiPath = '/account/password'; - final Map apiParams = { - 'password': password, - if (oldPassword != null) 'oldPassword': oldPassword, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.User.fromMap(res.data); + final Map apiParams = { + 'password': password, + + if (oldPassword != null) 'oldPassword': oldPassword, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 @@ -785,52 +631,43 @@ 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 { final String apiPath = '/account/phone'; - final Map apiParams = { - 'phone': phone, - 'password': password, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.User.fromMap(res.data); + final Map apiParams = { + 'phone': phone, + + 'password': password, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 { final String apiPath = '/account/prefs'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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 @@ -839,22 +676,20 @@ class Account extends Service { Future updatePrefs({required Map prefs}) async { final String apiPath = '/account/prefs'; - final Map apiParams = {'prefs': prefs}; + final Map apiParams = { + 'prefs': prefs, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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. @@ -865,28 +700,25 @@ 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 { final String apiPath = '/account/recovery'; - final Map apiParams = {'email': email, 'url': url}; + final Map apiParams = { + 'email': email, + + 'url': url, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 @@ -894,38 +726,32 @@ 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 { final String apiPath = '/account/recovery'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - 'password': password, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Token.fromMap(res.data); + final Map apiParams = { + 'userId': userId, + + 'secret': secret, + + 'password': password, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 @@ -933,21 +759,18 @@ class Account extends Service { Future listSessions() async { final String apiPath = '/account/sessions'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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 @@ -955,21 +778,18 @@ class Account extends Service { Future deleteSessions() async { final String apiPath = '/account/sessions'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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 @@ -982,254 +802,213 @@ class Account extends Service { Future createAnonymousSession() async { final String apiPath = '/account/sessions/anonymous'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 { final String apiPath = '/account/sessions/email'; - final Map apiParams = { - 'email': email, - 'password': password, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Session.fromMap(res.data); + final Map apiParams = { + 'email': email, + + 'password': password, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 { final String apiPath = '/account/sessions/magic-url'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + + 'secret': secret, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 = { - if (success != null) 'success': success, - if (failure != null) 'failure': failure, - if (scopes != null) '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 = { + + if (success != null) 'success': success, + + if (failure != null) 'failure': failure, + + if (scopes != null) '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 { final String apiPath = '/account/sessions/phone'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + + 'secret': secret, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 { final String apiPath = '/account/sessions/token'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + + 'secret': secret, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 Map apiParams = {}; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Session.fromMap(res.data); + final String apiPath = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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 Map apiParams = {}; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Session.fromMap(res.data); + final String apiPath = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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, @@ -1238,26 +1017,20 @@ 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 Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; - - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return res.data; + final String apiPath = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; + + 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 @@ -1266,22 +1039,18 @@ class Account extends Service { Future updateStatus() async { final String apiPath = '/account/status'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 @@ -1289,33 +1058,27 @@ 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 { final String apiPath = '/account/targets/push'; - final Map apiParams = { - 'targetId': targetId, - 'identifier': identifier, - if (providerId != null) 'providerId': providerId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Target.fromMap(res.data); + final Map apiParams = { + 'targetId': targetId, + + 'identifier': identifier, + + if (providerId != null) 'providerId': providerId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 @@ -1323,57 +1086,43 @@ 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; - - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return res.data; + final String apiPath = '/account/targets/{targetId}/push'.replaceAll('{targetId}', targetId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; + + 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 @@ -1385,38 +1134,32 @@ 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 { final String apiPath = '/account/tokens/email'; - final Map apiParams = { - 'userId': userId, - 'email': email, - if (phrase != null) 'phrase': phrase, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Token.fromMap(res.data); + final Map apiParams = { + 'userId': userId, + + 'email': email, + + if (phrase != null) 'phrase': phrase, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 @@ -1428,98 +1171,87 @@ 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 { final String apiPath = '/account/tokens/magic-url'; - final Map apiParams = { - 'userId': userId, - 'email': email, - if (url != null) 'url': url, - if (phrase != null) 'phrase': phrase, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Token.fromMap(res.data); + final Map apiParams = { + 'userId': userId, + + 'email': email, + + if (url != null) 'url': url, + + if (phrase != null) 'phrase': phrase, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 = { - if (success != null) 'success': success, - if (failure != null) 'failure': failure, - if (scopes != null) '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 = { + + if (success != null) 'success': success, + + if (failure != null) 'failure': failure, + + if (scopes != null) '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 @@ -1528,32 +1260,29 @@ 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 { final String apiPath = '/account/tokens/phone'; - final Map apiParams = {'userId': userId, 'phone': phone}; + final Map apiParams = { + 'userId': userId, + + 'phone': phone, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 @@ -1565,31 +1294,29 @@ 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 createEmailVerification({required String url}) async { final String apiPath = '/account/verifications/email'; - final Map apiParams = {'url': url}; + final Map apiParams = { + 'url': url, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 @@ -1601,93 +1328,81 @@ 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. - /// - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.createEmailVerification` instead.', - ) + /// + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.createEmailVerification` instead.') Future createVerification({required String url}) async { final String apiPath = '/account/verifications/email'; - final Map apiParams = {'url': url}; + final Map apiParams = { + 'url': url, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 updateEmailVerification({ - required String userId, - required String secret, - }) async { + Future updateEmailVerification({required String userId, required String secret}) async { final String apiPath = '/account/verifications/email'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + + 'secret': secret, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 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. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.updateEmailVerification` instead.', - ) - Future updateVerification({ - required String userId, - required String secret, - }) async { + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.updateEmailVerification` instead.') + Future updateVerification({required String userId, required String secret}) async { final String apiPath = '/account/verifications/email'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + + 'secret': secret, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 @@ -1701,49 +1416,42 @@ class Account extends Service { Future createPhoneVerification() async { final String apiPath = '/account/verifications/phone'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 { final String apiPath = '/account/verifications/phone'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + + 'secret': secret, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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); } } diff --git a/lib/services/avatars.dart b/lib/services/avatars.dart index a3162b76..4dca3b16 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,164 +11,139 @@ 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 = { - if (width != null) 'width': width, - if (height != null) 'height': height, - if (quality != null) '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 = { + + if (width != null) 'width': width, + + if (height != null) 'height': height, + + if (quality != null) 'quality': quality, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 = { - if (width != null) 'width': width, - if (height != null) 'height': height, - if (quality != null) '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 = { + + if (width != null) 'width': width, + + if (height != null) 'height': height, + + if (quality != null) 'quality': quality, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 { final String apiPath = '/avatars/favicon'; - final Map params = { - 'url': url, - '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, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 = { - if (width != null) 'width': width, - if (height != null) 'height': height, - if (quality != null) '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 = { + + if (width != null) 'width': width, + + if (height != null) 'height': height, + + if (quality != null) 'quality': quality, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 { final String apiPath = '/avatars/image'; - final Map params = { - 'url': url, - if (width != null) 'width': width, - if (height != null) '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, + + if (width != null) 'width': width, + + if (height != null) 'height': height, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 @@ -176,135 +151,125 @@ 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 { final String apiPath = '/avatars/initials'; - final Map params = { - if (name != null) 'name': name, - if (width != null) 'width': width, - if (height != null) 'height': height, - if (background != null) '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 = { + + if (name != null) 'name': name, + + if (width != null) 'width': width, + + if (height != null) 'height': height, + + if (background != null) 'background': background, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 { final String apiPath = '/avatars/qr'; - final Map params = { - 'text': text, - if (size != null) 'size': size, - if (margin != null) 'margin': margin, - if (download != null) '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, + + if (size != null) 'size': size, + + if (margin != null) 'margin': margin, + + if (download != null) 'download': download, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// Use this endpoint to capture a screenshot of any website URL. This endpoint /// uses a headless browser to render the webpage and capture it as an image. - /// + /// /// You can configure the browser viewport size, theme, user agent, /// geolocation, permissions, and more. Capture either just the viewport or the /// full page scroll. - /// + /// /// When width and height are specified, the image is resized accordingly. If /// both dimensions are 0, the API provides an image at original size. If /// dimensions are not specified, the default viewport size is 1280x720px. - Future getScreenshot({ - required String url, - Map? headers, - int? viewportWidth, - int? viewportHeight, - double? scale, - enums.BrowserTheme? theme, - String? userAgent, - bool? fullpage, - String? locale, - enums.Timezone? timezone, - double? latitude, - double? longitude, - double? accuracy, - bool? touch, - List? permissions, - int? sleep, - int? width, - int? height, - int? quality, - enums.ImageFormat? output, - }) async { + Future getScreenshot({required String url, Map? headers, int? viewportWidth, int? viewportHeight, double? scale, enums.BrowserTheme? theme, String? userAgent, bool? fullpage, String? locale, enums.Timezone? timezone, double? latitude, double? longitude, double? accuracy, bool? touch, List? permissions, int? sleep, int? width, int? height, int? quality, enums.ImageFormat? output}) async { final String apiPath = '/avatars/screenshots'; - final Map params = { - 'url': url, - if (headers != null) 'headers': headers, - if (viewportWidth != null) 'viewportWidth': viewportWidth, - if (viewportHeight != null) 'viewportHeight': viewportHeight, - if (scale != null) 'scale': scale, - if (theme != null) 'theme': theme.value, - if (userAgent != null) 'userAgent': userAgent, - if (fullpage != null) 'fullpage': fullpage, - if (locale != null) 'locale': locale, - if (timezone != null) 'timezone': timezone.value, - if (latitude != null) 'latitude': latitude, - if (longitude != null) 'longitude': longitude, - if (accuracy != null) 'accuracy': accuracy, - if (touch != null) 'touch': touch, - if (permissions != null) - 'permissions': permissions.map((e) => e.value).toList(), - if (sleep != null) 'sleep': sleep, - if (width != null) 'width': width, - if (height != null) 'height': height, - if (quality != null) 'quality': quality, - if (output != null) 'output': output.value, - '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, + + if (headers != null) 'headers': headers, + + if (viewportWidth != null) 'viewportWidth': viewportWidth, + + if (viewportHeight != null) 'viewportHeight': viewportHeight, + + if (scale != null) 'scale': scale, + + if (theme != null) 'theme': theme.value, + + if (userAgent != null) 'userAgent': userAgent, + + if (fullpage != null) 'fullpage': fullpage, + + if (locale != null) 'locale': locale, + + if (timezone != null) 'timezone': timezone.value, + + if (latitude != null) 'latitude': latitude, + + if (longitude != null) 'longitude': longitude, + + if (accuracy != null) 'accuracy': accuracy, + + if (touch != null) 'touch': touch, + + if (permissions != null) 'permissions': permissions.map((e) => e.value).toList(), + + if (sleep != null) 'sleep': sleep, + + if (width != null) 'width': width, + + if (height != null) 'height': height, + + if (quality != null) 'quality': quality, + + if (output != null) 'output': output.value, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } } diff --git a/lib/services/databases.dart b/lib/services/databases.dart index 84df4444..0bfd935a 100644 --- a/lib/services/databases.dart +++ b/lib/services/databases.dart @@ -1,487 +1,339 @@ 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); /// List transactions across all databases. - Future listTransactions({ - List? queries, - }) async { + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.listTransactions` instead.') + Future listTransactions({List? queries}) async { final String apiPath = '/databases/transactions'; - final Map apiParams = { - if (queries != null) 'queries': queries, - }; + final Map apiParams = { + if (queries != null) 'queries': queries, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.TransactionList.fromMap(res.data); - return models.TransactionList.fromMap(res.data); } /// Create a new transaction. + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.createTransaction` instead.') Future createTransaction({int? ttl}) async { final String apiPath = '/databases/transactions'; - final Map apiParams = {if (ttl != null) 'ttl': ttl}; + final Map apiParams = { + if (ttl != null) 'ttl': ttl, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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.Transaction.fromMap(res.data); - return models.Transaction.fromMap(res.data); } /// Get a transaction by its unique ID. - Future getTransaction({ - required String transactionId, - }) async { - final String apiPath = '/databases/transactions/{transactionId}'.replaceAll( - '{transactionId}', - transactionId, - ); - - final Map apiParams = {}; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Transaction.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.getTransaction` instead.') + Future getTransaction({required String transactionId}) async { + final String apiPath = '/databases/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Transaction.fromMap(res.data); + } /// Update a transaction, to either commit or roll back its operations. - Future updateTransaction({ - required String transactionId, - bool? commit, - bool? rollback, - }) async { - final String apiPath = '/databases/transactions/{transactionId}'.replaceAll( - '{transactionId}', - transactionId, - ); - - final Map apiParams = { - if (commit != null) 'commit': commit, - if (rollback != null) 'rollback': rollback, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Transaction.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.updateTransaction` instead.') + Future updateTransaction({required String transactionId, bool? commit, bool? rollback}) async { + final String apiPath = '/databases/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + if (commit != null) 'commit': commit, + + if (rollback != null) 'rollback': rollback, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Transaction.fromMap(res.data); + } /// Delete a transaction by its unique ID. + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.deleteTransaction` instead.') Future deleteTransaction({required String transactionId}) async { - final String apiPath = '/databases/transactions/{transactionId}'.replaceAll( - '{transactionId}', - transactionId, - ); - - final Map apiParams = {}; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; - - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return res.data; + final String apiPath = '/databases/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; + } /// Create multiple operations in a single transaction. - Future createOperations({ - required String transactionId, - List? operations, - }) async { - final String apiPath = '/databases/transactions/{transactionId}/operations' - .replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - if (operations != null) 'operations': operations, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Transaction.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.createOperations` instead.') + Future createOperations({required String transactionId, List? operations}) async { + final String apiPath = '/databases/transactions/{transactionId}/operations'.replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + if (operations != null) 'operations': operations, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Transaction.fromMap(res.data); + } /// 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, - String? transactionId, - bool? total, - int? ttl, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - if (transactionId != null) 'transactionId': transactionId, - if (total != null) 'total': total, - if (ttl != null) 'ttl': ttl, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, String? transactionId, bool? total, int? ttl}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + + if (transactionId != null) 'transactionId': transactionId, + + if (total != null) 'total': total, + + if (ttl != null) 'ttl': ttl, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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, - String? transactionId, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId); - - final Map apiParams = { - 'documentId': documentId, - 'data': data, - 'permissions': permissions, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, String? transactionId}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); + + final Map apiParams = { + 'documentId': documentId, + + 'data': data, + + 'permissions': permissions, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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, - String? transactionId, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - if (transactionId != null) 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, String? transactionId}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + + if (transactionId != null) 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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, - Map? data, - List? permissions, - String? transactionId, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); - - final Map apiParams = { - if (data != null) 'data': data, - 'permissions': permissions, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, Map? data, List? permissions, String? transactionId}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + + final Map apiParams = { + if (data != null) 'data': data, + + 'permissions': permissions, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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, - String? transactionId, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); - - final Map apiParams = { - if (data != null) 'data': data, - 'permissions': permissions, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, String? transactionId}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + + final Map apiParams = { + if (data != null) 'data': data, + + 'permissions': permissions, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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, - String? transactionId, - }) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); - - final Map apiParams = {'transactionId': transactionId}; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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, String? transactionId}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + + final Map apiParams = { + if (transactionId != null) 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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, - String? transactionId, - }) 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 = { - if (value != null) 'value': value, - 'min': min, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, String? transactionId}) 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 = { + if (value != null) 'value': value, + + 'min': min, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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, - String? transactionId, - }) 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 = { - if (value != null) 'value': value, - 'max': max, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, String? transactionId}) 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 = { + if (value != null) 'value': value, + + 'max': max, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); + } } diff --git a/lib/services/functions.dart b/lib/services/functions.dart index 7f0606a5..0640f80f 100644 --- a/lib/services/functions.dart +++ b/lib/services/functions.dart @@ -1,109 +1,82 @@ 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, - bool? total, - }) async { - final String apiPath = '/functions/{functionId}/executions'.replaceAll( - '{functionId}', - functionId, - ); - - final Map apiParams = { - if (queries != null) 'queries': queries, - if (total != null) 'total': total, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, bool? total}) async { + final String apiPath = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + + if (total != null) 'total': total, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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 = { - if (body != null) 'body': body, - if (xasync != null) 'async': xasync, - if (path != null) 'path': path, - if (method != null) 'method': method.value, - if (headers != null) 'headers': headers, - 'scheduledAt': scheduledAt, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 = { + if (body != null) 'body': body, + + if (xasync != null) 'async': xasync, + + if (path != null) 'path': path, + + if (method != null) 'method': method.value, + + if (headers != null) 'headers': headers, + + 'scheduledAt': scheduledAt, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Execution.fromMap(res.data); + } } diff --git a/lib/services/graphql.dart b/lib/services/graphql.dart index 048d4d98..978331fa 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,45 +10,39 @@ class Graphql extends Service { Future query({required Map query}) async { final String apiPath = '/graphql'; - final Map apiParams = {'query': query}; + final Map apiParams = { + 'query': query, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'x-sdk-graphql': 'true', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'x-sdk-graphql': 'true', 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 { final String apiPath = '/graphql/mutation'; - final Map apiParams = {'query': query}; + final Map apiParams = { + 'query': query, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'x-sdk-graphql': 'true', 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'x-sdk-graphql': 'true', - 'content-type': 'application/json', - 'accept': '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; } } diff --git a/lib/services/locale.dart b/lib/services/locale.dart index d4831b74..c45a1269 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,26 +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 { final String apiPath = '/locale'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -37,21 +34,18 @@ class Locale extends Service { Future listCodes() async { final String apiPath = '/locale/codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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 @@ -59,21 +53,18 @@ class Locale extends Service { Future listContinents() async { final String apiPath = '/locale/continents'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -81,21 +72,18 @@ class Locale extends Service { Future listCountries() async { final String apiPath = '/locale/countries'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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 @@ -103,21 +91,18 @@ class Locale extends Service { Future listCountriesEU() async { final String apiPath = '/locale/countries/eu'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -125,21 +110,18 @@ class Locale extends Service { Future listCountriesPhones() async { final String apiPath = '/locale/countries/phones'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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 @@ -148,21 +130,18 @@ class Locale extends Service { Future listCurrencies() async { final String apiPath = '/locale/currencies'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -170,20 +149,17 @@ class Locale extends Service { Future listLanguages() async { final String apiPath = '/locale/languages'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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); } } diff --git a/lib/services/messaging.dart b/lib/services/messaging.dart index 15585ec4..3dffe41b 100644 --- a/lib/services/messaging.dart +++ b/lib/services/messaging.dart @@ -1,67 +1,48 @@ 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, - ); + 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 apiParams = { + 'subscriberId': subscriberId, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + 'targetId': targetId, - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Subscriber.fromMap(res.data); - 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); + 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 apiParams = {}; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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; } } diff --git a/lib/services/presences.dart b/lib/services/presences.dart index 2e3d6114..088700cb 100644 --- a/lib/services/presences.dart +++ b/lib/services/presences.dart @@ -5,160 +5,123 @@ class Presences extends Service { Presences(super.client); /// List presence logs. Expired entries are filtered out automatically. - /// - Future list({ - List? queries, - bool? total, - int? ttl, - }) async { + /// + Future list({List? queries, bool? total, int? ttl}) async { final String apiPath = '/presences'; - final Map apiParams = { - if (queries != null) 'queries': queries, - if (total != null) 'total': total, - if (ttl != null) 'ttl': ttl, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.PresenceList.fromMap(res.data); + final Map apiParams = { + if (queries != null) 'queries': queries, + + if (total != null) 'total': total, + + if (ttl != null) 'ttl': ttl, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.PresenceList.fromMap(res.data); + } /// Get a presence log by its unique ID. Entries whose `expiresAt` is in the /// past are treated as not found. - /// + /// Future get({required String presenceId}) async { - final String apiPath = '/presences/{presenceId}'.replaceAll( - '{presenceId}', - presenceId, - ); - - final Map apiParams = {}; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Presence.fromMap(res.data); + final String apiPath = '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Presence.fromMap(res.data); + } /// Create or update a presence log by its user ID. - /// - Future upsert({ - required String presenceId, - required String status, - List? permissions, - String? expiresAt, - Map? metadata, - }) async { - final String apiPath = '/presences/{presenceId}'.replaceAll( - '{presenceId}', - presenceId, - ); - - final Map apiParams = { - 'status': status, - if (permissions != null) 'permissions': permissions, - if (expiresAt != null) 'expiresAt': expiresAt, - if (metadata != null) 'metadata': metadata, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Presence.fromMap(res.data); + /// + Future upsert({required String presenceId, required String status, List? permissions, String? expiresAt, Map? metadata}) async { + final String apiPath = '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); + + final Map apiParams = { + 'status': status, + + if (permissions != null) 'permissions': permissions, + + if (expiresAt != null) 'expiresAt': expiresAt, + + if (metadata != null) 'metadata': metadata, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Presence.fromMap(res.data); + } /// Update a presence log by its unique ID. Using the patch method you can pass /// only specific fields that will get updated. - /// - Future update({ - required String presenceId, - String? status, - String? expiresAt, - Map? metadata, - List? permissions, - bool? purge, - }) async { - final String apiPath = '/presences/{presenceId}'.replaceAll( - '{presenceId}', - presenceId, - ); - - final Map apiParams = { - if (status != null) 'status': status, - if (expiresAt != null) 'expiresAt': expiresAt, - if (metadata != null) 'metadata': metadata, - if (permissions != null) 'permissions': permissions, - if (purge != null) 'purge': purge, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Presence.fromMap(res.data); + /// + Future update({required String presenceId, String? status, String? expiresAt, Map? metadata, List? permissions, bool? purge}) async { + final String apiPath = '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); + + final Map apiParams = { + if (status != null) 'status': status, + + if (expiresAt != null) 'expiresAt': expiresAt, + + if (metadata != null) 'metadata': metadata, + + if (permissions != null) 'permissions': permissions, + + if (purge != null) 'purge': purge, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Presence.fromMap(res.data); + } /// Delete a presence log by its unique ID. - /// + /// Future delete({required String presenceId}) async { - final String apiPath = '/presences/{presenceId}'.replaceAll( - '{presenceId}', - presenceId, - ); - - final Map apiParams = {}; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; - - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return res.data; + final String apiPath = '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; + } } diff --git a/lib/services/storage.dart b/lib/services/storage.dart index 83438aaa..c9499a99 100644 --- a/lib/services/storage.dart +++ b/lib/services/storage.dart @@ -1,209 +1,166 @@ 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, - bool? total, - }) async { - final String apiPath = '/storage/buckets/{bucketId}/files'.replaceAll( - '{bucketId}', - bucketId, - ); - - final Map apiParams = { - if (queries != null) 'queries': queries, - if (search != null) 'search': search, - if (total != null) 'total': total, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, bool? total}) async { + final String apiPath = '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + + if (search != null) 'search': search, + + if (total != null) 'total': total, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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, - if (permissions != null) 'permissions': permissions, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'multipart/form-data', - 'accept': 'application/json', - }; - - 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, + + if (permissions != null) 'permissions': permissions, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'multipart/form-data', 'accept': 'application/json', + }; + + 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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 = { - if (name != null) 'name': name, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 = { + if (name != null) 'name': name, + + 'permissions': permissions, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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 = { - if (token != null) '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 = { + + if (token != null) 'token': token, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 @@ -211,74 +168,60 @@ 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 = { - if (width != null) 'width': width, - if (height != null) 'height': height, - if (gravity != null) 'gravity': gravity.value, - if (quality != null) 'quality': quality, - if (borderWidth != null) 'borderWidth': borderWidth, - if (borderColor != null) 'borderColor': borderColor, - if (borderRadius != null) 'borderRadius': borderRadius, - if (opacity != null) 'opacity': opacity, - if (rotation != null) 'rotation': rotation, - if (background != null) 'background': background, - if (output != null) 'output': output.value, - if (token != null) '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 = { + + if (width != null) 'width': width, + + if (height != null) 'height': height, + + if (gravity != null) 'gravity': gravity.value, + + if (quality != null) 'quality': quality, + + if (borderWidth != null) 'borderWidth': borderWidth, + + if (borderColor != null) 'borderColor': borderColor, + + if (borderRadius != null) 'borderRadius': borderRadius, + + if (opacity != null) 'opacity': opacity, + + if (rotation != null) 'rotation': rotation, + + if (background != null) 'background': background, + + if (output != null) 'output': output.value, + + if (token != null) 'token': token, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 = { - if (token != null) '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 = { + + if (token != null) 'token': token, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } } diff --git a/lib/services/tables_db.dart b/lib/services/tables_db.dart index f27da9da..42572021 100644 --- a/lib/services/tables_db.dart +++ b/lib/services/tables_db.dart @@ -5,455 +5,319 @@ class TablesDB extends Service { TablesDB(super.client); /// List transactions across all databases. - Future listTransactions({ - List? queries, - }) async { + Future listTransactions({List? queries}) async { final String apiPath = '/tablesdb/transactions'; - final Map apiParams = { - if (queries != null) 'queries': queries, - }; + final Map apiParams = { + if (queries != null) 'queries': queries, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.TransactionList.fromMap(res.data); - return models.TransactionList.fromMap(res.data); } /// Create a new transaction. Future createTransaction({int? ttl}) async { final String apiPath = '/tablesdb/transactions'; - final Map apiParams = {if (ttl != null) 'ttl': ttl}; + final Map apiParams = { + if (ttl != null) 'ttl': ttl, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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.Transaction.fromMap(res.data); - return models.Transaction.fromMap(res.data); } /// Get a transaction by its unique ID. - Future getTransaction({ - required String transactionId, - }) async { - final String apiPath = '/tablesdb/transactions/{transactionId}'.replaceAll( - '{transactionId}', - transactionId, - ); - - final Map apiParams = {}; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Transaction.fromMap(res.data); + Future getTransaction({required String transactionId}) async { + final String apiPath = '/tablesdb/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Transaction.fromMap(res.data); + } /// Update a transaction, to either commit or roll back its operations. - Future updateTransaction({ - required String transactionId, - bool? commit, - bool? rollback, - }) async { - final String apiPath = '/tablesdb/transactions/{transactionId}'.replaceAll( - '{transactionId}', - transactionId, - ); - - final Map apiParams = { - if (commit != null) 'commit': commit, - if (rollback != null) 'rollback': rollback, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; - - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Transaction.fromMap(res.data); + Future updateTransaction({required String transactionId, bool? commit, bool? rollback}) async { + final String apiPath = '/tablesdb/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + if (commit != null) 'commit': commit, + + if (rollback != null) 'rollback': rollback, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Transaction.fromMap(res.data); + } /// Delete a transaction by its unique ID. Future deleteTransaction({required String transactionId}) async { - final String apiPath = '/tablesdb/transactions/{transactionId}'.replaceAll( - '{transactionId}', - transactionId, - ); - - final Map apiParams = {}; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; - - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return res.data; + final String apiPath = '/tablesdb/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; + } /// Create multiple operations in a single transaction. - Future createOperations({ - required String transactionId, - List? operations, - }) async { - final String apiPath = '/tablesdb/transactions/{transactionId}/operations' - .replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - if (operations != null) 'operations': operations, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Transaction.fromMap(res.data); + Future createOperations({required String transactionId, List? operations}) async { + final String apiPath = '/tablesdb/transactions/{transactionId}/operations'.replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + if (operations != null) 'operations': operations, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Transaction.fromMap(res.data); + } /// 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, - String? transactionId, - bool? total, - int? ttl, - }) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - if (transactionId != null) 'transactionId': transactionId, - if (total != null) 'total': total, - if (ttl != null) 'ttl': ttl, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, String? transactionId, bool? total, int? ttl}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + + if (transactionId != null) 'transactionId': transactionId, + + if (total != null) 'total': total, + + if (ttl != null) 'ttl': ttl, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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/references/cloud/server-dart/tablesDB#createTable) /// API or directly from your database console. - Future createRow({ - required String databaseId, - required String tableId, - required String rowId, - required Map data, - List? permissions, - String? transactionId, - }) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId); - - final Map apiParams = { - 'rowId': rowId, - 'data': data, - 'permissions': permissions, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, String? transactionId}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); + + final Map apiParams = { + 'rowId': rowId, + + 'data': data, + + 'permissions': permissions, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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, - String? transactionId, - }) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - if (transactionId != null) 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, String? transactionId}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + + if (transactionId != null) 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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/references/cloud/server-dart/tablesDB#createTable) /// API or directly from your database console. - Future upsertRow({ - required String databaseId, - required String tableId, - required String rowId, - Map? data, - List? permissions, - String? transactionId, - }) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); - - final Map apiParams = { - if (data != null) 'data': data, - 'permissions': permissions, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, String? transactionId}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); + + final Map apiParams = { + if (data != null) 'data': data, + + 'permissions': permissions, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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, - String? transactionId, - }) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); - - final Map apiParams = { - if (data != null) 'data': data, - 'permissions': permissions, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, String? transactionId}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); + + final Map apiParams = { + if (data != null) 'data': data, + + 'permissions': permissions, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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, - String? transactionId, - }) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); - - final Map apiParams = {'transactionId': transactionId}; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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, String? transactionId}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); + + final Map apiParams = { + if (transactionId != null) 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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, - String? transactionId, - }) 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 = { - if (value != null) 'value': value, - 'min': min, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, String? transactionId}) 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 = { + if (value != null) 'value': value, + + 'min': min, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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, - String? transactionId, - }) 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 = { - if (value != null) 'value': value, - 'max': max, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, String? transactionId}) 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 = { + if (value != null) 'value': value, + + 'max': max, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); + } } diff --git a/lib/services/teams.dart b/lib/services/teams.dart index efd66405..27bc561e 100644 --- a/lib/services/teams.dart +++ b/lib/services/teams.dart @@ -1,117 +1,98 @@ 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); /// Get a list of all the teams in which the current user is a member. You can /// use the parameters to filter your results. - Future list({ - List? queries, - String? search, - bool? total, - }) async { + Future list({List? queries, String? search, bool? total}) async { final String apiPath = '/teams'; - final Map apiParams = { - if (queries != null) 'queries': queries, - if (search != null) 'search': search, - if (total != null) 'total': total, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.TeamList.fromMap(res.data); + final Map apiParams = { + if (queries != null) 'queries': queries, + + if (search != null) 'search': search, + + if (total != null) 'total': total, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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 { final String apiPath = '/teams'; - final Map apiParams = { - 'teamId': teamId, - 'name': name, - if (roles != null) 'roles': roles, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; - - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Team.fromMap(res.data); + final Map apiParams = { + 'teamId': teamId, + + 'name': name, + + if (roles != null) 'roles': roles, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 @@ -119,56 +100,44 @@ 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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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, - bool? total, - }) async { - final String apiPath = '/teams/{teamId}/memberships'.replaceAll( - '{teamId}', - teamId, - ); - - final Map apiParams = { - if (queries != null) 'queries': queries, - if (search != null) 'search': search, - if (total != null) 'total': total, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, bool? total}) async { + final String apiPath = '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + + if (search != null) 'search': search, + + if (total != null) 'total': total, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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 @@ -177,235 +146,180 @@ 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 = { - if (email != null) 'email': email, - if (userId != null) 'userId': userId, - if (phone != null) 'phone': phone, - 'roles': roles, - if (url != null) 'url': url, - if (name != null) 'name': name, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 = { + if (email != null) 'email': email, + + if (userId != null) 'userId': userId, + + if (phone != null) 'phone': phone, + + 'roles': roles, + + if (url != null) 'url': url, + + if (name != null) 'name': name, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); - - return models.Preferences.fromMap(res.data); + final String apiPath = '/teams/{teamId}/prefs'.replaceAll('{teamId}', teamId); + + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Preferences.fromMap(res.data); + } } diff --git a/lib/src/client.dart b/lib/src/client.dart index 940ddb5e..65b2f044 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -27,8 +27,7 @@ abstract class Client { factory Client({ String endPoint = 'https://cloud.appwrite.io/v1', bool selfSigned = false, - }) => - createClient(endPoint: endPoint, selfSigned: selfSigned); + }) => createClient(endPoint: endPoint, selfSigned: selfSigned); /// Handle OAuth2 session creation. Future webAuth(Uri url, {String? callbackUrlScheme}); @@ -86,17 +85,17 @@ abstract class Client { /// Set ImpersonateUserId. /// - /// Impersonate a user by ID on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data.. + /// Impersonate a user by ID. Client setImpersonateUserId(String value); /// Set ImpersonateUserEmail. /// - /// Impersonate a user by email on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data.. + /// Impersonate a user by email. Client setImpersonateUserEmail(String value); /// Set ImpersonateUserPhone. /// - /// Impersonate a user by phone on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data.. + /// Impersonate a user by phone. Client setImpersonateUserPhone(String value); /// Add headers that should be sent with all API calls. @@ -105,9 +104,10 @@ abstract class Client { /// Get the current request headers. Map getHeaders(); - /// Sends a "ping" request to Appwrite to verify connectivity. + /// Send a ping to project as part of onboarding. Future ping(); + /// Send the API request. Future call( HttpMethod method, { diff --git a/lib/src/client_base.dart b/lib/src/client_base.dart index d3f47540..9e964a79 100644 --- a/lib/src/client_base.dart +++ b/lib/src/client_base.dart @@ -6,34 +6,27 @@ 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); - /// The user cookie to authenticate with. Used by SDKs that forward an incoming Cookie header in server-side runtimes. @override ClientBase setCookie(value); - - /// Impersonate a user by ID on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. + /// Impersonate a user by ID @override ClientBase setImpersonateUserId(value); - - /// Impersonate a user by email on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. + /// Impersonate a user by email @override ClientBase setImpersonateUserEmail(value); - - /// Impersonate a user by phone on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. + /// Impersonate a user by phone @override ClientBase setImpersonateUserPhone(value); @@ -58,7 +51,10 @@ abstract class ClientBase implements Client { final response = await call( HttpMethod.get, path: apiPath, - headers: {'X-Appwrite-Project': config['project'] ?? ''}, + headers: { + 'X-Appwrite-Project': config['project'] ?? '', + 'accept': 'application/json', + }, responseType: ResponseType.plain, ); return response.data; diff --git a/lib/src/client_browser.dart b/lib/src/client_browser.dart index 516021dd..2f4c7b48 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': '25.1.0', + 'x-sdk-version': '25.2.0', 'X-Appwrite-Response-Format': '1.9.5', }; @@ -62,7 +62,6 @@ class ClientBrowser extends ClientBase with ClientMixin { config['project'] = value; return this; } - /// Your secret JSON Web Token @override ClientBrowser setJWT(value) { @@ -70,14 +69,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) { @@ -85,7 +82,6 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Session', value); return this; } - /// Your secret dev API key @override ClientBrowser setDevKey(value) { @@ -93,7 +89,6 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Dev-Key', value); return this; } - /// The user cookie to authenticate with. Used by SDKs that forward an incoming Cookie header in server-side runtimes. @override ClientBrowser setCookie(value) { @@ -101,24 +96,21 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('Cookie', value); return this; } - - /// Impersonate a user by ID on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. + /// Impersonate a user by ID @override ClientBrowser setImpersonateUserId(value) { config['impersonateUserId'] = value; addHeader('X-Appwrite-Impersonate-User-Id', value); return this; } - - /// Impersonate a user by email on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. + /// Impersonate a user by email @override ClientBrowser setImpersonateUserEmail(value) { config['impersonateUserEmail'] = value; addHeader('X-Appwrite-Impersonate-User-Email', value); return this; } - - /// Impersonate a user by phone on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. + /// Impersonate a user by phone @override ClientBrowser setImpersonateUserPhone(value) { config['impersonateUserPhone'] = value; @@ -227,12 +219,7 @@ class ClientBrowser extends ClientBase with ClientMixin { final totalChunks = (size / chunkSize).ceil(); - Future uploadChunk( - int index, - int start, - int end, - String? id, - ) async { + Future uploadChunk(int index, int start, int end, String? id) async { List chunk = []; chunk = file.bytes!.getRange(start, end).toList(); @@ -270,9 +257,7 @@ class ClientBrowser extends ClientBase with ClientMixin { bool isUploadComplete(Response response) { final chunksUploaded = response.data['chunksUploaded']; final chunksTotal = response.data['chunksTotal'] ?? totalChunks; - return chunksUploaded is num && - chunksTotal is num && - chunksUploaded >= chunksTotal; + return chunksUploaded is num && chunksTotal is num && chunksUploaded >= chunksTotal; } final progress = UploadProgress( @@ -287,7 +272,11 @@ class ClientBrowser extends ClientBase with ClientMixin { final chunks = >[]; for (var start = firstEnd; start < size; start += chunkSize) { final end = min(start + chunkSize, size); - chunks.add({'index': start ~/ chunkSize, 'start': start, 'end': end}); + chunks.add({ + 'index': start ~/ chunkSize, + 'start': start, + 'end': end, + }); } var nextChunk = 0; diff --git a/lib/src/client_io.dart b/lib/src/client_io.dart index 645efba1..6e6e2ee8 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': '25.1.0', + 'x-sdk-version': '25.2.0', 'X-Appwrite-Response-Format': '1.9.5', }; @@ -88,7 +88,6 @@ class ClientIO extends ClientBase with ClientMixin { config['project'] = value; return this; } - /// Your secret JSON Web Token @override ClientIO setJWT(value) { @@ -96,14 +95,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) { @@ -111,7 +108,6 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Session', value); return this; } - /// Your secret dev API key @override ClientIO setDevKey(value) { @@ -119,7 +115,6 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Dev-Key', value); return this; } - /// The user cookie to authenticate with. Used by SDKs that forward an incoming Cookie header in server-side runtimes. @override ClientIO setCookie(value) { @@ -127,24 +122,21 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('Cookie', value); return this; } - - /// Impersonate a user by ID on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. + /// Impersonate a user by ID @override ClientIO setImpersonateUserId(value) { config['impersonateUserId'] = value; addHeader('X-Appwrite-Impersonate-User-Id', value); return this; } - - /// Impersonate a user by email on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. + /// Impersonate a user by email @override ClientIO setImpersonateUserEmail(value) { config['impersonateUserEmail'] = value; addHeader('X-Appwrite-Impersonate-User-Email', value); return this; } - - /// Impersonate a user by phone on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. + /// Impersonate a user by phone @override ClientIO setImpersonateUserPhone(value) { config['impersonateUserPhone'] = value; @@ -348,13 +340,8 @@ class ClientIO extends ClientBase with ClientMixin { final totalChunks = (size / chunkSize).ceil(); - Future uploadChunk( - int index, - int start, - int end, - String? id, [ - RandomAccessFile? raf, - ]) async { + Future uploadChunk(int index, int start, int end, String? id, + [RandomAccessFile? raf]) async { List chunk = []; if (file.bytes != null) { chunk = file.bytes!.getRange(start, end).toList(); @@ -407,9 +394,7 @@ class ClientIO extends ClientBase with ClientMixin { bool isUploadComplete(Response response) { final chunksUploaded = response.data['chunksUploaded']; final chunksTotal = response.data['chunksTotal'] ?? totalChunks; - return chunksUploaded is num && - chunksTotal is num && - chunksUploaded >= chunksTotal; + return chunksUploaded is num && chunksTotal is num && chunksUploaded >= chunksTotal; } final progress = UploadProgress( @@ -424,13 +409,16 @@ class ClientIO extends ClientBase with ClientMixin { final chunks = >[]; for (var start = firstEnd; start < size; start += chunkSize) { final end = min(start + chunkSize, size); - chunks.add({'index': start ~/ chunkSize, 'start': start, 'end': end}); + chunks.add({ + 'index': start ~/ chunkSize, + 'start': start, + 'end': end, + }); } var nextChunk = 0; Future uploadNext() async { - final raf = - file.bytes == null ? await iofile!.open(mode: FileMode.read) : null; + final raf = file.bytes == null ? await iofile!.open(mode: FileMode.read) : null; try { while (nextChunk < chunks.length) { final chunk = chunks[nextChunk++]; @@ -477,7 +465,9 @@ class ClientIO extends ClientBase with ClientMixin { callbackUrlScheme: callbackUrlScheme != null && _customSchemeAllowed ? callbackUrlScheme : "appwrite-callback-${config['project']!}", - options: const FlutterWebAuth2Options(useWebview: false), + options: const FlutterWebAuth2Options( + useWebview: false, + ), ).then((value) async { Uri url = Uri.parse(value); final key = url.queryParameters['key']; diff --git a/lib/src/client_mixin.dart b/lib/src/client_mixin.dart index 8783f6e8..40484946 100644 --- a/lib/src/client_mixin.dart +++ b/lib/src/client_mixin.dart @@ -12,6 +12,7 @@ mixin ClientMixin { required Map headers, required Map params, }) { + http.BaseRequest request = http.Request(method.name(), uri); if (headers['content-type'] == 'multipart/form-data') { request = http.MultipartRequest(method.name(), uri); @@ -127,14 +128,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 c345e705..6b1e67cd 100644 --- a/lib/src/cookie_manager.dart +++ b/lib/src/cookie_manager.dart @@ -11,7 +11,9 @@ 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) { @@ -41,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/browser_permission.dart b/lib/src/enums/browser_permission.dart index fb4983db..765b3e0c 100644 --- a/lib/src/enums/browser_permission.dart +++ b/lib/src/enums/browser_permission.dart @@ -1,30 +1,32 @@ part of '../../enums.dart'; enum BrowserPermission { - geolocation(value: 'geolocation'), - camera(value: 'camera'), - microphone(value: 'microphone'), - notifications(value: 'notifications'), - midi(value: 'midi'), - push(value: 'push'), - clipboardRead(value: 'clipboard-read'), - clipboardWrite(value: 'clipboard-write'), - paymentHandler(value: 'payment-handler'), - usb(value: 'usb'), - bluetooth(value: 'bluetooth'), - accelerometer(value: 'accelerometer'), - gyroscope(value: 'gyroscope'), - magnetometer(value: 'magnetometer'), - ambientLightSensor(value: 'ambient-light-sensor'), - backgroundSync(value: 'background-sync'), - persistentStorage(value: 'persistent-storage'), - screenWakeLock(value: 'screen-wake-lock'), - webShare(value: 'web-share'), - xrSpatialTracking(value: 'xr-spatial-tracking'); + geolocation(value: 'geolocation'), + camera(value: 'camera'), + microphone(value: 'microphone'), + notifications(value: 'notifications'), + midi(value: 'midi'), + push(value: 'push'), + clipboardRead(value: 'clipboard-read'), + clipboardWrite(value: 'clipboard-write'), + paymentHandler(value: 'payment-handler'), + usb(value: 'usb'), + bluetooth(value: 'bluetooth'), + accelerometer(value: 'accelerometer'), + gyroscope(value: 'gyroscope'), + magnetometer(value: 'magnetometer'), + ambientLightSensor(value: 'ambient-light-sensor'), + backgroundSync(value: 'background-sync'), + persistentStorage(value: 'persistent-storage'), + screenWakeLock(value: 'screen-wake-lock'), + webShare(value: 'web-share'), + xrSpatialTracking(value: 'xr-spatial-tracking'); - const BrowserPermission({required this.value}); + const BrowserPermission({ + 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_theme.dart b/lib/src/enums/browser_theme.dart index 1e059c2c..e81a0f68 100644 --- a/lib/src/enums/browser_theme.dart +++ b/lib/src/enums/browser_theme.dart @@ -1,12 +1,14 @@ part of '../../enums.dart'; enum BrowserTheme { - light(value: 'light'), - dark(value: 'dark'); + light(value: 'light'), + dark(value: 'dark'); - const BrowserTheme({required this.value}); + const BrowserTheme({ + 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/execution_status.dart b/lib/src/enums/execution_status.dart index 7ea9865e..f54859c9 100644 --- a/lib/src/enums/execution_status.dart +++ b/lib/src/enums/execution_status.dart @@ -1,15 +1,17 @@ part of '../../enums.dart'; enum ExecutionStatus { - waiting(value: 'waiting'), - processing(value: 'processing'), - completed(value: 'completed'), - failed(value: 'failed'), - scheduled(value: 'scheduled'); + waiting(value: 'waiting'), + processing(value: 'processing'), + completed(value: 'completed'), + failed(value: 'failed'), + scheduled(value: 'scheduled'); - const ExecutionStatus({required this.value}); + const ExecutionStatus({ + 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_trigger.dart b/lib/src/enums/execution_trigger.dart index fb05eb7d..8a14ae60 100644 --- a/lib/src/enums/execution_trigger.dart +++ b/lib/src/enums/execution_trigger.dart @@ -1,13 +1,15 @@ part of '../../enums.dart'; enum ExecutionTrigger { - http(value: 'http'), - schedule(value: 'schedule'), - event(value: 'event'); + http(value: 'http'), + schedule(value: 'schedule'), + event(value: 'event'); - const ExecutionTrigger({required this.value}); + const ExecutionTrigger({ + 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 b88e0a55..8ed7ecff 100644 --- a/lib/src/enums/o_auth_provider.dart +++ b/lib/src/enums/o_auth_provider.dart @@ -1,53 +1,55 @@ 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'), - fusionauth(value: 'fusionauth'), - github(value: 'github'), - gitlab(value: 'gitlab'), - google(value: 'google'), - keycloak(value: 'keycloak'), - kick(value: 'kick'), - 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'), - x(value: 'x'), - yahoo(value: 'yahoo'), - yammer(value: 'yammer'), - yandex(value: 'yandex'), - zoho(value: 'zoho'), - zoom(value: 'zoom'); + 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'), + fusionauth(value: 'fusionauth'), + github(value: 'github'), + gitlab(value: 'gitlab'), + google(value: 'google'), + keycloak(value: 'keycloak'), + kick(value: 'kick'), + 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'), + x(value: 'x'), + yahoo(value: 'yahoo'), + yammer(value: 'yammer'), + yandex(value: 'yandex'), + zoho(value: 'zoho'), + zoom(value: 'zoom'); - 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/enums/timezone.dart b/lib/src/enums/timezone.dart index d5d8d94a..4a8de1ce 100644 --- a/lib/src/enums/timezone.dart +++ b/lib/src/enums/timezone.dart @@ -1,429 +1,431 @@ part of '../../enums.dart'; enum Timezone { - africaAbidjan(value: 'africa/abidjan'), - africaAccra(value: 'africa/accra'), - africaAddisAbaba(value: 'africa/addis_ababa'), - africaAlgiers(value: 'africa/algiers'), - africaAsmara(value: 'africa/asmara'), - africaBamako(value: 'africa/bamako'), - africaBangui(value: 'africa/bangui'), - africaBanjul(value: 'africa/banjul'), - africaBissau(value: 'africa/bissau'), - africaBlantyre(value: 'africa/blantyre'), - africaBrazzaville(value: 'africa/brazzaville'), - africaBujumbura(value: 'africa/bujumbura'), - africaCairo(value: 'africa/cairo'), - africaCasablanca(value: 'africa/casablanca'), - africaCeuta(value: 'africa/ceuta'), - africaConakry(value: 'africa/conakry'), - africaDakar(value: 'africa/dakar'), - africaDarEsSalaam(value: 'africa/dar_es_salaam'), - africaDjibouti(value: 'africa/djibouti'), - africaDouala(value: 'africa/douala'), - africaElAaiun(value: 'africa/el_aaiun'), - africaFreetown(value: 'africa/freetown'), - africaGaborone(value: 'africa/gaborone'), - africaHarare(value: 'africa/harare'), - africaJohannesburg(value: 'africa/johannesburg'), - africaJuba(value: 'africa/juba'), - africaKampala(value: 'africa/kampala'), - africaKhartoum(value: 'africa/khartoum'), - africaKigali(value: 'africa/kigali'), - africaKinshasa(value: 'africa/kinshasa'), - africaLagos(value: 'africa/lagos'), - africaLibreville(value: 'africa/libreville'), - africaLome(value: 'africa/lome'), - africaLuanda(value: 'africa/luanda'), - africaLubumbashi(value: 'africa/lubumbashi'), - africaLusaka(value: 'africa/lusaka'), - africaMalabo(value: 'africa/malabo'), - africaMaputo(value: 'africa/maputo'), - africaMaseru(value: 'africa/maseru'), - africaMbabane(value: 'africa/mbabane'), - africaMogadishu(value: 'africa/mogadishu'), - africaMonrovia(value: 'africa/monrovia'), - africaNairobi(value: 'africa/nairobi'), - africaNdjamena(value: 'africa/ndjamena'), - africaNiamey(value: 'africa/niamey'), - africaNouakchott(value: 'africa/nouakchott'), - africaOuagadougou(value: 'africa/ouagadougou'), - africaPortoNovo(value: 'africa/porto-novo'), - africaSaoTome(value: 'africa/sao_tome'), - africaTripoli(value: 'africa/tripoli'), - africaTunis(value: 'africa/tunis'), - africaWindhoek(value: 'africa/windhoek'), - americaAdak(value: 'america/adak'), - americaAnchorage(value: 'america/anchorage'), - americaAnguilla(value: 'america/anguilla'), - americaAntigua(value: 'america/antigua'), - americaAraguaina(value: 'america/araguaina'), - americaArgentinaBuenosAires(value: 'america/argentina/buenos_aires'), - americaArgentinaCatamarca(value: 'america/argentina/catamarca'), - americaArgentinaCordoba(value: 'america/argentina/cordoba'), - americaArgentinaJujuy(value: 'america/argentina/jujuy'), - americaArgentinaLaRioja(value: 'america/argentina/la_rioja'), - americaArgentinaMendoza(value: 'america/argentina/mendoza'), - americaArgentinaRioGallegos(value: 'america/argentina/rio_gallegos'), - americaArgentinaSalta(value: 'america/argentina/salta'), - americaArgentinaSanJuan(value: 'america/argentina/san_juan'), - americaArgentinaSanLuis(value: 'america/argentina/san_luis'), - americaArgentinaTucuman(value: 'america/argentina/tucuman'), - americaArgentinaUshuaia(value: 'america/argentina/ushuaia'), - americaAruba(value: 'america/aruba'), - americaAsuncion(value: 'america/asuncion'), - americaAtikokan(value: 'america/atikokan'), - americaBahia(value: 'america/bahia'), - americaBahiaBanderas(value: 'america/bahia_banderas'), - americaBarbados(value: 'america/barbados'), - americaBelem(value: 'america/belem'), - americaBelize(value: 'america/belize'), - americaBlancSablon(value: 'america/blanc-sablon'), - americaBoaVista(value: 'america/boa_vista'), - americaBogota(value: 'america/bogota'), - americaBoise(value: 'america/boise'), - americaCambridgeBay(value: 'america/cambridge_bay'), - americaCampoGrande(value: 'america/campo_grande'), - americaCancun(value: 'america/cancun'), - americaCaracas(value: 'america/caracas'), - americaCayenne(value: 'america/cayenne'), - americaCayman(value: 'america/cayman'), - americaChicago(value: 'america/chicago'), - americaChihuahua(value: 'america/chihuahua'), - americaCiudadJuarez(value: 'america/ciudad_juarez'), - americaCostaRica(value: 'america/costa_rica'), - americaCoyhaique(value: 'america/coyhaique'), - americaCreston(value: 'america/creston'), - americaCuiaba(value: 'america/cuiaba'), - americaCuracao(value: 'america/curacao'), - americaDanmarkshavn(value: 'america/danmarkshavn'), - americaDawson(value: 'america/dawson'), - americaDawsonCreek(value: 'america/dawson_creek'), - americaDenver(value: 'america/denver'), - americaDetroit(value: 'america/detroit'), - americaDominica(value: 'america/dominica'), - americaEdmonton(value: 'america/edmonton'), - americaEirunepe(value: 'america/eirunepe'), - americaElSalvador(value: 'america/el_salvador'), - americaFortNelson(value: 'america/fort_nelson'), - americaFortaleza(value: 'america/fortaleza'), - americaGlaceBay(value: 'america/glace_bay'), - americaGooseBay(value: 'america/goose_bay'), - americaGrandTurk(value: 'america/grand_turk'), - americaGrenada(value: 'america/grenada'), - americaGuadeloupe(value: 'america/guadeloupe'), - americaGuatemala(value: 'america/guatemala'), - americaGuayaquil(value: 'america/guayaquil'), - americaGuyana(value: 'america/guyana'), - americaHalifax(value: 'america/halifax'), - americaHavana(value: 'america/havana'), - americaHermosillo(value: 'america/hermosillo'), - americaIndianaIndianapolis(value: 'america/indiana/indianapolis'), - americaIndianaKnox(value: 'america/indiana/knox'), - americaIndianaMarengo(value: 'america/indiana/marengo'), - americaIndianaPetersburg(value: 'america/indiana/petersburg'), - americaIndianaTellCity(value: 'america/indiana/tell_city'), - americaIndianaVevay(value: 'america/indiana/vevay'), - americaIndianaVincennes(value: 'america/indiana/vincennes'), - americaIndianaWinamac(value: 'america/indiana/winamac'), - americaInuvik(value: 'america/inuvik'), - americaIqaluit(value: 'america/iqaluit'), - americaJamaica(value: 'america/jamaica'), - americaJuneau(value: 'america/juneau'), - americaKentuckyLouisville(value: 'america/kentucky/louisville'), - americaKentuckyMonticello(value: 'america/kentucky/monticello'), - americaKralendijk(value: 'america/kralendijk'), - americaLaPaz(value: 'america/la_paz'), - americaLima(value: 'america/lima'), - americaLosAngeles(value: 'america/los_angeles'), - americaLowerPrinces(value: 'america/lower_princes'), - americaMaceio(value: 'america/maceio'), - americaManagua(value: 'america/managua'), - americaManaus(value: 'america/manaus'), - americaMarigot(value: 'america/marigot'), - americaMartinique(value: 'america/martinique'), - americaMatamoros(value: 'america/matamoros'), - americaMazatlan(value: 'america/mazatlan'), - americaMenominee(value: 'america/menominee'), - americaMerida(value: 'america/merida'), - americaMetlakatla(value: 'america/metlakatla'), - americaMexicoCity(value: 'america/mexico_city'), - americaMiquelon(value: 'america/miquelon'), - americaMoncton(value: 'america/moncton'), - americaMonterrey(value: 'america/monterrey'), - americaMontevideo(value: 'america/montevideo'), - americaMontserrat(value: 'america/montserrat'), - americaNassau(value: 'america/nassau'), - americaNewYork(value: 'america/new_york'), - americaNome(value: 'america/nome'), - americaNoronha(value: 'america/noronha'), - americaNorthDakotaBeulah(value: 'america/north_dakota/beulah'), - americaNorthDakotaCenter(value: 'america/north_dakota/center'), - americaNorthDakotaNewSalem(value: 'america/north_dakota/new_salem'), - americaNuuk(value: 'america/nuuk'), - americaOjinaga(value: 'america/ojinaga'), - americaPanama(value: 'america/panama'), - americaParamaribo(value: 'america/paramaribo'), - americaPhoenix(value: 'america/phoenix'), - americaPortAuPrince(value: 'america/port-au-prince'), - americaPortOfSpain(value: 'america/port_of_spain'), - americaPortoVelho(value: 'america/porto_velho'), - americaPuertoRico(value: 'america/puerto_rico'), - americaPuntaArenas(value: 'america/punta_arenas'), - americaRankinInlet(value: 'america/rankin_inlet'), - americaRecife(value: 'america/recife'), - americaRegina(value: 'america/regina'), - americaResolute(value: 'america/resolute'), - americaRioBranco(value: 'america/rio_branco'), - americaSantarem(value: 'america/santarem'), - americaSantiago(value: 'america/santiago'), - americaSantoDomingo(value: 'america/santo_domingo'), - americaSaoPaulo(value: 'america/sao_paulo'), - americaScoresbysund(value: 'america/scoresbysund'), - americaSitka(value: 'america/sitka'), - americaStBarthelemy(value: 'america/st_barthelemy'), - americaStJohns(value: 'america/st_johns'), - americaStKitts(value: 'america/st_kitts'), - americaStLucia(value: 'america/st_lucia'), - americaStThomas(value: 'america/st_thomas'), - americaStVincent(value: 'america/st_vincent'), - americaSwiftCurrent(value: 'america/swift_current'), - americaTegucigalpa(value: 'america/tegucigalpa'), - americaThule(value: 'america/thule'), - americaTijuana(value: 'america/tijuana'), - americaToronto(value: 'america/toronto'), - americaTortola(value: 'america/tortola'), - americaVancouver(value: 'america/vancouver'), - americaWhitehorse(value: 'america/whitehorse'), - americaWinnipeg(value: 'america/winnipeg'), - americaYakutat(value: 'america/yakutat'), - antarcticaCasey(value: 'antarctica/casey'), - antarcticaDavis(value: 'antarctica/davis'), - antarcticaDumontdurville(value: 'antarctica/dumontdurville'), - antarcticaMacquarie(value: 'antarctica/macquarie'), - antarcticaMawson(value: 'antarctica/mawson'), - antarcticaMcmurdo(value: 'antarctica/mcmurdo'), - antarcticaPalmer(value: 'antarctica/palmer'), - antarcticaRothera(value: 'antarctica/rothera'), - antarcticaSyowa(value: 'antarctica/syowa'), - antarcticaTroll(value: 'antarctica/troll'), - antarcticaVostok(value: 'antarctica/vostok'), - arcticLongyearbyen(value: 'arctic/longyearbyen'), - asiaAden(value: 'asia/aden'), - asiaAlmaty(value: 'asia/almaty'), - asiaAmman(value: 'asia/amman'), - asiaAnadyr(value: 'asia/anadyr'), - asiaAqtau(value: 'asia/aqtau'), - asiaAqtobe(value: 'asia/aqtobe'), - asiaAshgabat(value: 'asia/ashgabat'), - asiaAtyrau(value: 'asia/atyrau'), - asiaBaghdad(value: 'asia/baghdad'), - asiaBahrain(value: 'asia/bahrain'), - asiaBaku(value: 'asia/baku'), - asiaBangkok(value: 'asia/bangkok'), - asiaBarnaul(value: 'asia/barnaul'), - asiaBeirut(value: 'asia/beirut'), - asiaBishkek(value: 'asia/bishkek'), - asiaBrunei(value: 'asia/brunei'), - asiaChita(value: 'asia/chita'), - asiaColombo(value: 'asia/colombo'), - asiaDamascus(value: 'asia/damascus'), - asiaDhaka(value: 'asia/dhaka'), - asiaDili(value: 'asia/dili'), - asiaDubai(value: 'asia/dubai'), - asiaDushanbe(value: 'asia/dushanbe'), - asiaFamagusta(value: 'asia/famagusta'), - asiaGaza(value: 'asia/gaza'), - asiaHebron(value: 'asia/hebron'), - asiaHoChiMinh(value: 'asia/ho_chi_minh'), - asiaHongKong(value: 'asia/hong_kong'), - asiaHovd(value: 'asia/hovd'), - asiaIrkutsk(value: 'asia/irkutsk'), - asiaJakarta(value: 'asia/jakarta'), - asiaJayapura(value: 'asia/jayapura'), - asiaJerusalem(value: 'asia/jerusalem'), - asiaKabul(value: 'asia/kabul'), - asiaKamchatka(value: 'asia/kamchatka'), - asiaKarachi(value: 'asia/karachi'), - asiaKathmandu(value: 'asia/kathmandu'), - asiaKhandyga(value: 'asia/khandyga'), - asiaKolkata(value: 'asia/kolkata'), - asiaKrasnoyarsk(value: 'asia/krasnoyarsk'), - asiaKualaLumpur(value: 'asia/kuala_lumpur'), - asiaKuching(value: 'asia/kuching'), - asiaKuwait(value: 'asia/kuwait'), - asiaMacau(value: 'asia/macau'), - asiaMagadan(value: 'asia/magadan'), - asiaMakassar(value: 'asia/makassar'), - asiaManila(value: 'asia/manila'), - asiaMuscat(value: 'asia/muscat'), - asiaNicosia(value: 'asia/nicosia'), - asiaNovokuznetsk(value: 'asia/novokuznetsk'), - asiaNovosibirsk(value: 'asia/novosibirsk'), - asiaOmsk(value: 'asia/omsk'), - asiaOral(value: 'asia/oral'), - asiaPhnomPenh(value: 'asia/phnom_penh'), - asiaPontianak(value: 'asia/pontianak'), - asiaPyongyang(value: 'asia/pyongyang'), - asiaQatar(value: 'asia/qatar'), - asiaQostanay(value: 'asia/qostanay'), - asiaQyzylorda(value: 'asia/qyzylorda'), - asiaRiyadh(value: 'asia/riyadh'), - asiaSakhalin(value: 'asia/sakhalin'), - asiaSamarkand(value: 'asia/samarkand'), - asiaSeoul(value: 'asia/seoul'), - asiaShanghai(value: 'asia/shanghai'), - asiaSingapore(value: 'asia/singapore'), - asiaSrednekolymsk(value: 'asia/srednekolymsk'), - asiaTaipei(value: 'asia/taipei'), - asiaTashkent(value: 'asia/tashkent'), - asiaTbilisi(value: 'asia/tbilisi'), - asiaTehran(value: 'asia/tehran'), - asiaThimphu(value: 'asia/thimphu'), - asiaTokyo(value: 'asia/tokyo'), - asiaTomsk(value: 'asia/tomsk'), - asiaUlaanbaatar(value: 'asia/ulaanbaatar'), - asiaUrumqi(value: 'asia/urumqi'), - asiaUstNera(value: 'asia/ust-nera'), - asiaVientiane(value: 'asia/vientiane'), - asiaVladivostok(value: 'asia/vladivostok'), - asiaYakutsk(value: 'asia/yakutsk'), - asiaYangon(value: 'asia/yangon'), - asiaYekaterinburg(value: 'asia/yekaterinburg'), - asiaYerevan(value: 'asia/yerevan'), - atlanticAzores(value: 'atlantic/azores'), - atlanticBermuda(value: 'atlantic/bermuda'), - atlanticCanary(value: 'atlantic/canary'), - atlanticCapeVerde(value: 'atlantic/cape_verde'), - atlanticFaroe(value: 'atlantic/faroe'), - atlanticMadeira(value: 'atlantic/madeira'), - atlanticReykjavik(value: 'atlantic/reykjavik'), - atlanticSouthGeorgia(value: 'atlantic/south_georgia'), - atlanticStHelena(value: 'atlantic/st_helena'), - atlanticStanley(value: 'atlantic/stanley'), - australiaAdelaide(value: 'australia/adelaide'), - australiaBrisbane(value: 'australia/brisbane'), - australiaBrokenHill(value: 'australia/broken_hill'), - australiaDarwin(value: 'australia/darwin'), - australiaEucla(value: 'australia/eucla'), - australiaHobart(value: 'australia/hobart'), - australiaLindeman(value: 'australia/lindeman'), - australiaLordHowe(value: 'australia/lord_howe'), - australiaMelbourne(value: 'australia/melbourne'), - australiaPerth(value: 'australia/perth'), - australiaSydney(value: 'australia/sydney'), - europeAmsterdam(value: 'europe/amsterdam'), - europeAndorra(value: 'europe/andorra'), - europeAstrakhan(value: 'europe/astrakhan'), - europeAthens(value: 'europe/athens'), - europeBelgrade(value: 'europe/belgrade'), - europeBerlin(value: 'europe/berlin'), - europeBratislava(value: 'europe/bratislava'), - europeBrussels(value: 'europe/brussels'), - europeBucharest(value: 'europe/bucharest'), - europeBudapest(value: 'europe/budapest'), - europeBusingen(value: 'europe/busingen'), - europeChisinau(value: 'europe/chisinau'), - europeCopenhagen(value: 'europe/copenhagen'), - europeDublin(value: 'europe/dublin'), - europeGibraltar(value: 'europe/gibraltar'), - europeGuernsey(value: 'europe/guernsey'), - europeHelsinki(value: 'europe/helsinki'), - europeIsleOfMan(value: 'europe/isle_of_man'), - europeIstanbul(value: 'europe/istanbul'), - europeJersey(value: 'europe/jersey'), - europeKaliningrad(value: 'europe/kaliningrad'), - europeKirov(value: 'europe/kirov'), - europeKyiv(value: 'europe/kyiv'), - europeLisbon(value: 'europe/lisbon'), - europeLjubljana(value: 'europe/ljubljana'), - europeLondon(value: 'europe/london'), - europeLuxembourg(value: 'europe/luxembourg'), - europeMadrid(value: 'europe/madrid'), - europeMalta(value: 'europe/malta'), - europeMariehamn(value: 'europe/mariehamn'), - europeMinsk(value: 'europe/minsk'), - europeMonaco(value: 'europe/monaco'), - europeMoscow(value: 'europe/moscow'), - europeOslo(value: 'europe/oslo'), - europeParis(value: 'europe/paris'), - europePodgorica(value: 'europe/podgorica'), - europePrague(value: 'europe/prague'), - europeRiga(value: 'europe/riga'), - europeRome(value: 'europe/rome'), - europeSamara(value: 'europe/samara'), - europeSanMarino(value: 'europe/san_marino'), - europeSarajevo(value: 'europe/sarajevo'), - europeSaratov(value: 'europe/saratov'), - europeSimferopol(value: 'europe/simferopol'), - europeSkopje(value: 'europe/skopje'), - europeSofia(value: 'europe/sofia'), - europeStockholm(value: 'europe/stockholm'), - europeTallinn(value: 'europe/tallinn'), - europeTirane(value: 'europe/tirane'), - europeUlyanovsk(value: 'europe/ulyanovsk'), - europeVaduz(value: 'europe/vaduz'), - europeVatican(value: 'europe/vatican'), - europeVienna(value: 'europe/vienna'), - europeVilnius(value: 'europe/vilnius'), - europeVolgograd(value: 'europe/volgograd'), - europeWarsaw(value: 'europe/warsaw'), - europeZagreb(value: 'europe/zagreb'), - europeZurich(value: 'europe/zurich'), - indianAntananarivo(value: 'indian/antananarivo'), - indianChagos(value: 'indian/chagos'), - indianChristmas(value: 'indian/christmas'), - indianCocos(value: 'indian/cocos'), - indianComoro(value: 'indian/comoro'), - indianKerguelen(value: 'indian/kerguelen'), - indianMahe(value: 'indian/mahe'), - indianMaldives(value: 'indian/maldives'), - indianMauritius(value: 'indian/mauritius'), - indianMayotte(value: 'indian/mayotte'), - indianReunion(value: 'indian/reunion'), - pacificApia(value: 'pacific/apia'), - pacificAuckland(value: 'pacific/auckland'), - pacificBougainville(value: 'pacific/bougainville'), - pacificChatham(value: 'pacific/chatham'), - pacificChuuk(value: 'pacific/chuuk'), - pacificEaster(value: 'pacific/easter'), - pacificEfate(value: 'pacific/efate'), - pacificFakaofo(value: 'pacific/fakaofo'), - pacificFiji(value: 'pacific/fiji'), - pacificFunafuti(value: 'pacific/funafuti'), - pacificGalapagos(value: 'pacific/galapagos'), - pacificGambier(value: 'pacific/gambier'), - pacificGuadalcanal(value: 'pacific/guadalcanal'), - pacificGuam(value: 'pacific/guam'), - pacificHonolulu(value: 'pacific/honolulu'), - pacificKanton(value: 'pacific/kanton'), - pacificKiritimati(value: 'pacific/kiritimati'), - pacificKosrae(value: 'pacific/kosrae'), - pacificKwajalein(value: 'pacific/kwajalein'), - pacificMajuro(value: 'pacific/majuro'), - pacificMarquesas(value: 'pacific/marquesas'), - pacificMidway(value: 'pacific/midway'), - pacificNauru(value: 'pacific/nauru'), - pacificNiue(value: 'pacific/niue'), - pacificNorfolk(value: 'pacific/norfolk'), - pacificNoumea(value: 'pacific/noumea'), - pacificPagoPago(value: 'pacific/pago_pago'), - pacificPalau(value: 'pacific/palau'), - pacificPitcairn(value: 'pacific/pitcairn'), - pacificPohnpei(value: 'pacific/pohnpei'), - pacificPortMoresby(value: 'pacific/port_moresby'), - pacificRarotonga(value: 'pacific/rarotonga'), - pacificSaipan(value: 'pacific/saipan'), - pacificTahiti(value: 'pacific/tahiti'), - pacificTarawa(value: 'pacific/tarawa'), - pacificTongatapu(value: 'pacific/tongatapu'), - pacificWake(value: 'pacific/wake'), - pacificWallis(value: 'pacific/wallis'), - utc(value: 'utc'); + africaAbidjan(value: 'africa/abidjan'), + africaAccra(value: 'africa/accra'), + africaAddisAbaba(value: 'africa/addis_ababa'), + africaAlgiers(value: 'africa/algiers'), + africaAsmara(value: 'africa/asmara'), + africaBamako(value: 'africa/bamako'), + africaBangui(value: 'africa/bangui'), + africaBanjul(value: 'africa/banjul'), + africaBissau(value: 'africa/bissau'), + africaBlantyre(value: 'africa/blantyre'), + africaBrazzaville(value: 'africa/brazzaville'), + africaBujumbura(value: 'africa/bujumbura'), + africaCairo(value: 'africa/cairo'), + africaCasablanca(value: 'africa/casablanca'), + africaCeuta(value: 'africa/ceuta'), + africaConakry(value: 'africa/conakry'), + africaDakar(value: 'africa/dakar'), + africaDarEsSalaam(value: 'africa/dar_es_salaam'), + africaDjibouti(value: 'africa/djibouti'), + africaDouala(value: 'africa/douala'), + africaElAaiun(value: 'africa/el_aaiun'), + africaFreetown(value: 'africa/freetown'), + africaGaborone(value: 'africa/gaborone'), + africaHarare(value: 'africa/harare'), + africaJohannesburg(value: 'africa/johannesburg'), + africaJuba(value: 'africa/juba'), + africaKampala(value: 'africa/kampala'), + africaKhartoum(value: 'africa/khartoum'), + africaKigali(value: 'africa/kigali'), + africaKinshasa(value: 'africa/kinshasa'), + africaLagos(value: 'africa/lagos'), + africaLibreville(value: 'africa/libreville'), + africaLome(value: 'africa/lome'), + africaLuanda(value: 'africa/luanda'), + africaLubumbashi(value: 'africa/lubumbashi'), + africaLusaka(value: 'africa/lusaka'), + africaMalabo(value: 'africa/malabo'), + africaMaputo(value: 'africa/maputo'), + africaMaseru(value: 'africa/maseru'), + africaMbabane(value: 'africa/mbabane'), + africaMogadishu(value: 'africa/mogadishu'), + africaMonrovia(value: 'africa/monrovia'), + africaNairobi(value: 'africa/nairobi'), + africaNdjamena(value: 'africa/ndjamena'), + africaNiamey(value: 'africa/niamey'), + africaNouakchott(value: 'africa/nouakchott'), + africaOuagadougou(value: 'africa/ouagadougou'), + africaPortoNovo(value: 'africa/porto-novo'), + africaSaoTome(value: 'africa/sao_tome'), + africaTripoli(value: 'africa/tripoli'), + africaTunis(value: 'africa/tunis'), + africaWindhoek(value: 'africa/windhoek'), + americaAdak(value: 'america/adak'), + americaAnchorage(value: 'america/anchorage'), + americaAnguilla(value: 'america/anguilla'), + americaAntigua(value: 'america/antigua'), + americaAraguaina(value: 'america/araguaina'), + americaArgentinaBuenosAires(value: 'america/argentina/buenos_aires'), + americaArgentinaCatamarca(value: 'america/argentina/catamarca'), + americaArgentinaCordoba(value: 'america/argentina/cordoba'), + americaArgentinaJujuy(value: 'america/argentina/jujuy'), + americaArgentinaLaRioja(value: 'america/argentina/la_rioja'), + americaArgentinaMendoza(value: 'america/argentina/mendoza'), + americaArgentinaRioGallegos(value: 'america/argentina/rio_gallegos'), + americaArgentinaSalta(value: 'america/argentina/salta'), + americaArgentinaSanJuan(value: 'america/argentina/san_juan'), + americaArgentinaSanLuis(value: 'america/argentina/san_luis'), + americaArgentinaTucuman(value: 'america/argentina/tucuman'), + americaArgentinaUshuaia(value: 'america/argentina/ushuaia'), + americaAruba(value: 'america/aruba'), + americaAsuncion(value: 'america/asuncion'), + americaAtikokan(value: 'america/atikokan'), + americaBahia(value: 'america/bahia'), + americaBahiaBanderas(value: 'america/bahia_banderas'), + americaBarbados(value: 'america/barbados'), + americaBelem(value: 'america/belem'), + americaBelize(value: 'america/belize'), + americaBlancSablon(value: 'america/blanc-sablon'), + americaBoaVista(value: 'america/boa_vista'), + americaBogota(value: 'america/bogota'), + americaBoise(value: 'america/boise'), + americaCambridgeBay(value: 'america/cambridge_bay'), + americaCampoGrande(value: 'america/campo_grande'), + americaCancun(value: 'america/cancun'), + americaCaracas(value: 'america/caracas'), + americaCayenne(value: 'america/cayenne'), + americaCayman(value: 'america/cayman'), + americaChicago(value: 'america/chicago'), + americaChihuahua(value: 'america/chihuahua'), + americaCiudadJuarez(value: 'america/ciudad_juarez'), + americaCostaRica(value: 'america/costa_rica'), + americaCoyhaique(value: 'america/coyhaique'), + americaCreston(value: 'america/creston'), + americaCuiaba(value: 'america/cuiaba'), + americaCuracao(value: 'america/curacao'), + americaDanmarkshavn(value: 'america/danmarkshavn'), + americaDawson(value: 'america/dawson'), + americaDawsonCreek(value: 'america/dawson_creek'), + americaDenver(value: 'america/denver'), + americaDetroit(value: 'america/detroit'), + americaDominica(value: 'america/dominica'), + americaEdmonton(value: 'america/edmonton'), + americaEirunepe(value: 'america/eirunepe'), + americaElSalvador(value: 'america/el_salvador'), + americaFortNelson(value: 'america/fort_nelson'), + americaFortaleza(value: 'america/fortaleza'), + americaGlaceBay(value: 'america/glace_bay'), + americaGooseBay(value: 'america/goose_bay'), + americaGrandTurk(value: 'america/grand_turk'), + americaGrenada(value: 'america/grenada'), + americaGuadeloupe(value: 'america/guadeloupe'), + americaGuatemala(value: 'america/guatemala'), + americaGuayaquil(value: 'america/guayaquil'), + americaGuyana(value: 'america/guyana'), + americaHalifax(value: 'america/halifax'), + americaHavana(value: 'america/havana'), + americaHermosillo(value: 'america/hermosillo'), + americaIndianaIndianapolis(value: 'america/indiana/indianapolis'), + americaIndianaKnox(value: 'america/indiana/knox'), + americaIndianaMarengo(value: 'america/indiana/marengo'), + americaIndianaPetersburg(value: 'america/indiana/petersburg'), + americaIndianaTellCity(value: 'america/indiana/tell_city'), + americaIndianaVevay(value: 'america/indiana/vevay'), + americaIndianaVincennes(value: 'america/indiana/vincennes'), + americaIndianaWinamac(value: 'america/indiana/winamac'), + americaInuvik(value: 'america/inuvik'), + americaIqaluit(value: 'america/iqaluit'), + americaJamaica(value: 'america/jamaica'), + americaJuneau(value: 'america/juneau'), + americaKentuckyLouisville(value: 'america/kentucky/louisville'), + americaKentuckyMonticello(value: 'america/kentucky/monticello'), + americaKralendijk(value: 'america/kralendijk'), + americaLaPaz(value: 'america/la_paz'), + americaLima(value: 'america/lima'), + americaLosAngeles(value: 'america/los_angeles'), + americaLowerPrinces(value: 'america/lower_princes'), + americaMaceio(value: 'america/maceio'), + americaManagua(value: 'america/managua'), + americaManaus(value: 'america/manaus'), + americaMarigot(value: 'america/marigot'), + americaMartinique(value: 'america/martinique'), + americaMatamoros(value: 'america/matamoros'), + americaMazatlan(value: 'america/mazatlan'), + americaMenominee(value: 'america/menominee'), + americaMerida(value: 'america/merida'), + americaMetlakatla(value: 'america/metlakatla'), + americaMexicoCity(value: 'america/mexico_city'), + americaMiquelon(value: 'america/miquelon'), + americaMoncton(value: 'america/moncton'), + americaMonterrey(value: 'america/monterrey'), + americaMontevideo(value: 'america/montevideo'), + americaMontserrat(value: 'america/montserrat'), + americaNassau(value: 'america/nassau'), + americaNewYork(value: 'america/new_york'), + americaNome(value: 'america/nome'), + americaNoronha(value: 'america/noronha'), + americaNorthDakotaBeulah(value: 'america/north_dakota/beulah'), + americaNorthDakotaCenter(value: 'america/north_dakota/center'), + americaNorthDakotaNewSalem(value: 'america/north_dakota/new_salem'), + americaNuuk(value: 'america/nuuk'), + americaOjinaga(value: 'america/ojinaga'), + americaPanama(value: 'america/panama'), + americaParamaribo(value: 'america/paramaribo'), + americaPhoenix(value: 'america/phoenix'), + americaPortAuPrince(value: 'america/port-au-prince'), + americaPortOfSpain(value: 'america/port_of_spain'), + americaPortoVelho(value: 'america/porto_velho'), + americaPuertoRico(value: 'america/puerto_rico'), + americaPuntaArenas(value: 'america/punta_arenas'), + americaRankinInlet(value: 'america/rankin_inlet'), + americaRecife(value: 'america/recife'), + americaRegina(value: 'america/regina'), + americaResolute(value: 'america/resolute'), + americaRioBranco(value: 'america/rio_branco'), + americaSantarem(value: 'america/santarem'), + americaSantiago(value: 'america/santiago'), + americaSantoDomingo(value: 'america/santo_domingo'), + americaSaoPaulo(value: 'america/sao_paulo'), + americaScoresbysund(value: 'america/scoresbysund'), + americaSitka(value: 'america/sitka'), + americaStBarthelemy(value: 'america/st_barthelemy'), + americaStJohns(value: 'america/st_johns'), + americaStKitts(value: 'america/st_kitts'), + americaStLucia(value: 'america/st_lucia'), + americaStThomas(value: 'america/st_thomas'), + americaStVincent(value: 'america/st_vincent'), + americaSwiftCurrent(value: 'america/swift_current'), + americaTegucigalpa(value: 'america/tegucigalpa'), + americaThule(value: 'america/thule'), + americaTijuana(value: 'america/tijuana'), + americaToronto(value: 'america/toronto'), + americaTortola(value: 'america/tortola'), + americaVancouver(value: 'america/vancouver'), + americaWhitehorse(value: 'america/whitehorse'), + americaWinnipeg(value: 'america/winnipeg'), + americaYakutat(value: 'america/yakutat'), + antarcticaCasey(value: 'antarctica/casey'), + antarcticaDavis(value: 'antarctica/davis'), + antarcticaDumontdurville(value: 'antarctica/dumontdurville'), + antarcticaMacquarie(value: 'antarctica/macquarie'), + antarcticaMawson(value: 'antarctica/mawson'), + antarcticaMcmurdo(value: 'antarctica/mcmurdo'), + antarcticaPalmer(value: 'antarctica/palmer'), + antarcticaRothera(value: 'antarctica/rothera'), + antarcticaSyowa(value: 'antarctica/syowa'), + antarcticaTroll(value: 'antarctica/troll'), + antarcticaVostok(value: 'antarctica/vostok'), + arcticLongyearbyen(value: 'arctic/longyearbyen'), + asiaAden(value: 'asia/aden'), + asiaAlmaty(value: 'asia/almaty'), + asiaAmman(value: 'asia/amman'), + asiaAnadyr(value: 'asia/anadyr'), + asiaAqtau(value: 'asia/aqtau'), + asiaAqtobe(value: 'asia/aqtobe'), + asiaAshgabat(value: 'asia/ashgabat'), + asiaAtyrau(value: 'asia/atyrau'), + asiaBaghdad(value: 'asia/baghdad'), + asiaBahrain(value: 'asia/bahrain'), + asiaBaku(value: 'asia/baku'), + asiaBangkok(value: 'asia/bangkok'), + asiaBarnaul(value: 'asia/barnaul'), + asiaBeirut(value: 'asia/beirut'), + asiaBishkek(value: 'asia/bishkek'), + asiaBrunei(value: 'asia/brunei'), + asiaChita(value: 'asia/chita'), + asiaColombo(value: 'asia/colombo'), + asiaDamascus(value: 'asia/damascus'), + asiaDhaka(value: 'asia/dhaka'), + asiaDili(value: 'asia/dili'), + asiaDubai(value: 'asia/dubai'), + asiaDushanbe(value: 'asia/dushanbe'), + asiaFamagusta(value: 'asia/famagusta'), + asiaGaza(value: 'asia/gaza'), + asiaHebron(value: 'asia/hebron'), + asiaHoChiMinh(value: 'asia/ho_chi_minh'), + asiaHongKong(value: 'asia/hong_kong'), + asiaHovd(value: 'asia/hovd'), + asiaIrkutsk(value: 'asia/irkutsk'), + asiaJakarta(value: 'asia/jakarta'), + asiaJayapura(value: 'asia/jayapura'), + asiaJerusalem(value: 'asia/jerusalem'), + asiaKabul(value: 'asia/kabul'), + asiaKamchatka(value: 'asia/kamchatka'), + asiaKarachi(value: 'asia/karachi'), + asiaKathmandu(value: 'asia/kathmandu'), + asiaKhandyga(value: 'asia/khandyga'), + asiaKolkata(value: 'asia/kolkata'), + asiaKrasnoyarsk(value: 'asia/krasnoyarsk'), + asiaKualaLumpur(value: 'asia/kuala_lumpur'), + asiaKuching(value: 'asia/kuching'), + asiaKuwait(value: 'asia/kuwait'), + asiaMacau(value: 'asia/macau'), + asiaMagadan(value: 'asia/magadan'), + asiaMakassar(value: 'asia/makassar'), + asiaManila(value: 'asia/manila'), + asiaMuscat(value: 'asia/muscat'), + asiaNicosia(value: 'asia/nicosia'), + asiaNovokuznetsk(value: 'asia/novokuznetsk'), + asiaNovosibirsk(value: 'asia/novosibirsk'), + asiaOmsk(value: 'asia/omsk'), + asiaOral(value: 'asia/oral'), + asiaPhnomPenh(value: 'asia/phnom_penh'), + asiaPontianak(value: 'asia/pontianak'), + asiaPyongyang(value: 'asia/pyongyang'), + asiaQatar(value: 'asia/qatar'), + asiaQostanay(value: 'asia/qostanay'), + asiaQyzylorda(value: 'asia/qyzylorda'), + asiaRiyadh(value: 'asia/riyadh'), + asiaSakhalin(value: 'asia/sakhalin'), + asiaSamarkand(value: 'asia/samarkand'), + asiaSeoul(value: 'asia/seoul'), + asiaShanghai(value: 'asia/shanghai'), + asiaSingapore(value: 'asia/singapore'), + asiaSrednekolymsk(value: 'asia/srednekolymsk'), + asiaTaipei(value: 'asia/taipei'), + asiaTashkent(value: 'asia/tashkent'), + asiaTbilisi(value: 'asia/tbilisi'), + asiaTehran(value: 'asia/tehran'), + asiaThimphu(value: 'asia/thimphu'), + asiaTokyo(value: 'asia/tokyo'), + asiaTomsk(value: 'asia/tomsk'), + asiaUlaanbaatar(value: 'asia/ulaanbaatar'), + asiaUrumqi(value: 'asia/urumqi'), + asiaUstNera(value: 'asia/ust-nera'), + asiaVientiane(value: 'asia/vientiane'), + asiaVladivostok(value: 'asia/vladivostok'), + asiaYakutsk(value: 'asia/yakutsk'), + asiaYangon(value: 'asia/yangon'), + asiaYekaterinburg(value: 'asia/yekaterinburg'), + asiaYerevan(value: 'asia/yerevan'), + atlanticAzores(value: 'atlantic/azores'), + atlanticBermuda(value: 'atlantic/bermuda'), + atlanticCanary(value: 'atlantic/canary'), + atlanticCapeVerde(value: 'atlantic/cape_verde'), + atlanticFaroe(value: 'atlantic/faroe'), + atlanticMadeira(value: 'atlantic/madeira'), + atlanticReykjavik(value: 'atlantic/reykjavik'), + atlanticSouthGeorgia(value: 'atlantic/south_georgia'), + atlanticStHelena(value: 'atlantic/st_helena'), + atlanticStanley(value: 'atlantic/stanley'), + australiaAdelaide(value: 'australia/adelaide'), + australiaBrisbane(value: 'australia/brisbane'), + australiaBrokenHill(value: 'australia/broken_hill'), + australiaDarwin(value: 'australia/darwin'), + australiaEucla(value: 'australia/eucla'), + australiaHobart(value: 'australia/hobart'), + australiaLindeman(value: 'australia/lindeman'), + australiaLordHowe(value: 'australia/lord_howe'), + australiaMelbourne(value: 'australia/melbourne'), + australiaPerth(value: 'australia/perth'), + australiaSydney(value: 'australia/sydney'), + europeAmsterdam(value: 'europe/amsterdam'), + europeAndorra(value: 'europe/andorra'), + europeAstrakhan(value: 'europe/astrakhan'), + europeAthens(value: 'europe/athens'), + europeBelgrade(value: 'europe/belgrade'), + europeBerlin(value: 'europe/berlin'), + europeBratislava(value: 'europe/bratislava'), + europeBrussels(value: 'europe/brussels'), + europeBucharest(value: 'europe/bucharest'), + europeBudapest(value: 'europe/budapest'), + europeBusingen(value: 'europe/busingen'), + europeChisinau(value: 'europe/chisinau'), + europeCopenhagen(value: 'europe/copenhagen'), + europeDublin(value: 'europe/dublin'), + europeGibraltar(value: 'europe/gibraltar'), + europeGuernsey(value: 'europe/guernsey'), + europeHelsinki(value: 'europe/helsinki'), + europeIsleOfMan(value: 'europe/isle_of_man'), + europeIstanbul(value: 'europe/istanbul'), + europeJersey(value: 'europe/jersey'), + europeKaliningrad(value: 'europe/kaliningrad'), + europeKirov(value: 'europe/kirov'), + europeKyiv(value: 'europe/kyiv'), + europeLisbon(value: 'europe/lisbon'), + europeLjubljana(value: 'europe/ljubljana'), + europeLondon(value: 'europe/london'), + europeLuxembourg(value: 'europe/luxembourg'), + europeMadrid(value: 'europe/madrid'), + europeMalta(value: 'europe/malta'), + europeMariehamn(value: 'europe/mariehamn'), + europeMinsk(value: 'europe/minsk'), + europeMonaco(value: 'europe/monaco'), + europeMoscow(value: 'europe/moscow'), + europeOslo(value: 'europe/oslo'), + europeParis(value: 'europe/paris'), + europePodgorica(value: 'europe/podgorica'), + europePrague(value: 'europe/prague'), + europeRiga(value: 'europe/riga'), + europeRome(value: 'europe/rome'), + europeSamara(value: 'europe/samara'), + europeSanMarino(value: 'europe/san_marino'), + europeSarajevo(value: 'europe/sarajevo'), + europeSaratov(value: 'europe/saratov'), + europeSimferopol(value: 'europe/simferopol'), + europeSkopje(value: 'europe/skopje'), + europeSofia(value: 'europe/sofia'), + europeStockholm(value: 'europe/stockholm'), + europeTallinn(value: 'europe/tallinn'), + europeTirane(value: 'europe/tirane'), + europeUlyanovsk(value: 'europe/ulyanovsk'), + europeVaduz(value: 'europe/vaduz'), + europeVatican(value: 'europe/vatican'), + europeVienna(value: 'europe/vienna'), + europeVilnius(value: 'europe/vilnius'), + europeVolgograd(value: 'europe/volgograd'), + europeWarsaw(value: 'europe/warsaw'), + europeZagreb(value: 'europe/zagreb'), + europeZurich(value: 'europe/zurich'), + indianAntananarivo(value: 'indian/antananarivo'), + indianChagos(value: 'indian/chagos'), + indianChristmas(value: 'indian/christmas'), + indianCocos(value: 'indian/cocos'), + indianComoro(value: 'indian/comoro'), + indianKerguelen(value: 'indian/kerguelen'), + indianMahe(value: 'indian/mahe'), + indianMaldives(value: 'indian/maldives'), + indianMauritius(value: 'indian/mauritius'), + indianMayotte(value: 'indian/mayotte'), + indianReunion(value: 'indian/reunion'), + pacificApia(value: 'pacific/apia'), + pacificAuckland(value: 'pacific/auckland'), + pacificBougainville(value: 'pacific/bougainville'), + pacificChatham(value: 'pacific/chatham'), + pacificChuuk(value: 'pacific/chuuk'), + pacificEaster(value: 'pacific/easter'), + pacificEfate(value: 'pacific/efate'), + pacificFakaofo(value: 'pacific/fakaofo'), + pacificFiji(value: 'pacific/fiji'), + pacificFunafuti(value: 'pacific/funafuti'), + pacificGalapagos(value: 'pacific/galapagos'), + pacificGambier(value: 'pacific/gambier'), + pacificGuadalcanal(value: 'pacific/guadalcanal'), + pacificGuam(value: 'pacific/guam'), + pacificHonolulu(value: 'pacific/honolulu'), + pacificKanton(value: 'pacific/kanton'), + pacificKiritimati(value: 'pacific/kiritimati'), + pacificKosrae(value: 'pacific/kosrae'), + pacificKwajalein(value: 'pacific/kwajalein'), + pacificMajuro(value: 'pacific/majuro'), + pacificMarquesas(value: 'pacific/marquesas'), + pacificMidway(value: 'pacific/midway'), + pacificNauru(value: 'pacific/nauru'), + pacificNiue(value: 'pacific/niue'), + pacificNorfolk(value: 'pacific/norfolk'), + pacificNoumea(value: 'pacific/noumea'), + pacificPagoPago(value: 'pacific/pago_pago'), + pacificPalau(value: 'pacific/palau'), + pacificPitcairn(value: 'pacific/pitcairn'), + pacificPohnpei(value: 'pacific/pohnpei'), + pacificPortMoresby(value: 'pacific/port_moresby'), + pacificRarotonga(value: 'pacific/rarotonga'), + pacificSaipan(value: 'pacific/saipan'), + pacificTahiti(value: 'pacific/tahiti'), + pacificTarawa(value: 'pacific/tarawa'), + pacificTongatapu(value: 'pacific/tongatapu'), + pacificWake(value: 'pacific/wake'), + pacificWallis(value: 'pacific/wallis'), + utc(value: 'utc'); - const Timezone({required this.value}); + const Timezone({ + 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 344a8770..f80fa854 100644 --- a/lib/src/models/algo_argon2.dart +++ b/lib/src/models/algo_argon2.dart @@ -2,41 +2,41 @@ 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'], + ); + } - @override - Map toMap() { - return { - "type": type, - "memoryCost": memoryCost, - "timeCost": timeCost, - "threads": threads, - }; - } + @override + 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 a8b682fb..c51da4bb 100644 --- a/lib/src/models/algo_bcrypt.dart +++ b/lib/src/models/algo_bcrypt.dart @@ -2,17 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return {"type": type}; - } + @override + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_md5.dart b/lib/src/models/algo_md5.dart index f5d7bc9a..43523ab1 100644 --- a/lib/src/models/algo_md5.dart +++ b/lib/src/models/algo_md5.dart @@ -2,17 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return {"type": type}; - } + @override + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_phpass.dart b/lib/src/models/algo_phpass.dart index e17a69a8..8562c4e3 100644 --- a/lib/src/models/algo_phpass.dart +++ b/lib/src/models/algo_phpass.dart @@ -2,17 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return {"type": type}; - } + @override + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_scrypt.dart b/lib/src/models/algo_scrypt.dart index a1648843..8e844839 100644 --- a/lib/src/models/algo_scrypt.dart +++ b/lib/src/models/algo_scrypt.dart @@ -2,47 +2,47 @@ 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'], - ); - } - - @override - 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'], + ); + } + + @override + 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 33ef4a6f..5202db05 100644 --- a/lib/src/models/algo_scrypt_modified.dart +++ b/lib/src/models/algo_scrypt_modified.dart @@ -2,41 +2,41 @@ 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(), + ); + } - @override - Map toMap() { - return { - "type": type, - "salt": salt, - "saltSeparator": saltSeparator, - "signerKey": signerKey, - }; - } + @override + 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 1ab20633..3d08af9f 100644 --- a/lib/src/models/algo_sha.dart +++ b/lib/src/models/algo_sha.dart @@ -2,17 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return {"type": type}; - } + @override + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/continent.dart b/lib/src/models/continent.dart index 9f832f6c..930900bf 100644 --- a/lib/src/models/continent.dart +++ b/lib/src/models/continent.dart @@ -2,23 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return {"name": name, "code": code}; - } + @override + Map toMap() { + return { + "name": name, + "code": code, + }; + } } diff --git a/lib/src/models/continent_list.dart b/lib/src/models/continent_list.dart index fa2f5f7b..753bcacc 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "continents": continents.map((p) => p.toMap()).toList(), - }; - } + @override + 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 0ce90cf6..c4838ba3 100644 --- a/lib/src/models/country.dart +++ b/lib/src/models/country.dart @@ -2,20 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return {"name": name, "code": code}; - } + @override + Map toMap() { + return { + "name": name, + "code": code, + }; + } } diff --git a/lib/src/models/country_list.dart b/lib/src/models/country_list.dart index 32df44f7..f363a54b 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "countries": countries.map((p) => p.toMap()).toList(), - }; - } + @override + 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 f2b18093..b6bb455f 100644 --- a/lib/src/models/currency.dart +++ b/lib/src/models/currency.dart @@ -2,59 +2,59 @@ 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(), - ); - } - - @override - 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(), + ); + } + + @override + 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 6c4a94da..eb2bad19 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "currencies": currencies.map((p) => p.toMap()).toList(), - }; - } + @override + 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 be08d599..0d1fdeb0 100644 --- a/lib/src/models/document.dart +++ b/lib/src/models/document.dart @@ -2,66 +2,66 @@ part of '../../models.dart'; /// Document class Document implements Model { - /// Document ID. - final String $id; + /// Document ID. + final String $id; - /// Document sequence ID. - final String $sequence; + /// Document sequence ID. + final String $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'].toString(), - $collectionId: map['\$collectionId'].toString(), - $databaseId: map['\$databaseId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - data: map["data"] ?? map, - ); - } + factory Document.fromMap(Map map) { + return Document( + $id: map['\$id'].toString(), + $sequence: map['\$sequence'].toString(), + $collectionId: map['\$collectionId'].toString(), + $databaseId: map['\$databaseId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + data: map["data"] ?? map, + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$sequence": $sequence, - "\$collectionId": $collectionId, - "\$databaseId": $databaseId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "data": data, - }; - } + @override + 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 ca84e1b6..0e30844a 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "documents": documents.map((p) => p.toMap()).toList(), - }; - } + @override + 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 92c27230..3e767ca3 100644 --- a/lib/src/models/execution.dart +++ b/lib/src/models/execution.dart @@ -2,133 +2,125 @@ 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 enums.ExecutionTrigger trigger; - - /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, `failed`, or `scheduled`. - final enums.ExecutionStatus status; - - /// HTTP request method type. - final String requestMethod; - - /// HTTP request path and query. - final String requestPath; - - /// HTTP request 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: enums.ExecutionTrigger.values.firstWhere( - (e) => e.value == map['trigger'], - ), - status: enums.ExecutionStatus.values.firstWhere( - (e) => e.value == map['status'], - ), - 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(), - ); - } - - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "functionId": functionId, - "deploymentId": deploymentId, - "trigger": trigger.value, - "status": status.value, - "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 enums.ExecutionTrigger trigger; + + /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, `failed`, or `scheduled`. + final enums.ExecutionStatus status; + + /// HTTP request method type. + final String requestMethod; + + /// HTTP request path and query. + final String requestPath; + + /// HTTP request 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: enums.ExecutionTrigger.values.firstWhere((e) => e.value == map['trigger']), + status: enums.ExecutionStatus.values.firstWhere((e) => e.value == map['status']), + 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(), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "functionId": functionId, + "deploymentId": deploymentId, + "trigger": trigger.value, + "status": status.value, + "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 7737afaa..45b60682 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "executions": executions.map((p) => p.toMap()).toList(), - }; - } + @override + 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 01cdcb3a..9e5f9eb1 100644 --- a/lib/src/models/file.dart +++ b/lib/src/models/file.dart @@ -2,101 +2,101 @@ part of '../../models.dart'; /// File class File implements Model { - /// File ID. - final String $id; - - /// Bucket ID. - final String bucketId; - - /// File creation date in ISO 8601 format. - final String $createdAt; - - /// 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 name. - final String name; - - /// File MD5 signature. - final String signature; - - /// File mime type. - final String mimeType; - - /// File original size in bytes. - final int sizeOriginal; - - /// File actual stored size in bytes after compression and/or encryption. - final int sizeActual; - - /// Total number of chunks available - final int chunksTotal; - - /// Total number of chunks uploaded - final int chunksUploaded; - - /// Whether file contents are encrypted at rest. - final bool encryption; - - /// Compression algorithm used for the file. Will be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd). - final String compression; - - 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.sizeActual, - required this.chunksTotal, - required this.chunksUploaded, - required this.encryption, - required this.compression, - }); - - 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'], - sizeActual: map['sizeActual'], - chunksTotal: map['chunksTotal'], - chunksUploaded: map['chunksUploaded'], - encryption: map['encryption'], - compression: map['compression'].toString(), - ); - } - - @override - Map toMap() { - return { - "\$id": $id, - "bucketId": bucketId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "name": name, - "signature": signature, - "mimeType": mimeType, - "sizeOriginal": sizeOriginal, - "sizeActual": sizeActual, - "chunksTotal": chunksTotal, - "chunksUploaded": chunksUploaded, - "encryption": encryption, - "compression": compression, - }; - } + /// File ID. + final String $id; + + /// Bucket ID. + final String bucketId; + + /// File creation date in ISO 8601 format. + final String $createdAt; + + /// 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 name. + final String name; + + /// File MD5 signature. + final String signature; + + /// File mime type. + final String mimeType; + + /// File original size in bytes. + final int sizeOriginal; + + /// File actual stored size in bytes after compression and/or encryption. + final int sizeActual; + + /// Total number of chunks available + final int chunksTotal; + + /// Total number of chunks uploaded + final int chunksUploaded; + + /// Whether file contents are encrypted at rest. + final bool encryption; + + /// Compression algorithm used for the file. Will be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd). + final String compression; + + 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.sizeActual, + required this.chunksTotal, + required this.chunksUploaded, + required this.encryption, + required this.compression, + }); + + 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'], + sizeActual: map['sizeActual'], + chunksTotal: map['chunksTotal'], + chunksUploaded: map['chunksUploaded'], + encryption: map['encryption'], + compression: map['compression'].toString(), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "bucketId": bucketId, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "name": name, + "signature": signature, + "mimeType": mimeType, + "sizeOriginal": sizeOriginal, + "sizeActual": sizeActual, + "chunksTotal": chunksTotal, + "chunksUploaded": chunksUploaded, + "encryption": encryption, + "compression": compression, + }; + } } diff --git a/lib/src/models/file_list.dart b/lib/src/models/file_list.dart index 500e09fe..84c54b2e 100644 --- a/lib/src/models/file_list.dart +++ b/lib/src/models/file_list.dart @@ -2,23 +2,29 @@ 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))), + ); + } - @override - Map toMap() { - return {"total": total, "files": files.map((p) => p.toMap()).toList()}; - } + @override + 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 df11e0fb..bbccf88a 100644 --- a/lib/src/models/headers.dart +++ b/lib/src/models/headers.dart @@ -2,23 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return {"name": name, "value": value}; - } + @override + Map toMap() { + return { + "name": name, + "value": value, + }; + } } diff --git a/lib/src/models/identity.dart b/lib/src/models/identity.dart index cc659043..7e90020c 100644 --- a/lib/src/models/identity.dart +++ b/lib/src/models/identity.dart @@ -2,77 +2,77 @@ 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(), + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "userId": userId, - "provider": provider, - "providerUid": providerUid, - "providerEmail": providerEmail, - "providerAccessToken": providerAccessToken, - "providerAccessTokenExpiry": providerAccessTokenExpiry, - "providerRefreshToken": providerRefreshToken, - }; - } + @override + 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 f8eda904..d9cc09a2 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "identities": identities.map((p) => p.toMap()).toList(), - }; - } + @override + 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 1de0ca29..2000acb6 100644 --- a/lib/src/models/jwt.dart +++ b/lib/src/models/jwt.dart @@ -2,17 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return {"jwt": jwt}; - } + @override + Map toMap() { + return { + "jwt": jwt, + }; + } } diff --git a/lib/src/models/language.dart b/lib/src/models/language.dart index d2807477..1422d065 100644 --- a/lib/src/models/language.dart +++ b/lib/src/models/language.dart @@ -2,27 +2,35 @@ 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(), + ); + } - @override - Map toMap() { - return {"name": name, "code": code, "nativeName": nativeName}; - } + @override + 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 de936431..5d78a367 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "languages": languages.map((p) => p.toMap()).toList(), - }; - } + @override + 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 54dd0c29..3292a896 100644 --- a/lib/src/models/locale.dart +++ b/lib/src/models/locale.dart @@ -2,59 +2,59 @@ 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(), - ); - } - - @override - 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(), + ); + } + + @override + 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 3255ef92..49ef3b0b 100644 --- a/lib/src/models/locale_code.dart +++ b/lib/src/models/locale_code.dart @@ -2,23 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return {"code": code, "name": name}; - } + @override + 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 af24267e..a3a26b61 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "localeCodes": localeCodes.map((p) => p.toMap()).toList(), - }; - } + @override + 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 572cce50..406fcbcf 100644 --- a/lib/src/models/log.dart +++ b/lib/src/models/log.dart @@ -2,149 +2,149 @@ part of '../../models.dart'; /// Log class Log implements Model { - /// Event name. - final String event; - - /// User ID of the actor recorded for this log. During impersonation, this is the original impersonator, not the impersonated target user. - final String userId; - - /// User email of the actor recorded for this log. During impersonation, this is the original impersonator. - final String userEmail; - - /// User name of the actor recorded for this log. During impersonation, this is the original impersonator. - final String userName; - - /// API mode when event triggered. - final String mode; - - /// User type who triggered the audit log. Possible values: user, admin, guest, keyProject, keyAccount, keyOrganization. - final String userType; - - /// 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.userType, - 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(), - userType: map['userType'].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(), - ); - } - - @override - Map toMap() { - return { - "event": event, - "userId": userId, - "userEmail": userEmail, - "userName": userName, - "mode": mode, - "userType": userType, - "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 of the actor recorded for this log. During impersonation, this is the original impersonator, not the impersonated target user. + final String userId; + + /// User email of the actor recorded for this log. During impersonation, this is the original impersonator. + final String userEmail; + + /// User name of the actor recorded for this log. During impersonation, this is the original impersonator. + final String userName; + + /// API mode when event triggered. + final String mode; + + /// User type who triggered the audit log. Possible values: user, admin, guest, keyProject, keyAccount, keyOrganization. + final String userType; + + /// 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.userType, + 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(), + userType: map['userType'].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(), + ); + } + + @override + Map toMap() { + return { + "event": event, + "userId": userId, + "userEmail": userEmail, + "userName": userName, + "mode": mode, + "userType": userType, + "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 50695e4a..ebf593c2 100644 --- a/lib/src/models/log_list.dart +++ b/lib/src/models/log_list.dart @@ -2,23 +2,29 @@ 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))), + ); + } - @override - Map toMap() { - return {"total": total, "logs": logs.map((p) => p.toMap()).toList()}; - } + @override + 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 4d8a2f9b..4baffb71 100644 --- a/lib/src/models/membership.dart +++ b/lib/src/models/membership.dart @@ -2,107 +2,107 @@ 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; - - /// User phone number. Hide this attribute by toggling membership privacy in the Console. - final String userPhone; - - /// 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; - - /// Most recent access date in ISO 8601 format. Show this attribute by toggling membership privacy in the Console. - final String userAccessedAt; - - /// 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.userPhone, - required this.teamId, - required this.teamName, - required this.invited, - required this.joined, - required this.confirm, - required this.mfa, - required this.userAccessedAt, - 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(), - userPhone: map['userPhone'].toString(), - teamId: map['teamId'].toString(), - teamName: map['teamName'].toString(), - invited: map['invited'].toString(), - joined: map['joined'].toString(), - confirm: map['confirm'], - mfa: map['mfa'], - userAccessedAt: map['userAccessedAt'].toString(), - roles: List.from(map['roles'] ?? []), - ); - } - - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "userId": userId, - "userName": userName, - "userEmail": userEmail, - "userPhone": userPhone, - "teamId": teamId, - "teamName": teamName, - "invited": invited, - "joined": joined, - "confirm": confirm, - "mfa": mfa, - "userAccessedAt": userAccessedAt, - "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; + + /// User phone number. Hide this attribute by toggling membership privacy in the Console. + final String userPhone; + + /// 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; + + /// Most recent access date in ISO 8601 format. Show this attribute by toggling membership privacy in the Console. + final String userAccessedAt; + + /// 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.userPhone, + required this.teamId, + required this.teamName, + required this.invited, + required this.joined, + required this.confirm, + required this.mfa, + required this.userAccessedAt, + 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(), + userPhone: map['userPhone'].toString(), + teamId: map['teamId'].toString(), + teamName: map['teamName'].toString(), + invited: map['invited'].toString(), + joined: map['joined'].toString(), + confirm: map['confirm'], + mfa: map['mfa'], + userAccessedAt: map['userAccessedAt'].toString(), + roles: List.from(map['roles'] ?? []), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "userId": userId, + "userName": userName, + "userEmail": userEmail, + "userPhone": userPhone, + "teamId": teamId, + "teamName": teamName, + "invited": invited, + "joined": joined, + "confirm": confirm, + "mfa": mfa, + "userAccessedAt": userAccessedAt, + "roles": roles, + }; + } } diff --git a/lib/src/models/membership_list.dart b/lib/src/models/membership_list.dart index cc11b182..a0641a28 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "memberships": memberships.map((p) => p.toMap()).toList(), - }; - } + @override + 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 fa385541..3d2e2335 100644 --- a/lib/src/models/mfa_challenge.dart +++ b/lib/src/models/mfa_challenge.dart @@ -2,41 +2,41 @@ 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(), + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "userId": userId, - "expire": expire, - }; - } + @override + 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 2777de7f..a7e5fefc 100644 --- a/lib/src/models/mfa_factors.dart +++ b/lib/src/models/mfa_factors.dart @@ -2,41 +2,41 @@ 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'], + ); + } - @override - Map toMap() { - return { - "totp": totp, - "phone": phone, - "email": email, - "recoveryCode": recoveryCode, - }; - } + @override + 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 fb3af632..33036476 100644 --- a/lib/src/models/mfa_recovery_codes.dart +++ b/lib/src/models/mfa_recovery_codes.dart @@ -2,19 +2,23 @@ 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'] ?? []), + ); + } - @override - Map toMap() { - return {"recoveryCodes": recoveryCodes}; - } + @override + Map toMap() { + return { + "recoveryCodes": recoveryCodes, + }; + } } diff --git a/lib/src/models/mfa_type.dart b/lib/src/models/mfa_type.dart index 4debb42e..05cab363 100644 --- a/lib/src/models/mfa_type.dart +++ b/lib/src/models/mfa_type.dart @@ -2,23 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return {"secret": secret, "uri": uri}; - } + @override + 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 60e2abd9..7ac578e2 100644 --- a/lib/src/models/phone.dart +++ b/lib/src/models/phone.dart @@ -2,35 +2,35 @@ 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(), + ); + } - @override - Map toMap() { - return { - "code": code, - "countryCode": countryCode, - "countryName": countryName, - }; - } + @override + 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 e4376c98..9791d590 100644 --- a/lib/src/models/phone_list.dart +++ b/lib/src/models/phone_list.dart @@ -2,23 +2,29 @@ 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))), + ); + } - @override - Map toMap() { - return {"total": total, "phones": phones.map((p) => p.toMap()).toList()}; - } + @override + 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 d10c62fc..b107afe5 100644 --- a/lib/src/models/preferences.dart +++ b/lib/src/models/preferences.dart @@ -2,18 +2,24 @@ 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["data"] ?? map); - } + factory Preferences.fromMap(Map map) { + return Preferences( + data: map["data"] ?? map, + ); + } - @override - Map toMap() { - return {"data": data}; - } + @override + 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/presence.dart b/lib/src/models/presence.dart index d31911de..133fe66d 100644 --- a/lib/src/models/presence.dart +++ b/lib/src/models/presence.dart @@ -2,71 +2,71 @@ part of '../../models.dart'; /// Presence class Presence implements Model { - /// Presence ID. - final String $id; + /// Presence ID. + final String $id; - /// Presence creation date in ISO 8601 format. - final String $createdAt; + /// Presence creation date in ISO 8601 format. + final String $createdAt; - /// Presence update date in ISO 8601 format. - final String $updatedAt; + /// Presence update date in ISO 8601 format. + final String $updatedAt; - /// Presence permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; + /// Presence permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Presence status. - final String? status; + /// Presence status. + final String? status; - /// Presence source. - final String source; + /// Presence source. + final String source; - /// Presence expiry date in ISO 8601 format. - final String? expiresAt; + /// Presence expiry date in ISO 8601 format. + final String? expiresAt; - /// Presence metadata. - final Map? metadata; + /// Presence metadata. + final Map? metadata; - Presence({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.userId, - this.status, - required this.source, - this.expiresAt, - this.metadata, - }); + Presence({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.userId, + this.status, + required this.source, + this.expiresAt, + this.metadata, + }); - factory Presence.fromMap(Map map) { - return Presence( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - userId: map['userId'].toString(), - status: map['status']?.toString(), - source: map['source'].toString(), - expiresAt: map['expiresAt']?.toString(), - metadata: map['metadata'], - ); - } + factory Presence.fromMap(Map map) { + return Presence( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + userId: map['userId'].toString(), + status: map['status']?.toString(), + source: map['source'].toString(), + expiresAt: map['expiresAt']?.toString(), + metadata: map['metadata'], + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "userId": userId, - "status": status, - "source": source, - "expiresAt": expiresAt, - "metadata": metadata, - }; - } + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "userId": userId, + "status": status, + "source": source, + "expiresAt": expiresAt, + "metadata": metadata, + }; + } } diff --git a/lib/src/models/presence_list.dart b/lib/src/models/presence_list.dart index ec5f575b..aebbe880 100644 --- a/lib/src/models/presence_list.dart +++ b/lib/src/models/presence_list.dart @@ -2,28 +2,29 @@ part of '../../models.dart'; /// Presences List class PresenceList implements Model { - /// Total number of presences that matched your query. - final int total; + /// Total number of presences that matched your query. + final int total; - /// List of presences. - final List presences; + /// List of presences. + final List presences; - PresenceList({required this.total, required this.presences}); + PresenceList({ + required this.total, + required this.presences, + }); - factory PresenceList.fromMap(Map map) { - return PresenceList( - total: map['total'], - presences: List.from( - map['presences'].map((p) => Presence.fromMap(p)), - ), - ); - } + factory PresenceList.fromMap(Map map) { + return PresenceList( + total: map['total'], + presences: List.from(map['presences'].map((p) => Presence.fromMap(p))), + ); + } - @override - Map toMap() { - return { - "total": total, - "presences": presences.map((p) => p.toMap()).toList(), - }; - } + @override + Map toMap() { + return { + "total": total, + "presences": presences.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/row.dart b/lib/src/models/row.dart index a825eab0..c5f233b4 100644 --- a/lib/src/models/row.dart +++ b/lib/src/models/row.dart @@ -2,66 +2,66 @@ part of '../../models.dart'; /// Row class Row implements Model { - /// Row ID. - final String $id; + /// Row ID. + final String $id; - /// Row sequence ID. - final String $sequence; + /// Row sequence ID. + final String $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'].toString(), - $tableId: map['\$tableId'].toString(), - $databaseId: map['\$databaseId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - data: map["data"] ?? map, - ); - } + factory Row.fromMap(Map map) { + return Row( + $id: map['\$id'].toString(), + $sequence: map['\$sequence'].toString(), + $tableId: map['\$tableId'].toString(), + $databaseId: map['\$databaseId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + data: map["data"] ?? map, + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$sequence": $sequence, - "\$tableId": $tableId, - "\$databaseId": $databaseId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "data": data, - }; - } + @override + 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 0ec8cfce..90efa95f 100644 --- a/lib/src/models/row_list.dart +++ b/lib/src/models/row_list.dart @@ -2,26 +2,32 @@ 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))), + ); + } - @override - Map toMap() { - return {"total": total, "rows": rows.map((p) => p.toMap()).toList()}; - } + @override + 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 92e4034e..c37de95a 100644 --- a/lib/src/models/session.dart +++ b/lib/src/models/session.dart @@ -2,191 +2,191 @@ 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(), - ); - } - - @override - 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(), + ); + } + + @override + 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 1a10a711..d823d0e6 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "sessions": sessions.map((p) => p.toMap()).toList(), - }; - } + @override + 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 450aafd1..850ab8d2 100644 --- a/lib/src/models/subscriber.dart +++ b/lib/src/models/subscriber.dart @@ -2,71 +2,71 @@ 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(), + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "targetId": targetId, - "target": target.toMap(), - "userId": userId, - "userName": userName, - "topicId": topicId, - "providerType": providerType, - }; - } + @override + 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 c2e8c4dc..742e7590 100644 --- a/lib/src/models/target.dart +++ b/lib/src/models/target.dart @@ -2,71 +2,71 @@ 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'], + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "userId": userId, - "providerId": providerId, - "providerType": providerType, - "identifier": identifier, - "expired": expired, - }; - } + @override + 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 91b888b9..21e65e95 100644 --- a/lib/src/models/team.dart +++ b/lib/src/models/team.dart @@ -2,53 +2,53 @@ 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']), - ); - } - - @override - 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']), + ); + } + + @override + 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 cdd54fba..ffca5e98 100644 --- a/lib/src/models/team_list.dart +++ b/lib/src/models/team_list.dart @@ -2,23 +2,29 @@ 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))), + ); + } - @override - Map toMap() { - return {"total": total, "teams": teams.map((p) => p.toMap()).toList()}; - } + @override + 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 b5ea87c8..b05320da 100644 --- a/lib/src/models/token.dart +++ b/lib/src/models/token.dart @@ -2,53 +2,53 @@ 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(), - ); - } - - @override - 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(), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "userId": userId, + "secret": secret, + "expire": expire, + "phrase": phrase, + }; + } } diff --git a/lib/src/models/transaction.dart b/lib/src/models/transaction.dart index b0606dd8..e3f3e43d 100644 --- a/lib/src/models/transaction.dart +++ b/lib/src/models/transaction.dart @@ -2,53 +2,53 @@ part of '../../models.dart'; /// Transaction class Transaction implements Model { - /// Transaction ID. - final String $id; - - /// Transaction creation time in ISO 8601 format. - final String $createdAt; - - /// Transaction update date in ISO 8601 format. - final String $updatedAt; - - /// Current status of the transaction. One of: pending, committing, committed, rolled_back, failed. - final String status; - - /// Number of operations in the transaction. - final int operations; - - /// Expiration time in ISO 8601 format. - final String expiresAt; - - Transaction({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.status, - required this.operations, - required this.expiresAt, - }); - - factory Transaction.fromMap(Map map) { - return Transaction( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - status: map['status'].toString(), - operations: map['operations'], - expiresAt: map['expiresAt'].toString(), - ); - } - - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "status": status, - "operations": operations, - "expiresAt": expiresAt, - }; - } + /// Transaction ID. + final String $id; + + /// Transaction creation time in ISO 8601 format. + final String $createdAt; + + /// Transaction update date in ISO 8601 format. + final String $updatedAt; + + /// Current status of the transaction. One of: pending, committing, committed, rolled_back, failed. + final String status; + + /// Number of operations in the transaction. + final int operations; + + /// Expiration time in ISO 8601 format. + final String expiresAt; + + Transaction({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.status, + required this.operations, + required this.expiresAt, + }); + + factory Transaction.fromMap(Map map) { + return Transaction( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + status: map['status'].toString(), + operations: map['operations'], + expiresAt: map['expiresAt'].toString(), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "status": status, + "operations": operations, + "expiresAt": expiresAt, + }; + } } diff --git a/lib/src/models/transaction_list.dart b/lib/src/models/transaction_list.dart index bb39e8c8..19ea651d 100644 --- a/lib/src/models/transaction_list.dart +++ b/lib/src/models/transaction_list.dart @@ -2,28 +2,29 @@ part of '../../models.dart'; /// Transaction List class TransactionList implements Model { - /// Total number of transactions that matched your query. - final int total; + /// Total number of transactions that matched your query. + final int total; - /// List of transactions. - final List transactions; + /// List of transactions. + final List transactions; - TransactionList({required this.total, required this.transactions}); + TransactionList({ + required this.total, + required this.transactions, + }); - factory TransactionList.fromMap(Map map) { - return TransactionList( - total: map['total'], - transactions: List.from( - map['transactions'].map((p) => Transaction.fromMap(p)), - ), - ); - } + factory TransactionList.fromMap(Map map) { + return TransactionList( + total: map['total'], + transactions: List.from(map['transactions'].map((p) => Transaction.fromMap(p))), + ); + } - @override - Map toMap() { - return { - "total": total, - "transactions": transactions.map((p) => p.toMap()).toList(), - }; - } + @override + Map toMap() { + return { + "total": total, + "transactions": transactions.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/user.dart b/lib/src/models/user.dart index 5a6cad30..e3b9536b 100644 --- a/lib/src/models/user.dart +++ b/lib/src/models/user.dart @@ -2,173 +2,173 @@ part of '../../models.dart'; /// User class User implements Model { - /// User ID. - final String $id; + /// User ID. + final String $id; - /// User creation date in ISO 8601 format. - final String $createdAt; + /// User creation date in ISO 8601 format. + final String $createdAt; - /// User update date in ISO 8601 format. - final String $updatedAt; + /// 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; - - /// Canonical form of the user email address. - final String? emailCanonical; - - /// Whether the user email is from a free email provider. - final bool? emailIsFree; - - /// Whether the user email is from a disposable email provider. - final bool? emailIsDisposable; - - /// Whether the user email is from a corporate domain. - final bool? emailIsCorporate; - - /// Whether the user email is in its canonical form. - final bool? emailIsCanonical; - - /// 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; - - /// Whether the user can impersonate other users. - final bool? impersonator; - - /// ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data. - final String? impersonatorUserId; - - 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, - this.emailCanonical, - this.emailIsFree, - this.emailIsDisposable, - this.emailIsCorporate, - this.emailIsCanonical, - required this.phoneVerification, - required this.mfa, - required this.prefs, - required this.targets, - required this.accessedAt, - this.impersonator, - this.impersonatorUserId, - }); - - 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'], - emailCanonical: map['emailCanonical']?.toString(), - emailIsFree: map['emailIsFree'], - emailIsDisposable: map['emailIsDisposable'], - emailIsCorporate: map['emailIsCorporate'], - emailIsCanonical: map['emailIsCanonical'], - 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(), - impersonator: map['impersonator'], - impersonatorUserId: map['impersonatorUserId']?.toString(), - ); - } - - @override - 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, - "emailCanonical": emailCanonical, - "emailIsFree": emailIsFree, - "emailIsDisposable": emailIsDisposable, - "emailIsCorporate": emailIsCorporate, - "emailIsCanonical": emailIsCanonical, - "phoneVerification": phoneVerification, - "mfa": mfa, - "prefs": prefs.toMap(), - "targets": targets.map((p) => p.toMap()).toList(), - "accessedAt": accessedAt, - "impersonator": impersonator, - "impersonatorUserId": impersonatorUserId, - }; - } + /// 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; + + /// Canonical form of the user email address. + final String? emailCanonical; + + /// Whether the user email is from a free email provider. + final bool? emailIsFree; + + /// Whether the user email is from a disposable email provider. + final bool? emailIsDisposable; + + /// Whether the user email is from a corporate domain. + final bool? emailIsCorporate; + + /// Whether the user email is in its canonical form. + final bool? emailIsCanonical; + + /// 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; + + /// Whether the user can impersonate other users. + final bool? impersonator; + + /// ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data. + final String? impersonatorUserId; + + 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, + this.emailCanonical, + this.emailIsFree, + this.emailIsDisposable, + this.emailIsCorporate, + this.emailIsCanonical, + required this.phoneVerification, + required this.mfa, + required this.prefs, + required this.targets, + required this.accessedAt, + this.impersonator, + this.impersonatorUserId, + }); + + 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'], + emailCanonical: map['emailCanonical']?.toString(), + emailIsFree: map['emailIsFree'], + emailIsDisposable: map['emailIsDisposable'], + emailIsCorporate: map['emailIsCorporate'], + emailIsCanonical: map['emailIsCanonical'], + 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(), + impersonator: map['impersonator'], + impersonatorUserId: map['impersonatorUserId']?.toString(), + ); + } + + @override + 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, + "emailCanonical": emailCanonical, + "emailIsFree": emailIsFree, + "emailIsDisposable": emailIsDisposable, + "emailIsCorporate": emailIsCorporate, + "emailIsCanonical": emailIsCanonical, + "phoneVerification": phoneVerification, + "mfa": mfa, + "prefs": prefs.toMap(), + "targets": targets.map((p) => p.toMap()).toList(), + "accessedAt": accessedAt, + "impersonator": impersonator, + "impersonatorUserId": impersonatorUserId, + }; + } } diff --git a/lib/src/realtime.dart b/lib/src/realtime.dart index 28e4c43d..7a5e6303 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(); /// ``` - /// + /// /// You can also use Channel builders: /// ```dart /// final subscription = realtime.subscribe([ diff --git a/lib/src/realtime_browser.dart b/lib/src/realtime_browser.dart index 3563e7d9..a0f4193a 100644 --- a/lib/src/realtime_browser.dart +++ b/lib/src/realtime_browser.dart @@ -22,6 +22,15 @@ class RealtimeBrowser extends RealtimeBase with RealtimeMixin { Future _getWebSocket(Uri uri) async { await (client as ClientBrowser).init(); + + final jwt = client.config['jwt']; + if (jwt != null && jwt.isNotEmpty) { + uri = uri.replace(queryParameters: { + ...uri.queryParameters, + 'jwt': jwt, + }); + } + return HtmlWebSocketChannel.connect(uri); } diff --git a/lib/src/realtime_io.dart b/lib/src/realtime_io.dart index edff9665..83f01b4c 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,14 @@ 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 jwt = client.config['jwt']; + if (jwt != null && jwt.isNotEmpty) { + headers['x-appwrite-jwt'] = jwt; + } + + final websok = IOWebSocketChannel((client as ClientIO).selfSigned + ? await _connectForSelfSignedCert(uri, headers) + : await WebSocket.connect(uri.toString(), headers: headers)); return websok; } @@ -70,9 +73,7 @@ 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))); 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 0102de03..6cebb5b1 100644 --- a/lib/src/realtime_mixin.dart +++ b/lib/src/realtime_mixin.dart @@ -58,7 +58,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" + })); } }); } @@ -100,78 +102,72 @@ mixin RealtimeMixin { _websok = await getWebSocket(uri); } _retries = 0; - _websocketSubscription = _websok?.stream.listen( - (response) { - final data = RealtimeResponse.fromJson(response); - switch (data.type) { - case 'error': - handleError(data); - break; - case 'connected': - 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}, - }), - ); - } - } - for (var entry in _subscriptions.entries) { - _pendingSubscribes[entry.key] = { - 'subscriptionId': entry.key, - 'channels': entry.value.channels, - 'queries': entry.value.queries, - }; + _websocketSubscription = _websok?.stream.listen((response) { + final data = RealtimeResponse.fromJson(response); + switch (data.type) { + case 'error': + handleError(data); + break; + case 'connected': + 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, + }, + })); } - _appConnected = true; - _sendPendingSubscribes(); - _flushPendingPresence(); - _startHeartbeat(); // Start heartbeat after successful connection - break; - case 'pong': + } + for (var entry in _subscriptions.entries) { + _pendingSubscribes[entry.key] = { + 'subscriptionId': entry.key, + 'channels': entry.value.channels, + 'queries': entry.value.queries, + }; + } + _appConnected = true; + _sendPendingSubscribes(); + _flushPendingPresence(); + _startHeartbeat(); // Start heartbeat after successful connection + break; + case 'pong': + break; + case 'event': + final messageData = data.data as Map; + final message = RealtimeMessage.fromMap(messageData); + final subscriptions = (messageData['subscriptions'] as List?) + ?.map((x) => x.toString()) + .toList() ?? []; + + if (subscriptions.isEmpty) { break; - case 'event': - final messageData = data.data as Map; - final message = RealtimeMessage.fromMap(messageData); - final subscriptions = - (messageData['subscriptions'] as List?) - ?.map((x) => x.toString()) - .toList() ?? - []; - - if (subscriptions.isEmpty) { - break; - } + } - for (var subscriptionId in subscriptions) { - final subscription = _subscriptions[subscriptionId]; - if (subscription != null) { - subscription.controller.add(message); - } + for (var subscriptionId in subscriptions) { + final subscription = _subscriptions[subscriptionId]; + if (subscription != null) { + subscription.controller.add(message); } - break; - } - }, - onDone: () { - _appConnected = false; - _stopHeartbeat(); - _retry(); - }, - onError: (err, stack) { - _appConnected = false; - _stopHeartbeat(); - for (var subscription in _subscriptions.values) { - subscription.controller.addError(err, stack); - } - _retry(); - }, - ); + } + break; + } + }, onDone: () { + _appConnected = false; + _stopHeartbeat(); + _retry(); + }, onError: (err, stack) { + _appConnected = false; + _stopHeartbeat(); + for (var subscription in _subscriptions.values) { + subscription.controller.addError(err, stack); + } + _retry(); + }); } catch (e) { if (e is AppwriteException) { rethrow; @@ -210,20 +206,16 @@ mixin RealtimeMixin { 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!); - - var queryParams = - "project=${Uri.encodeComponent(client.config['project']!)}"; + + var queryParams = "project=${Uri.encodeComponent(client.config['project']!)}"; final portPart = (uri.hasPort && uri.port != 80 && uri.port != 443) ? ':${uri.port}' : ''; - return Uri.parse( - "${uri.scheme}://${uri.host}$portPart${uri.path}/realtime?$queryParams", - ); + return Uri.parse("${uri.scheme}://${uri.host}$portPart${uri.path}/realtime?$queryParams"); } void _sendUnsubscribeMessage(List subscriptionIds) { @@ -233,12 +225,10 @@ mixin RealtimeMixin { if (_websok == null || _websok?.closeCode != null) { return; } - _websok!.sink.add( - jsonEncode({ - 'type': 'unsubscribe', - 'data': subscriptionIds.map((id) => {'subscriptionId': id}).toList(), - }), - ); + _websok!.sink.add(jsonEncode({ + 'type': 'unsubscribe', + 'data': subscriptionIds.map((id) => {'subscriptionId': id}).toList(), + })); } String _generateUniqueSubscriptionId() { @@ -300,7 +290,10 @@ mixin RealtimeMixin { final rows = _pendingSubscribes.values.toList(); _pendingSubscribes.clear(); - _websok!.sink.add(jsonEncode({'type': 'subscribe', 'data': rows})); + _websok!.sink.add(jsonEncode({ + 'type': 'subscribe', + 'data': rows, + })); } void _flushPendingPresence() { @@ -317,13 +310,9 @@ mixin RealtimeMixin { return channel is String ? channel : channel.toString(); } - RealtimeSubscription subscribeTo( - List channels, [ - List queries = const [], - ]) { + RealtimeSubscription subscribeTo(List channels, [List queries = const []]) { StreamController controller = StreamController.broadcast(); - final channelStrings = - channels.map((ch) => _channelToString(ch)).toList().cast(); + final channelStrings = channels.map((ch) => _channelToString(ch)).toList().cast(); final queryStrings = List.from(queries); final subscriptionId = _generateUniqueSubscriptionId(); @@ -340,7 +329,8 @@ mixin RealtimeMixin { _sendUnsubscribeMessage([subscriptionId]); } - Future update({List? channels, List? queries}) async { + Future update( + {List? channels, List? queries}) async { final current = _subscriptions[subscriptionId]; if (current == null) { return; @@ -405,7 +395,10 @@ mixin RealtimeMixin { List? permissions, Map? metadata, }) { - final data = {'status': status, 'presenceId': presenceId}; + final data = { + 'status': status, + 'presenceId': presenceId, + }; if (permissions != null) data['permissions'] = permissions; if (metadata != null) data['metadata'] = metadata; @@ -424,4 +417,4 @@ mixin RealtimeMixin { // until the application-level handshake completes. _flushPendingPresence(); } -} +} \ 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/lib/src/realtime_stub.dart b/lib/src/realtime_stub.dart index 3aab4e03..ce0b7e95 100644 --- a/lib/src/realtime_stub.dart +++ b/lib/src/realtime_stub.dart @@ -3,5 +3,5 @@ import 'client.dart'; /// Implemented in `realtime_browser.dart` and `realtime_io.dart`. RealtimeBase createRealtime(Client client) => throw UnsupportedError( - 'Cannot create a client without dart:html or dart:io.', - ); + 'Cannot create a client without dart:html or dart:io.', +); diff --git a/pubspec.yaml b/pubspec.yaml index 21fc904f..1277dec1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: appwrite -version: 25.1.0 +version: 25.2.0 description: Appwrite is an open-source self-hosted backend server that abstracts and simplifies 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/channel_test.dart b/test/channel_test.dart index 5ed52b81..62031aec 100644 --- a/test/channel_test.dart +++ b/test/channel_test.dart @@ -8,28 +8,18 @@ void main() { }); test('returns database channel with specific IDs', () { - expect( - Channel.database('db1').collection('col1').document().toString(), - 'databases.db1.collections.col1.documents', - ); + expect(Channel.database('db1').collection('col1').document().toString(), + 'databases.db1.collections.col1.documents'); }); test('returns database channel with action', () { - expect( - Channel.database( - 'db1', - ).collection('col1').document('doc1').create().toString(), - 'databases.db1.collections.col1.documents.doc1.create', - ); + expect(Channel.database('db1').collection('col1').document('doc1').create().toString(), + 'databases.db1.collections.col1.documents.doc1.create'); }); test('returns database channel with upsert action', () { - expect( - Channel.database( - 'db1', - ).collection('col1').document('doc1').upsert().toString(), - 'databases.db1.collections.col1.documents.doc1.upsert', - ); + expect(Channel.database('db1').collection('col1').document('doc1').upsert().toString(), + 'databases.db1.collections.col1.documents.doc1.upsert'); }); }); @@ -39,17 +29,13 @@ void main() { }); test('returns tablesdb channel with specific IDs', () { - expect( - Channel.tablesdb('db1').table('table1').row().toString(), - 'tablesdb.db1.tables.table1.rows', - ); + expect(Channel.tablesdb('db1').table('table1').row().toString(), + 'tablesdb.db1.tables.table1.rows'); }); test('returns tablesdb channel with action', () { - expect( - Channel.tablesdb('db1').table('table1').row('row1').update().toString(), - 'tablesdb.db1.tables.table1.rows.row1.update', - ); + expect(Channel.tablesdb('db1').table('table1').row('row1').update().toString(), + 'tablesdb.db1.tables.table1.rows.row1.update'); }); }); @@ -61,21 +47,17 @@ void main() { group('bucket()', () { test('throws when bucket id is missing', () { - expect(() => Channel.bucket(''), throwsArgumentError); + expect(() => Channel.bucket(''), throwsArgumentError); }); test('returns buckets channel with specific IDs', () { - expect( - Channel.bucket('bucket1').file().toString(), - 'buckets.bucket1.files', - ); + expect(Channel.bucket('bucket1').file().toString(), + 'buckets.bucket1.files'); }); test('returns buckets channel with action', () { - expect( - Channel.bucket('bucket1').file('file1').delete().toString(), - 'buckets.bucket1.files.file1.delete', - ); + expect(Channel.bucket('bucket1').file('file1').delete().toString(), + 'buckets.bucket1.files.file1.delete'); }); }); @@ -101,35 +83,30 @@ void main() { group('teams()', () { test('throws when team id is missing', () { - expect(() => Channel.team(''), throwsArgumentError); + expect(() => Channel.team(''), throwsArgumentError); }); test('returns teams channel with specific team ID', () { - expect(Channel.team('team1').toString(), 'teams.team1'); + expect(Channel.team('team1').toString(), 'teams.team1'); }); test('returns teams channel with action', () { - expect(Channel.team('team1').create().toString(), 'teams.team1.create'); + expect(Channel.team('team1').create().toString(), 'teams.team1.create'); }); }); group('memberships()', () { test('throws when membership id is missing', () { - expect(() => Channel.membership(''), throwsArgumentError); + expect(() => Channel.membership(''), throwsArgumentError); }); test('returns memberships channel with specific membership ID', () { - expect( - Channel.membership('membership1').toString(), - 'memberships.membership1', - ); + expect(Channel.membership('membership1').toString(), 'memberships.membership1'); }); test('returns memberships channel with action', () { - expect( - Channel.membership('membership1').update().toString(), - 'memberships.membership1.update', - ); + expect(Channel.membership('membership1').update().toString(), + 'memberships.membership1.update'); }); }); @@ -147,31 +124,23 @@ void main() { }); test('returns presence channel with create action', () { - expect( - Channel.presence('presence1').create().toString(), - 'presences.presence1.create', - ); + expect(Channel.presence('presence1').create().toString(), + 'presences.presence1.create'); }); test('returns presence channel with upsert action', () { - expect( - Channel.presence('presence1').upsert().toString(), - 'presences.presence1.upsert', - ); + expect(Channel.presence('presence1').upsert().toString(), + 'presences.presence1.upsert'); }); test('returns presence channel with update action', () { - expect( - Channel.presence('presence1').update().toString(), - 'presences.presence1.update', - ); + expect(Channel.presence('presence1').update().toString(), + 'presences.presence1.update'); }); test('returns presence channel with delete action', () { - expect( - Channel.presence('presence1').delete().toString(), - 'presences.presence1.delete', - ); + expect(Channel.presence('presence1').delete().toString(), + 'presences.presence1.delete'); }); }); } diff --git a/test/query_test.dart b/test/query_test.dart index dce037c0..25388fad 100644 --- a/test/query_test.dart +++ b/test/query_test.dart @@ -63,12 +63,16 @@ void main() { group('notEqual()', () { for (var t in tests) { - test(t.description, () { - final query = jsonDecode(Query.notEqual('attr', t.value)); - expect(query['attribute'], 'attr'); - expect(query['values'], t.expectedValues); - expect(query['method'], 'notEqual'); - }, skip: t.value is List); + test( + t.description, + () { + final query = jsonDecode(Query.notEqual('attr', t.value)); + expect(query['attribute'], 'attr'); + expect(query['values'], t.expectedValues); + expect(query['method'], 'notEqual'); + }, + skip: t.value is List, + ); } }); @@ -350,3 +354,4 @@ void main() { expect(query['method'], 'between'); }); } + diff --git a/test/services/account_test.dart b/test/services/account_test.dart index f0790ac8..bd65aa32 100644 --- a/test/services/account_test.dart +++ b/test/services/account_test.dart @@ -18,18 +18,18 @@ class MockClient extends Mock implements Client { Map params = const {}, ResponseType? responseType, }) async { - return super.noSuchMethod( - Invocation.method(#call, [method]), - returnValue: Response(), - ); + return super.noSuchMethod(Invocation.method(#call, [method]), + returnValue: Response()); } @override - Future webAuth(Uri? url, {String? callbackUrlScheme}) async { - return super.noSuchMethod( - Invocation.method(#webAuth, [url]), - returnValue: 'done', - ); + Future webAuth( + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,1321 +41,1540 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method(#chunkedUpload, [ - path, - params, - paramName, - idParamName, - headers, - ]), - returnValue: Response(data: {}), - ); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Account test', () { - late MockClient client; - late Account account; + group('Account test', () { + late MockClient client; + late Account account; + + setUp(() { + client = MockClient(); + account = Account(client); + }); + + test('test method get()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.get( + ); + expect(response, isA()); - setUp(() { - client = MockClient(); - account = Account(client); - }); + }); + + test('test method create()', () async { - test('test method get()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); - - final response = await account.get(); - expect(response, isA()); - }); + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - test('test method create()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); - - final response = await account.create( - userId: '', - email: 'email@example.com', - password: '', - ); - expect(response, isA()); - }); - test('test method updateEmail()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateEmail( - email: 'email@example.com', - password: 'password', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - test('test method listIdentities()', () async { - final Map data = {'total': 5, 'identities': []}; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + final response = await account.create( + userId: '', + email: 'email@example.com', + password: 'password', + ); + expect(response, isA()); - final response = await account.listIdentities(); - expect(response, isA()); - }); + }); - test('test method deleteIdentity()', () async { - final data = ''; + test('test method updateEmail()', () async { - when( - client.call(HttpMethod.delete), - ).thenAnswer((_) async => Response(data: data)); + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - final response = await account.deleteIdentity( - identityId: '', - ); - }); - test('test method createJWT()', () async { - final Map data = { - 'jwt': - 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', - }; + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); - final response = await account.createJWT(); - expect(response, isA()); - }); + final response = await account.updateEmail( + email: 'email@example.com', + password: 'password', + ); + expect(response, isA()); - test('test method listLogs()', () async { - final Map data = {'total': 5, 'logs': []}; + }); - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + test('test method listIdentities()', () async { - final response = await account.listLogs(); - expect(response, isA()); - }); + final Map data = { + 'total': 5, + 'identities': [],}; - test('test method updateMFA()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateMFA(mfa: true); - expect(response, isA()); - }); - test('test method createMfaAuthenticator()', () async { - final Map data = { - 'secret': '[SHARED_SECRET]', - 'uri': - 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', - }; - - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); - - final response = await account.createMfaAuthenticator( - type: enums.AuthenticatorType.totp, - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method createMFAAuthenticator()', () async { - final Map data = { - 'secret': '[SHARED_SECRET]', - 'uri': - 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', - }; - - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); - - final response = await account.createMFAAuthenticator( - type: enums.AuthenticatorType.totp, - ); - expect(response, isA()); - }); - test('test method updateMfaAuthenticator()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when( - client.call(HttpMethod.put), - ).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateMfaAuthenticator( - type: enums.AuthenticatorType.totp, - otp: '', - ); - expect(response, isA()); - }); + final response = await account.listIdentities( + ); + expect(response, isA()); - test('test method updateMFAAuthenticator()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when( - client.call(HttpMethod.put), - ).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateMFAAuthenticator( - type: enums.AuthenticatorType.totp, - otp: '', - ); - expect(response, isA()); - }); + }); - test('test method deleteMfaAuthenticator()', () async { - final data = ''; + test('test method deleteIdentity()', () async { - when( - client.call(HttpMethod.delete), - ).thenAnswer((_) async => Response(data: data)); + final data = ''; - final response = await account.deleteMfaAuthenticator( - type: enums.AuthenticatorType.totp, - ); - }); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - test('test method deleteMFAAuthenticator()', () async { - final data = ''; - when( - client.call(HttpMethod.delete), - ).thenAnswer((_) async => Response(data: data)); + final response = await account.deleteIdentity( + identityId: '', + ); + }); - final response = await account.deleteMFAAuthenticator( - type: enums.AuthenticatorType.totp, - ); - }); + test('test method createJWT()', () async { - test('test method createMfaChallenge()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'expire': '2020-10-15T06:38:00.000+00:00', - }; - - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); - - final response = await account.createMfaChallenge( - factor: enums.AuthenticationFactor.email, - ); - expect(response, isA()); - }); + final Map data = { + 'jwt': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c',}; - test('test method createMFAChallenge()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'expire': '2020-10-15T06:38:00.000+00:00', - }; - - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); - - final response = await account.createMFAChallenge( - factor: enums.AuthenticationFactor.email, - ); - expect(response, isA()); - }); - test('test method updateMfaChallenge()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when( - client.call(HttpMethod.put), - ).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateMfaChallenge( - challengeId: '', - otp: '', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - test('test method updateMFAChallenge()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when( - client.call(HttpMethod.put), - ).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateMFAChallenge( - challengeId: '', - otp: '', - ); - expect(response, isA()); - }); - test('test method listMfaFactors()', () async { - final Map data = { - 'totp': true, - 'phone': true, - 'email': true, - 'recoveryCode': true, - }; + final response = await account.createJWT( + ); + expect(response, isA()); - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + }); - final response = await account.listMfaFactors(); - expect(response, isA()); - }); + test('test method listLogs()', () async { - test('test method listMFAFactors()', () async { - final Map data = { - 'totp': true, - 'phone': true, - 'email': true, - 'recoveryCode': true, - }; + final Map data = { + 'total': 5, + 'logs': [],}; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); - final response = await account.listMFAFactors(); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method getMfaRecoveryCodes()', () async { - final Map data = {'recoveryCodes': []}; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + final response = await account.listLogs( + ); + expect(response, isA()); - final response = await account.getMfaRecoveryCodes(); - expect(response, isA()); - }); + }); - test('test method getMFARecoveryCodes()', () async { - final Map data = {'recoveryCodes': []}; + test('test method updateMFA()', () async { - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - final response = await account.getMFARecoveryCodes(); - expect(response, isA()); - }); - test('test method createMfaRecoveryCodes()', () async { - final Map data = {'recoveryCodes': []}; + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); - final response = await account.createMfaRecoveryCodes(); - expect(response, isA()); - }); + final response = await account.updateMFA( + mfa: true, + ); + expect(response, isA()); - test('test method createMFARecoveryCodes()', () async { - final Map data = {'recoveryCodes': []}; + }); - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); + test('test method createMfaAuthenticator()', () async { - final response = await account.createMFARecoveryCodes(); - expect(response, isA()); - }); + final Map data = { + 'secret': '[SHARED_SECRET]', + 'uri': 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite',}; - test('test method updateMfaRecoveryCodes()', () async { - final Map data = {'recoveryCodes': []}; - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - final response = await account.updateMfaRecoveryCodes(); - expect(response, isA()); - }); - test('test method updateMFARecoveryCodes()', () async { - final Map data = {'recoveryCodes': []}; + final response = await account.createMfaAuthenticator( + type: enums.AuthenticatorType.totp, + ); + expect(response, isA()); - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); + }); - final response = await account.updateMFARecoveryCodes(); - expect(response, isA()); - }); + test('test method createMFAAuthenticator()', () async { - test('test method updateName()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateName(name: ''); - expect(response, isA()); - }); + final Map data = { + 'secret': '[SHARED_SECRET]', + 'uri': 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite',}; - test('test method updatePassword()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); - - final response = await account.updatePassword(password: ''); - expect(response, isA()); - }); - test('test method updatePhone()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); - - final response = await account.updatePhone( - phone: '+12065550100', - password: 'password', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - test('test method getPrefs()', () async { - final Map data = {}; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + final response = await account.createMFAAuthenticator( + type: enums.AuthenticatorType.totp, + ); + expect(response, isA()); - final response = await account.getPrefs(); - expect(response, isA()); - }); + }); - test('test method updatePrefs()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); - - final response = await account.updatePrefs(prefs: {}); - expect(response, isA()); - }); + test('test method updateMfaAuthenticator()', () async { - test('test method createRecovery()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); - - final response = await account.createRecovery( - email: 'email@example.com', - url: 'https://example.com', - ); - expect(response, isA()); - }); + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - test('test method updateRecovery()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when( - client.call(HttpMethod.put), - ).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateRecovery( - userId: '', - secret: '', - password: '', - ); - expect(response, isA()); - }); - test('test method listSessions()', () async { - final Map data = {'total': 5, 'sessions': []}; + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); - final response = await account.listSessions(); - expect(response, isA()); - }); + final response = await account.updateMfaAuthenticator( + type: enums.AuthenticatorType.totp, + otp: '', + ); + expect(response, isA()); - test('test method deleteSessions()', () async { - final data = ''; + }); - when( - client.call(HttpMethod.delete), - ).thenAnswer((_) async => Response(data: data)); + test('test method updateMFAAuthenticator()', () async { - final response = await account.deleteSessions(); - }); + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - test('test method createAnonymousSession()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); - - final response = await account.createAnonymousSession(); - expect(response, isA()); - }); - test('test method createEmailPasswordSession()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); - - final response = await account.createEmailPasswordSession( - email: 'email@example.com', - password: 'password', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); - test('test method updateMagicURLSession()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when( - client.call(HttpMethod.put), - ).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateMagicURLSession( - userId: '', - secret: '', - ); - expect(response, isA()); - }); - test('test method createOAuth2Session()', () async { - when(client.webAuth(argThat(isNotNull))).thenAnswer((_) async => 'done'); + final response = await account.updateMFAAuthenticator( + type: enums.AuthenticatorType.totp, + otp: '', + ); + expect(response, isA()); - final response = await account.createOAuth2Session( - provider: enums.OAuthProvider.amazon, - ); - expect(response, equals('done')); - }); + }); - test('test method updatePhoneSession()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when( - client.call(HttpMethod.put), - ).thenAnswer((_) async => Response(data: data)); - - final response = await account.updatePhoneSession( - userId: '', - secret: '', - ); - expect(response, isA()); - }); + test('test method deleteMfaAuthenticator()', () async { - test('test method createSession()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); - - final response = await account.createSession( - userId: '', - secret: '', - ); - expect(response, isA()); - }); + final data = ''; - test('test method getSession()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); - - final response = await account.getSession(sessionId: ''); - expect(response, isA()); - }); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - test('test method updateSession()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateSession(sessionId: ''); - expect(response, isA()); - }); - test('test method deleteSession()', () async { - final data = ''; + final response = await account.deleteMfaAuthenticator( + type: enums.AuthenticatorType.totp, + ); + }); - when( - client.call(HttpMethod.delete), - ).thenAnswer((_) async => Response(data: data)); + test('test method deleteMFAAuthenticator()', () async { - final response = await account.deleteSession(sessionId: ''); - }); + final data = ''; - test('test method updateStatus()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateStatus(); - expect(response, isA()); - }); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - test('test method createPushTarget()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'Apple iPhone 12', - 'userId': '259125845563242502', - 'providerType': 'email', - 'identifier': 'token', - 'expired': true, - }; - - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); - - final response = await account.createPushTarget( - targetId: '', - identifier: '', - ); - expect(response, isA()); - }); - test('test method updatePushTarget()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'Apple iPhone 12', - 'userId': '259125845563242502', - 'providerType': 'email', - 'identifier': 'token', - 'expired': true, - }; - - when( - client.call(HttpMethod.put), - ).thenAnswer((_) async => Response(data: data)); - - final response = await account.updatePushTarget( - targetId: '', - identifier: '', - ); - expect(response, isA()); - }); + final response = await account.deleteMFAAuthenticator( + type: enums.AuthenticatorType.totp, + ); + }); + + test('test method createMfaChallenge()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'expire': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createMfaChallenge( + factor: enums.AuthenticationFactor.email, + ); + expect(response, isA()); + + }); + + test('test method createMFAChallenge()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'expire': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createMFAChallenge( + factor: enums.AuthenticationFactor.email, + ); + expect(response, isA()); + + }); + + test('test method updateMfaChallenge()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - test('test method deletePushTarget()', () async { - final data = ''; - when( - client.call(HttpMethod.delete), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); - final response = await account.deletePushTarget(targetId: ''); - }); - test('test method createEmailToken()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); - - final response = await account.createEmailToken( - userId: '', - email: 'email@example.com', - ); - expect(response, isA()); - }); + final response = await account.updateMfaChallenge( + challengeId: '', + otp: '', + ); + expect(response, isA()); - test('test method createMagicURLToken()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); - - final response = await account.createMagicURLToken( - userId: '', - email: 'email@example.com', - ); - expect(response, isA()); - }); + }); - test('test method createOAuth2Token()', () async { - when(client.webAuth(argThat(isNotNull))).thenAnswer((_) async => 'done'); + test('test method updateMFAChallenge()', () async { - final response = await account.createOAuth2Token( - provider: enums.OAuthProvider.amazon, - ); - expect(response, equals('done')); - }); + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - test('test method createPhoneToken()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); - - final response = await account.createPhoneToken( - userId: '', - phone: '+12065550100', - ); - expect(response, isA()); - }); - test('test method createEmailVerification()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); - - final response = await account.createEmailVerification( - url: 'https://example.com', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); - test('test method createVerification()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); - - final response = await account.createVerification( - url: 'https://example.com', - ); - expect(response, isA()); - }); - test('test method updateEmailVerification()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when( - client.call(HttpMethod.put), - ).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateEmailVerification( - userId: '', - secret: '', - ); - expect(response, isA()); - }); + final response = await account.updateMFAChallenge( + challengeId: '', + otp: '', + ); + expect(response, isA()); - test('test method updateVerification()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when( - client.call(HttpMethod.put), - ).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateVerification( - userId: '', - secret: '', - ); - expect(response, isA()); - }); + }); - test('test method createPhoneVerification()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); - - final response = await account.createPhoneVerification(); - expect(response, isA()); - }); + test('test method listMfaFactors()', () async { + + final Map data = { + 'totp': true, + 'phone': true, + 'email': true, + 'recoveryCode': true,}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.listMfaFactors( + ); + expect(response, isA()); + + }); + + test('test method listMFAFactors()', () async { + + final Map data = { + 'totp': true, + 'phone': true, + 'email': true, + 'recoveryCode': true,}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.listMFAFactors( + ); + expect(response, isA()); + + }); + + test('test method getMfaRecoveryCodes()', () async { + + final Map data = { + 'recoveryCodes': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.getMfaRecoveryCodes( + ); + expect(response, isA()); + + }); + + test('test method getMFARecoveryCodes()', () async { + + final Map data = { + 'recoveryCodes': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.getMFARecoveryCodes( + ); + expect(response, isA()); + + }); + + test('test method createMfaRecoveryCodes()', () async { + + final Map data = { + 'recoveryCodes': [],}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createMfaRecoveryCodes( + ); + expect(response, isA()); + + }); + + test('test method createMFARecoveryCodes()', () async { + + final Map data = { + 'recoveryCodes': [],}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createMFARecoveryCodes( + ); + expect(response, isA()); + + }); + + test('test method updateMfaRecoveryCodes()', () async { + + final Map data = { + 'recoveryCodes': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateMfaRecoveryCodes( + ); + expect(response, isA()); + + }); + + test('test method updateMFARecoveryCodes()', () async { + + final Map data = { + 'recoveryCodes': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateMFARecoveryCodes( + ); + expect(response, isA()); + + }); + + test('test method updateName()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateName( + name: '', + ); + expect(response, isA()); + + }); + + test('test method updatePassword()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updatePassword( + password: 'password', + ); + expect(response, isA()); + + }); + + test('test method updatePhone()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updatePhone( + phone: '+12065550100', + password: 'password', + ); + expect(response, isA()); + + }); + + test('test method getPrefs()', () async { + + final Map data = {}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.getPrefs( + ); + expect(response, isA()); + + }); + + test('test method updatePrefs()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updatePrefs( + prefs: {}, + ); + expect(response, isA()); + + }); + + test('test method createRecovery()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createRecovery( + email: 'email@example.com', + url: 'https://example.com', + ); + expect(response, isA()); + + }); + + test('test method updateRecovery()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateRecovery( + userId: '', + secret: '', + password: 'password', + ); + expect(response, isA()); + + }); + + test('test method listSessions()', () async { + + final Map data = { + 'total': 5, + 'sessions': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.listSessions( + ); + expect(response, isA()); + + }); + + test('test method deleteSessions()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.deleteSessions( + ); + }); + + test('test method createAnonymousSession()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createAnonymousSession( + ); + expect(response, isA()); + + }); + + test('test method createEmailPasswordSession()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createEmailPasswordSession( + email: 'email@example.com', + password: 'password', + ); + expect(response, isA()); + + }); + + test('test method updateMagicURLSession()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateMagicURLSession( + userId: '', + secret: '', + ); + expect(response, isA()); + + }); + + test('test method createOAuth2Session()', () async { + + + when(client.webAuth( + argThat(isNotNull), + )).thenAnswer((_) async => 'done'); + + + final response = await account.createOAuth2Session( + provider: enums.OAuthProvider.amazon, + ); + expect(response, equals('done')); + + }); + + test('test method updatePhoneSession()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updatePhoneSession( + userId: '', + secret: '', + ); + expect(response, isA()); + + }); + + test('test method createSession()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createSession( + userId: '', + secret: '', + ); + expect(response, isA()); + + }); + + test('test method getSession()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.getSession( + sessionId: '', + ); + expect(response, isA()); + + }); + + test('test method updateSession()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateSession( + sessionId: '', + ); + expect(response, isA()); + + }); + + test('test method deleteSession()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.deleteSession( + sessionId: '', + ); + }); + + test('test method updateStatus()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateStatus( + ); + expect(response, isA()); + + }); + + test('test method createPushTarget()', () async { + + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Apple iPhone 12', + 'userId': '259125845563242502', + 'providerType': 'email', + 'identifier': 'token', + 'expired': true,}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createPushTarget( + targetId: '', + identifier: '', + ); + expect(response, isA()); + + }); + + test('test method updatePushTarget()', () async { + + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Apple iPhone 12', + 'userId': '259125845563242502', + 'providerType': 'email', + 'identifier': 'token', + 'expired': true,}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updatePushTarget( + targetId: '', + identifier: '', + ); + expect(response, isA()); + + }); + + test('test method deletePushTarget()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.deletePushTarget( + targetId: '', + ); + }); + + test('test method createEmailToken()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createEmailToken( + userId: '', + email: 'email@example.com', + ); + expect(response, isA()); + + }); + + test('test method createMagicURLToken()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createMagicURLToken( + userId: '', + email: 'email@example.com', + ); + expect(response, isA()); + + }); + + test('test method createOAuth2Token()', () async { + + + when(client.webAuth( + argThat(isNotNull), + )).thenAnswer((_) async => 'done'); + + + final response = await account.createOAuth2Token( + provider: enums.OAuthProvider.amazon, + ); + expect(response, equals('done')); + + }); + + test('test method createPhoneToken()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createPhoneToken( + userId: '', + phone: '+12065550100', + ); + expect(response, isA()); + + }); + + test('test method createEmailVerification()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createEmailVerification( + url: 'https://example.com', + ); + expect(response, isA()); + + }); + + test('test method createVerification()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createVerification( + url: 'https://example.com', + ); + expect(response, isA()); + + }); + + test('test method updateEmailVerification()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateEmailVerification( + userId: '', + secret: '', + ); + expect(response, isA()); + + }); + + test('test method updateVerification()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateVerification( + userId: '', + secret: '', + ); + expect(response, isA()); + + }); + + test('test method createPhoneVerification()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createPhoneVerification( + ); + expect(response, isA()); + + }); + + test('test method updatePhoneVerification()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updatePhoneVerification( + userId: '', + secret: '', + ); + expect(response, isA()); + + }); - test('test method updatePhoneVerification()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when( - client.call(HttpMethod.put), - ).thenAnswer((_) async => Response(data: data)); - - final response = await account.updatePhoneVerification( - userId: '', - secret: '', - ); - expect(response, isA()); }); - }); } diff --git a/test/services/avatars_test.dart b/test/services/avatars_test.dart index 5b4a7340..4bdb434d 100644 --- a/test/services/avatars_test.dart +++ b/test/services/avatars_test.dart @@ -18,18 +18,18 @@ class MockClient extends Mock implements Client { Map params = const {}, ResponseType? responseType, }) async { - return super.noSuchMethod( - Invocation.method(#call, [method]), - returnValue: Response(), - ); + return super.noSuchMethod(Invocation.method(#call, [method]), + returnValue: Response()); } @override - Future webAuth(Uri? url, {String? callbackUrlScheme}) async { - return super.noSuchMethod( - Invocation.method(#webAuth, [url]), - returnValue: 'done', - ); + Future webAuth( + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,119 +41,138 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method(#chunkedUpload, [ - path, - params, - paramName, - idParamName, - headers, - ]), - returnValue: Response(data: {}), - ); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Avatars test', () { - late MockClient client; - late Avatars avatars; + group('Avatars test', () { + late MockClient client; + late Avatars avatars; - setUp(() { - client = MockClient(); - avatars = Avatars(client); - }); + setUp(() { + client = MockClient(); + avatars = Avatars(client); + }); - test('test method getBrowser()', () async { - final Uint8List data = Uint8List.fromList([]); + test('test method getBrowser()', () async { +final Uint8List data = Uint8List.fromList([]); - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await avatars.getBrowser( - code: enums.Browser.avantBrowser, - ); - expect(response, isA()); - }); - test('test method getCreditCard()', () async { - final Uint8List data = Uint8List.fromList([]); + final response = await avatars.getBrowser( + code: enums.Browser.avantBrowser, + ); + expect(response, isA()); - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + }); - final response = await avatars.getCreditCard( - code: enums.CreditCard.americanExpress, - ); - expect(response, isA()); - }); + test('test method getCreditCard()', () async { +final Uint8List data = Uint8List.fromList([]); - test('test method getFavicon()', () async { - final Uint8List data = Uint8List.fromList([]); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); - final response = await avatars.getFavicon(url: 'https://example.com'); - expect(response, isA()); - }); + final response = await avatars.getCreditCard( + code: enums.CreditCard.americanExpress, + ); + expect(response, isA()); - test('test method getFlag()', () async { - final Uint8List data = Uint8List.fromList([]); + }); - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + test('test method getFavicon()', () async { +final Uint8List data = Uint8List.fromList([]); - final response = await avatars.getFlag(code: enums.Flag.afghanistan); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method getImage()', () async { - final Uint8List data = Uint8List.fromList([]); - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + final response = await avatars.getFavicon( + url: 'https://example.com', + ); + expect(response, isA()); - final response = await avatars.getImage(url: 'https://example.com'); - expect(response, isA()); - }); + }); - test('test method getInitials()', () async { - final Uint8List data = Uint8List.fromList([]); + test('test method getFlag()', () async { +final Uint8List data = Uint8List.fromList([]); - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await avatars.getInitials(); - expect(response, isA()); - }); - test('test method getQR()', () async { - final Uint8List data = Uint8List.fromList([]); + final response = await avatars.getFlag( + code: enums.Flag.afghanistan, + ); + expect(response, isA()); - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + }); + + test('test method getImage()', () async { +final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await avatars.getImage( + url: 'https://example.com', + ); + expect(response, isA()); + + }); + + test('test method getInitials()', () async { +final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await avatars.getInitials( + ); + expect(response, isA()); + + }); + + test('test method getQR()', () async { +final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await avatars.getQR( + text: '', + ); + expect(response, isA()); + + }); + + test('test method getScreenshot()', () async { +final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await avatars.getQR(text: ''); - expect(response, isA()); - }); - test('test method getScreenshot()', () async { - final Uint8List data = Uint8List.fromList([]); + final response = await avatars.getScreenshot( + url: 'https://example.com', + ); + expect(response, isA()); - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + }); - final response = await avatars.getScreenshot(url: 'https://example.com'); - expect(response, isA()); }); - }); } diff --git a/test/services/databases_test.dart b/test/services/databases_test.dart index 1cd1e982..a4b0a6cc 100644 --- a/test/services/databases_test.dart +++ b/test/services/databases_test.dart @@ -18,18 +18,18 @@ class MockClient extends Mock implements Client { Map params = const {}, ResponseType? responseType, }) async { - return super.noSuchMethod( - Invocation.method(#call, [method]), - returnValue: Response(), - ); + return super.noSuchMethod(Invocation.method(#call, [method]), + returnValue: Response()); } @override - Future webAuth(Uri? url, {String? callbackUrlScheme}) async { - return super.noSuchMethod( - Invocation.method(#webAuth, [url]), - returnValue: 'done', - ); + Future webAuth( + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,297 +41,337 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method(#chunkedUpload, [ - path, - params, - paramName, - idParamName, - headers, - ]), - returnValue: Response(data: {}), - ); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Databases test', () { - late MockClient client; - late Databases databases; + group('Databases test', () { + late MockClient client; + late Databases databases; - setUp(() { - client = MockClient(); - databases = Databases(client); - }); + setUp(() { + client = MockClient(); + databases = Databases(client); + }); - test('test method listTransactions()', () async { - final Map data = {'total': 5, 'transactions': []}; + test('test method listTransactions()', () async { - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + final Map data = { + 'total': 5, + 'transactions': [],}; - final response = await databases.listTransactions(); - expect(response, isA()); - }); - test('test method createTransaction()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', - }; - - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); - - final response = await databases.createTransaction(); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method getTransaction()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', - }; - - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); - - final response = await databases.getTransaction( - transactionId: '', - ); - expect(response, isA()); - }); - test('test method updateTransaction()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', - }; - - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); - - final response = await databases.updateTransaction( - transactionId: '', - ); - expect(response, isA()); - }); + final response = await databases.listTransactions( + ); + expect(response, isA()); - test('test method deleteTransaction()', () async { - final data = ''; + }); - when( - client.call(HttpMethod.delete), - ).thenAnswer((_) async => Response(data: data)); + test('test method createTransaction()', () async { - final response = await databases.deleteTransaction( - transactionId: '', - ); - }); + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - test('test method createOperations()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', - }; - - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); - - final response = await databases.createOperations( - transactionId: '', - ); - expect(response, isA()); - }); - test('test method listDocuments()', () async { - final Map data = {'total': 5, 'documents': []}; + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); - final response = await databases.listDocuments( - databaseId: '', - collectionId: '', - ); - expect(response, isA()); - }); + final response = await databases.createTransaction( + ); + expect(response, isA()); - test('test method createDocument()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); - - final response = await databases.createDocument( - databaseId: '', - collectionId: '', - documentId: '', - data: {}, - ); - expect(response, isA()); - }); + }); - test('test method getDocument()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); - - final response = await databases.getDocument( - databaseId: '', - collectionId: '', - documentId: '', - ); - expect(response, isA()); - }); + test('test method getTransaction()', () async { - test('test method upsertDocument()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when( - client.call(HttpMethod.put), - ).thenAnswer((_) async => Response(data: data)); - - final response = await databases.upsertDocument( - databaseId: '', - collectionId: '', - documentId: '', - ); - expect(response, isA()); - }); + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - test('test method updateDocument()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); - - final response = await databases.updateDocument( - databaseId: '', - collectionId: '', - documentId: '', - ); - expect(response, isA()); - }); - test('test method deleteDocument()', () async { - final data = ''; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when( - client.call(HttpMethod.delete), - ).thenAnswer((_) async => Response(data: data)); - final response = await databases.deleteDocument( - databaseId: '', - collectionId: '', - documentId: '', - ); - }); + final response = await databases.getTransaction( + transactionId: '', + ); + expect(response, isA()); - test('test method decrementDocumentAttribute()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); - - final response = await databases.decrementDocumentAttribute( - databaseId: '', - collectionId: '', - documentId: '', - attribute: '', - ); - expect(response, isA()); - }); + }); + + test('test method updateTransaction()', () async { + + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.updateTransaction( + transactionId: '', + ); + expect(response, isA()); + + }); + + test('test method deleteTransaction()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.deleteTransaction( + transactionId: '', + ); + }); + + test('test method createOperations()', () async { + + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.createOperations( + transactionId: '', + ); + expect(response, isA()); + + }); + + test('test method listDocuments()', () async { + + final Map data = { + 'total': 5, + 'documents': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.listDocuments( + databaseId: '', + collectionId: '', + ); + expect(response, isA()); + + }); + + test('test method createDocument()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.createDocument( + databaseId: '', + collectionId: '', + documentId: '', + data: {}, + ); + expect(response, isA()); + + }); + + test('test method getDocument()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.getDocument( + databaseId: '', + collectionId: '', + documentId: '', + ); + expect(response, isA()); + + }); + + test('test method upsertDocument()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.upsertDocument( + databaseId: '', + collectionId: '', + documentId: '', + ); + expect(response, isA()); + + }); + + test('test method updateDocument()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.updateDocument( + databaseId: '', + collectionId: '', + documentId: '', + ); + expect(response, isA()); + + }); + + test('test method deleteDocument()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.deleteDocument( + databaseId: '', + collectionId: '', + documentId: '', + ); + }); + + test('test method decrementDocumentAttribute()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.decrementDocumentAttribute( + databaseId: '', + collectionId: '', + documentId: '', + attribute: '', + ); + expect(response, isA()); + + }); + + test('test method incrementDocumentAttribute()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.incrementDocumentAttribute( + databaseId: '', + collectionId: '', + documentId: '', + attribute: '', + ); + expect(response, isA()); + + }); - test('test method incrementDocumentAttribute()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); - - final response = await databases.incrementDocumentAttribute( - databaseId: '', - collectionId: '', - documentId: '', - attribute: '', - ); - expect(response, isA()); }); - }); } diff --git a/test/services/functions_test.dart b/test/services/functions_test.dart index 119f56f9..9b0d046f 100644 --- a/test/services/functions_test.dart +++ b/test/services/functions_test.dart @@ -18,18 +18,18 @@ class MockClient extends Mock implements Client { Map params = const {}, ResponseType? responseType, }) async { - return super.noSuchMethod( - Invocation.method(#call, [method]), - returnValue: Response(), - ); + return super.noSuchMethod(Invocation.method(#call, [method]), + returnValue: Response()); } @override - Future webAuth(Uri? url, {String? callbackUrlScheme}) async { - return super.noSuchMethod( - Invocation.method(#webAuth, [url]), - returnValue: 'done', - ); + Future webAuth( + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,103 +41,107 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method(#chunkedUpload, [ - path, - params, - paramName, - idParamName, - headers, - ]), - returnValue: Response(data: {}), - ); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Functions test', () { - late MockClient client; - late Functions functions; + group('Functions test', () { + late MockClient client; + late Functions functions; - setUp(() { - client = MockClient(); - functions = Functions(client); - }); + setUp(() { + client = MockClient(); + functions = Functions(client); + }); - test('test method listExecutions()', () async { - final Map data = {'total': 5, 'executions': []}; + test('test method listExecutions()', () async { - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + final Map data = { + 'total': 5, + 'executions': [],}; - final response = await functions.listExecutions( - functionId: '', - ); - expect(response, isA()); - }); - test('test method createExecution()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'functionId': '5e5ea6g16897e', - 'deploymentId': '5e5ea5c16897e', - 'trigger': 'http', - 'status': 'processing', - 'requestMethod': 'GET', - 'requestPath': '/articles?id=5', - 'requestHeaders': [], - 'responseStatusCode': 200, - 'responseBody': '', - 'responseHeaders': [], - 'logs': '', - 'errors': '', - 'duration': 0.4, - }; - - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); - - final response = await functions.createExecution( - functionId: '', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await functions.listExecutions( + functionId: '', + ); + expect(response, isA()); + + }); + + test('test method createExecution()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'functionId': '5e5ea6g16897e', + 'deploymentId': '5e5ea5c16897e', + 'trigger': 'http', + 'status': 'processing', + 'requestMethod': 'GET', + 'requestPath': '/articles?id=5', + 'requestHeaders': [], + 'responseStatusCode': 200, + 'responseBody': '', + 'responseHeaders': [], + 'logs': '', + 'errors': '', + 'duration': 0.4,}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await functions.createExecution( + functionId: '', + ); + expect(response, isA()); + + }); + + test('test method getExecution()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'functionId': '5e5ea6g16897e', + 'deploymentId': '5e5ea5c16897e', + 'trigger': 'http', + 'status': 'processing', + 'requestMethod': 'GET', + 'requestPath': '/articles?id=5', + 'requestHeaders': [], + 'responseStatusCode': 200, + 'responseBody': '', + 'responseHeaders': [], + 'logs': '', + 'errors': '', + 'duration': 0.4,}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await functions.getExecution( + functionId: '', + executionId: '', + ); + expect(response, isA()); + + }); - test('test method getExecution()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'functionId': '5e5ea6g16897e', - 'deploymentId': '5e5ea5c16897e', - 'trigger': 'http', - 'status': 'processing', - 'requestMethod': 'GET', - 'requestPath': '/articles?id=5', - 'requestHeaders': [], - 'responseStatusCode': 200, - 'responseBody': '', - 'responseHeaders': [], - 'logs': '', - 'errors': '', - 'duration': 0.4, - }; - - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); - - final response = await functions.getExecution( - functionId: '', - executionId: '', - ); - expect(response, isA()); }); - }); } diff --git a/test/services/graphql_test.dart b/test/services/graphql_test.dart index 59026cd2..c548e414 100644 --- a/test/services/graphql_test.dart +++ b/test/services/graphql_test.dart @@ -18,18 +18,18 @@ class MockClient extends Mock implements Client { Map params = const {}, ResponseType? responseType, }) async { - return super.noSuchMethod( - Invocation.method(#call, [method]), - returnValue: Response(), - ); + return super.noSuchMethod(Invocation.method(#call, [method]), + returnValue: Response()); } @override - Future webAuth(Uri? url, {String? callbackUrlScheme}) async { - return super.noSuchMethod( - Invocation.method(#webAuth, [url]), - returnValue: 'done', - ); + Future webAuth( + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,47 +41,47 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method(#chunkedUpload, [ - path, - params, - paramName, - idParamName, - headers, - ]), - returnValue: Response(data: {}), - ); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Graphql test', () { - late MockClient client; - late Graphql graphql; + group('Graphql test', () { + late MockClient client; + late Graphql graphql; - setUp(() { - client = MockClient(); - graphql = Graphql(client); - }); + setUp(() { + client = MockClient(); + graphql = Graphql(client); + }); - test('test method query()', () async { - final data = ''; + test('test method query()', () async { - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); + final data = ''; - final response = await graphql.query(query: {}); - }); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await graphql.query( + query: {}, + ); + }); + + test('test method mutation()', () async { + + final data = ''; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - test('test method mutation()', () async { - final data = ''; - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); + final response = await graphql.mutation( + query: {}, + ); + }); - final response = await graphql.mutation(query: {}); }); - }); } diff --git a/test/services/locale_test.dart b/test/services/locale_test.dart index 4fabebb0..42faaf72 100644 --- a/test/services/locale_test.dart +++ b/test/services/locale_test.dart @@ -18,18 +18,18 @@ class MockClient extends Mock implements Client { Map params = const {}, ResponseType? responseType, }) async { - return super.noSuchMethod( - Invocation.method(#call, [method]), - returnValue: Response(), - ); + return super.noSuchMethod(Invocation.method(#call, [method]), + returnValue: Response()); } @override - Future webAuth(Uri? url, {String? callbackUrlScheme}) async { - return super.noSuchMethod( - Invocation.method(#webAuth, [url]), - returnValue: 'done', - ); + Future webAuth( + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,123 +41,168 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method(#chunkedUpload, [ - path, - params, - paramName, - idParamName, - headers, - ]), - returnValue: Response(data: {}), - ); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Locale test', () { - late MockClient client; - late Locale locale; + group('Locale test', () { + late MockClient client; + late Locale locale; - setUp(() { - client = MockClient(); - locale = Locale(client); - }); + setUp(() { + client = MockClient(); + locale = Locale(client); + }); - test('test method get()', () async { - final Map data = { - 'ip': '127.0.0.1', - 'countryCode': 'US', - 'country': 'United States', - 'continentCode': 'NA', - 'continent': 'North America', - 'eu': true, - 'currency': 'USD', - }; - - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); - - final response = await locale.get(); - expect(response, isA()); - }); + test('test method get()', () async { - test('test method listCodes()', () async { - final Map data = {'total': 5, 'localeCodes': []}; + final Map data = { + 'ip': '127.0.0.1', + 'countryCode': 'US', + 'country': 'United States', + 'continentCode': 'NA', + 'continent': 'North America', + 'eu': true, + 'currency': 'USD',}; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); - final response = await locale.listCodes(); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method listContinents()', () async { - final Map data = {'total': 5, 'continents': []}; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + final response = await locale.get( + ); + expect(response, isA()); - final response = await locale.listContinents(); - expect(response, isA()); - }); + }); - test('test method listCountries()', () async { - final Map data = {'total': 5, 'countries': []}; + test('test method listCodes()', () async { - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + final Map data = { + 'total': 5, + 'localeCodes': [],}; - final response = await locale.listCountries(); - expect(response, isA()); - }); - test('test method listCountriesEU()', () async { - final Map data = {'total': 5, 'countries': []}; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); - final response = await locale.listCountriesEU(); - expect(response, isA()); - }); + final response = await locale.listCodes( + ); + expect(response, isA()); - test('test method listCountriesPhones()', () async { - final Map data = {'total': 5, 'phones': []}; + }); - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + test('test method listContinents()', () async { - final response = await locale.listCountriesPhones(); - expect(response, isA()); - }); + final Map data = { + 'total': 5, + 'continents': [],}; - test('test method listCurrencies()', () async { - final Map data = {'total': 5, 'currencies': []}; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await locale.listContinents( + ); + expect(response, isA()); + + }); + + test('test method listCountries()', () async { + + final Map data = { + 'total': 5, + 'countries': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await locale.listCountries( + ); + expect(response, isA()); + + }); + + test('test method listCountriesEU()', () async { + + final Map data = { + 'total': 5, + 'countries': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await locale.listCountriesEU( + ); + expect(response, isA()); + + }); + + test('test method listCountriesPhones()', () async { + + final Map data = { + 'total': 5, + 'phones': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await locale.listCountriesPhones( + ); + expect(response, isA()); + + }); + + test('test method listCurrencies()', () async { + + final Map data = { + 'total': 5, + 'currencies': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await locale.listCurrencies( + ); + expect(response, isA()); + + }); + + test('test method listLanguages()', () async { + + final Map data = { + 'total': 5, + 'languages': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await locale.listCurrencies(); - expect(response, isA()); - }); - test('test method listLanguages()', () async { - final Map data = {'total': 5, 'languages': []}; + final response = await locale.listLanguages( + ); + expect(response, isA()); - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + }); - final response = await locale.listLanguages(); - expect(response, isA()); }); - }); } diff --git a/test/services/messaging_test.dart b/test/services/messaging_test.dart index 96484f89..5899ace3 100644 --- a/test/services/messaging_test.dart +++ b/test/services/messaging_test.dart @@ -18,18 +18,18 @@ class MockClient extends Mock implements Client { Map params = const {}, ResponseType? responseType, }) async { - return super.noSuchMethod( - Invocation.method(#call, [method]), - returnValue: Response(), - ); + return super.noSuchMethod(Invocation.method(#call, [method]), + returnValue: Response()); } @override - Future webAuth(Uri? url, {String? callbackUrlScheme}) async { - return super.noSuchMethod( - Invocation.method(#webAuth, [url]), - returnValue: 'done', - ); + Future webAuth( + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,74 +41,71 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method(#chunkedUpload, [ - path, - params, - paramName, - idParamName, - headers, - ]), - returnValue: Response(data: {}), - ); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Messaging test', () { - late MockClient client; - late Messaging messaging; + group('Messaging test', () { + late MockClient client; + late Messaging messaging; - setUp(() { - client = MockClient(); - messaging = Messaging(client); - }); + setUp(() { + client = MockClient(); + messaging = Messaging(client); + }); - test('test method createSubscriber()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'targetId': '259125845563242502', - 'target': { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'Apple iPhone 12', - 'userId': '259125845563242502', - 'providerType': 'email', - 'identifier': 'token', - 'expired': true, - }, - 'userId': '5e5ea5c16897e', - 'userName': 'Aegon Targaryen', - 'topicId': '259125845563242502', - 'providerType': 'email', - }; - - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); - - final response = await messaging.createSubscriber( - topicId: '', - subscriberId: '', - targetId: '', - ); - expect(response, isA()); - }); + test('test method createSubscriber()', () async { + + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'targetId': '259125845563242502', + 'target': { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Apple iPhone 12', + 'userId': '259125845563242502', + 'providerType': 'email', + 'identifier': 'token', + 'expired': true, + }, + 'userId': '5e5ea5c16897e', + 'userName': 'Aegon Targaryen', + 'topicId': '259125845563242502', + 'providerType': 'email',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.createSubscriber( + topicId: '', + subscriberId: '', + targetId: '', + ); + expect(response, isA()); + + }); + + test('test method deleteSubscriber()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - test('test method deleteSubscriber()', () async { - final data = ''; - when( - client.call(HttpMethod.delete), - ).thenAnswer((_) async => Response(data: data)); + final response = await messaging.deleteSubscriber( + topicId: '', + subscriberId: '', + ); + }); - final response = await messaging.deleteSubscriber( - topicId: '', - subscriberId: '', - ); }); - }); } diff --git a/test/services/presences_test.dart b/test/services/presences_test.dart index 02e8a8a7..7b99675f 100644 --- a/test/services/presences_test.dart +++ b/test/services/presences_test.dart @@ -18,18 +18,18 @@ class MockClient extends Mock implements Client { Map params = const {}, ResponseType? responseType, }) async { - return super.noSuchMethod( - Invocation.method(#call, [method]), - returnValue: Response(), - ); + return super.noSuchMethod(Invocation.method(#call, [method]), + returnValue: Response()); } @override - Future webAuth(Uri? url, {String? callbackUrlScheme}) async { - return super.noSuchMethod( - Invocation.method(#webAuth, [url]), - returnValue: 'done', - ); + Future webAuth( + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,105 +41,121 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method(#chunkedUpload, [ - path, - params, - paramName, - idParamName, - headers, - ]), - returnValue: Response(data: {}), - ); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Presences test', () { - late MockClient client; - late Presences presences; + group('Presences test', () { + late MockClient client; + late Presences presences; - setUp(() { - client = MockClient(); - presences = Presences(client); - }); + setUp(() { + client = MockClient(); + presences = Presences(client); + }); - test('test method list()', () async { - final Map data = {'total': 5, 'presences': []}; + test('test method list()', () async { - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + final Map data = { + 'total': 5, + 'presences': [],}; - final response = await presences.list(); - expect(response, isA()); - }); - test('test method get()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'userId': '674af8f3e12a5f9ac0be', - 'source': 'HTTP', - }; - - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); - - final response = await presences.get(presenceId: ''); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method upsert()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'userId': '674af8f3e12a5f9ac0be', - 'source': 'HTTP', - }; - - when( - client.call(HttpMethod.put), - ).thenAnswer((_) async => Response(data: data)); - - final response = await presences.upsert( - presenceId: '', - status: '', - ); - expect(response, isA()); - }); - test('test method update()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'userId': '674af8f3e12a5f9ac0be', - 'source': 'HTTP', - }; - - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); - - final response = await presences.update(presenceId: ''); - expect(response, isA()); - }); + final response = await presences.list( + ); + expect(response, isA()); + + }); + + test('test method get()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'userId': '674af8f3e12a5f9ac0be', + 'source': 'HTTP',}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await presences.get( + presenceId: '', + ); + expect(response, isA()); + + }); + + test('test method upsert()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'userId': '674af8f3e12a5f9ac0be', + 'source': 'HTTP',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await presences.upsert( + presenceId: '', + status: '', + ); + expect(response, isA()); + + }); + + test('test method update()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'userId': '674af8f3e12a5f9ac0be', + 'source': 'HTTP',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await presences.update( + presenceId: '', + ); + expect(response, isA()); + + }); + + test('test method delete()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - test('test method delete()', () async { - final data = ''; - when( - client.call(HttpMethod.delete), - ).thenAnswer((_) async => Response(data: data)); + final response = await presences.delete( + presenceId: '', + ); + }); - final response = await presences.delete(presenceId: ''); }); - }); } diff --git a/test/services/storage_test.dart b/test/services/storage_test.dart index 4326f3d0..2390bfdd 100644 --- a/test/services/storage_test.dart +++ b/test/services/storage_test.dart @@ -18,18 +18,18 @@ class MockClient extends Mock implements Client { Map params = const {}, ResponseType? responseType, }) async { - return super.noSuchMethod( - Invocation.method(#call, [method]), - returnValue: Response(), - ); + return super.noSuchMethod(Invocation.method(#call, [method]), + returnValue: Response()); } @override - Future webAuth(Uri? url, {String? callbackUrlScheme}) async { - return super.noSuchMethod( - Invocation.method(#webAuth, [url]), - returnValue: 'done', - ); + Future webAuth( + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,187 +41,202 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method(#chunkedUpload, [ - path, - params, - paramName, - idParamName, - headers, - ]), - returnValue: Response(data: {}), - ); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Storage test', () { - late MockClient client; - late Storage storage; + group('Storage test', () { + late MockClient client; + late Storage storage; + + setUp(() { + client = MockClient(); + storage = Storage(client); + }); + + test('test method listFiles()', () async { + + final Map data = { + 'total': 5, + 'files': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await storage.listFiles( + bucketId: '', + ); + expect(response, isA()); + + }); + + test('test method createFile()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + 'bucketId': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'name': 'Pink.png', + 'signature': '5d529fd02b544198ae075bd57c1762bb', + 'mimeType': 'image/png', + 'sizeOriginal': 17890, + 'sizeActual': 12345, + 'chunksTotal': 17890, + 'chunksUploaded': 17890, + 'encryption': true, + 'compression': 'gzip',}; + - setUp(() { - client = MockClient(); - storage = Storage(client); - }); + when(client.chunkedUpload( + path: argThat(isNotNull), + params: argThat(isNotNull), + paramName: argThat(isNotNull), + idParamName: argThat(isNotNull), + headers: argThat(isNotNull), + )).thenAnswer((_) async => Response(data: data)); - test('test method listFiles()', () async { - final Map data = {'total': 5, 'files': []}; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + final response = await storage.createFile( + bucketId: '', + fileId: '', + file: InputFile.fromPath(path: './image.png'), + ); + expect(response, isA()); + + }); - final response = await storage.listFiles(bucketId: ''); - expect(response, isA()); - }); + test('test method getFile()', () async { - test('test method createFile()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - 'bucketId': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'name': 'Pink.png', - 'signature': '5d529fd02b544198ae075bd57c1762bb', - 'mimeType': 'image/png', - 'sizeOriginal': 17890, - 'sizeActual': 12345, - 'chunksTotal': 17890, - 'chunksUploaded': 17890, - 'encryption': true, - 'compression': 'gzip', - }; - - when( - client.chunkedUpload( - path: argThat(isNotNull), - params: argThat(isNotNull), - paramName: argThat(isNotNull), - idParamName: argThat(isNotNull), - headers: argThat(isNotNull), - ), - ).thenAnswer((_) async => Response(data: data)); - - final response = await storage.createFile( - bucketId: '', - fileId: '', - file: InputFile.fromPath(path: './image.png'), - ); - expect(response, isA()); - }); + final Map data = { + '\$id': '5e5ea5c16897e', + 'bucketId': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'name': 'Pink.png', + 'signature': '5d529fd02b544198ae075bd57c1762bb', + 'mimeType': 'image/png', + 'sizeOriginal': 17890, + 'sizeActual': 12345, + 'chunksTotal': 17890, + 'chunksUploaded': 17890, + 'encryption': true, + 'compression': 'gzip',}; - test('test method getFile()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - 'bucketId': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'name': 'Pink.png', - 'signature': '5d529fd02b544198ae075bd57c1762bb', - 'mimeType': 'image/png', - 'sizeOriginal': 17890, - 'sizeActual': 12345, - 'chunksTotal': 17890, - 'chunksUploaded': 17890, - 'encryption': true, - 'compression': 'gzip', - }; - - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); - - final response = await storage.getFile( - bucketId: '', - fileId: '', - ); - expect(response, isA()); - }); - test('test method updateFile()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - 'bucketId': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'name': 'Pink.png', - 'signature': '5d529fd02b544198ae075bd57c1762bb', - 'mimeType': 'image/png', - 'sizeOriginal': 17890, - 'sizeActual': 12345, - 'chunksTotal': 17890, - 'chunksUploaded': 17890, - 'encryption': true, - 'compression': 'gzip', - }; - - when( - client.call(HttpMethod.put), - ).thenAnswer((_) async => Response(data: data)); - - final response = await storage.updateFile( - bucketId: '', - fileId: '', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method deleteFile()', () async { - final data = ''; - when( - client.call(HttpMethod.delete), - ).thenAnswer((_) async => Response(data: data)); + final response = await storage.getFile( + bucketId: '', + fileId: '', + ); + expect(response, isA()); - final response = await storage.deleteFile( - bucketId: '', - fileId: '', - ); - }); + }); - test('test method getFileDownload()', () async { - final Uint8List data = Uint8List.fromList([]); + test('test method updateFile()', () async { - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + final Map data = { + '\$id': '5e5ea5c16897e', + 'bucketId': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'name': 'Pink.png', + 'signature': '5d529fd02b544198ae075bd57c1762bb', + 'mimeType': 'image/png', + 'sizeOriginal': 17890, + 'sizeActual': 12345, + 'chunksTotal': 17890, + 'chunksUploaded': 17890, + 'encryption': true, + 'compression': 'gzip',}; - final response = await storage.getFileDownload( - bucketId: '', - fileId: '', - ); - expect(response, isA()); - }); - test('test method getFilePreview()', () async { - final Uint8List data = Uint8List.fromList([]); + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); - final response = await storage.getFilePreview( - bucketId: '', - fileId: '', - ); - expect(response, isA()); - }); + final response = await storage.updateFile( + bucketId: '', + fileId: '', + ); + expect(response, isA()); + + }); + + test('test method deleteFile()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await storage.deleteFile( + bucketId: '', + fileId: '', + ); + }); + + test('test method getFileDownload()', () async { +final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await storage.getFileDownload( + bucketId: '', + fileId: '', + ); + expect(response, isA()); + + }); + + test('test method getFilePreview()', () async { +final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await storage.getFilePreview( + bucketId: '', + fileId: '', + ); + expect(response, isA()); + + }); + + test('test method getFileView()', () async { +final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + - test('test method getFileView()', () async { - final Uint8List data = Uint8List.fromList([]); + final response = await storage.getFileView( + bucketId: '', + fileId: '', + ); + expect(response, isA()); - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + }); - final response = await storage.getFileView( - bucketId: '', - fileId: '', - ); - expect(response, isA()); }); - }); } diff --git a/test/services/tables_db_test.dart b/test/services/tables_db_test.dart index 935db401..5219d2bf 100644 --- a/test/services/tables_db_test.dart +++ b/test/services/tables_db_test.dart @@ -18,18 +18,18 @@ class MockClient extends Mock implements Client { Map params = const {}, ResponseType? responseType, }) async { - return super.noSuchMethod( - Invocation.method(#call, [method]), - returnValue: Response(), - ); + return super.noSuchMethod(Invocation.method(#call, [method]), + returnValue: Response()); } @override - Future webAuth(Uri? url, {String? callbackUrlScheme}) async { - return super.noSuchMethod( - Invocation.method(#webAuth, [url]), - returnValue: 'done', - ); + Future webAuth( + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,297 +41,337 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method(#chunkedUpload, [ - path, - params, - paramName, - idParamName, - headers, - ]), - returnValue: Response(data: {}), - ); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('TablesDB test', () { - late MockClient client; - late TablesDB tablesDB; + group('TablesDB test', () { + late MockClient client; + late TablesDB tablesDB; - setUp(() { - client = MockClient(); - tablesDB = TablesDB(client); - }); + setUp(() { + client = MockClient(); + tablesDB = TablesDB(client); + }); - test('test method listTransactions()', () async { - final Map data = {'total': 5, 'transactions': []}; + test('test method listTransactions()', () async { - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + final Map data = { + 'total': 5, + 'transactions': [],}; - final response = await tablesDB.listTransactions(); - expect(response, isA()); - }); - test('test method createTransaction()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', - }; - - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.createTransaction(); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method getTransaction()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', - }; - - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.getTransaction( - transactionId: '', - ); - expect(response, isA()); - }); - test('test method updateTransaction()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', - }; - - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.updateTransaction( - transactionId: '', - ); - expect(response, isA()); - }); + final response = await tablesDB.listTransactions( + ); + expect(response, isA()); - test('test method deleteTransaction()', () async { - final data = ''; + }); - when( - client.call(HttpMethod.delete), - ).thenAnswer((_) async => Response(data: data)); + test('test method createTransaction()', () async { - final response = await tablesDB.deleteTransaction( - transactionId: '', - ); - }); + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - test('test method createOperations()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', - }; - - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.createOperations( - transactionId: '', - ); - expect(response, isA()); - }); - test('test method listRows()', () async { - final Map data = {'total': 5, 'rows': []}; + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); - final response = await tablesDB.listRows( - databaseId: '', - tableId: '', - ); - expect(response, isA()); - }); + final response = await tablesDB.createTransaction( + ); + expect(response, isA()); - test('test method createRow()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.createRow( - databaseId: '', - tableId: '', - rowId: '', - data: {}, - ); - expect(response, isA()); - }); + }); - test('test method getRow()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.getRow( - databaseId: '', - tableId: '', - rowId: '', - ); - expect(response, isA()); - }); + test('test method getTransaction()', () async { - test('test method upsertRow()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when( - client.call(HttpMethod.put), - ).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.upsertRow( - databaseId: '', - tableId: '', - rowId: '', - ); - expect(response, isA()); - }); + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - test('test method updateRow()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.updateRow( - databaseId: '', - tableId: '', - rowId: '', - ); - expect(response, isA()); - }); - test('test method deleteRow()', () async { - final data = ''; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when( - client.call(HttpMethod.delete), - ).thenAnswer((_) async => Response(data: data)); - final response = await tablesDB.deleteRow( - databaseId: '', - tableId: '', - rowId: '', - ); - }); + final response = await tablesDB.getTransaction( + transactionId: '', + ); + expect(response, isA()); - test('test method decrementRowColumn()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.decrementRowColumn( - databaseId: '', - tableId: '', - rowId: '', - column: '', - ); - expect(response, isA()); - }); + }); + + test('test method updateTransaction()', () async { + + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.updateTransaction( + transactionId: '', + ); + expect(response, isA()); + + }); + + test('test method deleteTransaction()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.deleteTransaction( + transactionId: '', + ); + }); + + test('test method createOperations()', () async { + + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.createOperations( + transactionId: '', + ); + expect(response, isA()); + + }); + + test('test method listRows()', () async { + + final Map data = { + 'total': 5, + 'rows': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.listRows( + databaseId: '', + tableId: '', + ); + expect(response, isA()); + + }); + + test('test method createRow()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.createRow( + databaseId: '', + tableId: '', + rowId: '', + data: {}, + ); + expect(response, isA()); + + }); + + test('test method getRow()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.getRow( + databaseId: '', + tableId: '', + rowId: '', + ); + expect(response, isA()); + + }); + + test('test method upsertRow()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.upsertRow( + databaseId: '', + tableId: '', + rowId: '', + ); + expect(response, isA()); + + }); + + test('test method updateRow()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.updateRow( + databaseId: '', + tableId: '', + rowId: '', + ); + expect(response, isA()); + + }); + + test('test method deleteRow()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.deleteRow( + databaseId: '', + tableId: '', + rowId: '', + ); + }); + + test('test method decrementRowColumn()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.decrementRowColumn( + databaseId: '', + tableId: '', + rowId: '', + column: '', + ); + expect(response, isA()); + + }); + + test('test method incrementRowColumn()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.incrementRowColumn( + databaseId: '', + tableId: '', + rowId: '', + column: '', + ); + expect(response, isA()); + + }); - test('test method incrementRowColumn()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.incrementRowColumn( - databaseId: '', - tableId: '', - rowId: '', - column: '', - ); - expect(response, isA()); }); - }); } diff --git a/test/services/teams_test.dart b/test/services/teams_test.dart index 30fcc639..ea72a432 100644 --- a/test/services/teams_test.dart +++ b/test/services/teams_test.dart @@ -18,18 +18,18 @@ class MockClient extends Mock implements Client { Map params = const {}, ResponseType? responseType, }) async { - return super.noSuchMethod( - Invocation.method(#call, [method]), - returnValue: Response(), - ); + return super.noSuchMethod(Invocation.method(#call, [method]), + returnValue: Response()); } @override - Future webAuth(Uri? url, {String? callbackUrlScheme}) async { - return super.noSuchMethod( - Invocation.method(#webAuth, [url]), - returnValue: 'done', - ); + Future webAuth( + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,274 +41,326 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method(#chunkedUpload, [ - path, - params, - paramName, - idParamName, - headers, - ]), - returnValue: Response(data: {}), - ); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Teams test', () { - late MockClient client; - late Teams teams; + group('Teams test', () { + late MockClient client; + late Teams teams; - setUp(() { - client = MockClient(); - teams = Teams(client); - }); + setUp(() { + client = MockClient(); + teams = Teams(client); + }); - test('test method list()', () async { - final Map data = {'total': 5, 'teams': []}; + test('test method list()', () async { - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + final Map data = { + 'total': 5, + 'teams': [],}; - final response = await teams.list(); - expect(response, isA()); - }); - test('test method create()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'VIP', - 'total': 7, - 'prefs': {}, - }; - - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); - - final response = await teams.create(teamId: '', name: ''); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method get()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'VIP', - 'total': 7, - 'prefs': {}, - }; - - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); - - final response = await teams.get(teamId: ''); - expect(response, isA()); - }); - test('test method updateName()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'VIP', - 'total': 7, - 'prefs': {}, - }; - - when( - client.call(HttpMethod.put), - ).thenAnswer((_) async => Response(data: data)); - - final response = await teams.updateName( - teamId: '', - name: '', - ); - expect(response, isA()); - }); + final response = await teams.list( + ); + expect(response, isA()); - test('test method delete()', () async { - final data = ''; + }); - when( - client.call(HttpMethod.delete), - ).thenAnswer((_) async => Response(data: data)); + test('test method create()', () async { - final response = await teams.delete(teamId: ''); - }); + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'VIP', + 'total': 7, + 'prefs': {},}; - test('test method listMemberships()', () async { - final Map data = {'total': 5, 'memberships': []}; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - final response = await teams.listMemberships(teamId: ''); - expect(response, isA()); - }); - test('test method createMembership()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [], - }; - - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); - - final response = await teams.createMembership( - teamId: '', - roles: [], - ); - expect(response, isA()); - }); + final response = await teams.create( + teamId: '', + name: '', + ); + expect(response, isA()); - test('test method getMembership()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [], - }; - - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); - - final response = await teams.getMembership( - teamId: '', - membershipId: '', - ); - expect(response, isA()); - }); + }); - test('test method updateMembership()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [], - }; - - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); - - final response = await teams.updateMembership( - teamId: '', - membershipId: '', - roles: [], - ); - expect(response, isA()); - }); + test('test method get()', () async { - test('test method deleteMembership()', () async { - final data = ''; + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'VIP', + 'total': 7, + 'prefs': {},}; - when( - client.call(HttpMethod.delete), - ).thenAnswer((_) async => Response(data: data)); - final response = await teams.deleteMembership( - teamId: '', - membershipId: '', - ); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method updateMembershipStatus()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [], - }; - - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); - - final response = await teams.updateMembershipStatus( - teamId: '', - membershipId: '', - userId: '', - secret: '', - ); - expect(response, isA()); - }); - test('test method getPrefs()', () async { - final Map data = {}; + final response = await teams.get( + teamId: '', + ); + expect(response, isA()); - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + }); + + test('test method updateName()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'VIP', + 'total': 7, + 'prefs': {},}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.updateName( + teamId: '', + name: '', + ); + expect(response, isA()); + + }); + + test('test method delete()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.delete( + teamId: '', + ); + }); + + test('test method listMemberships()', () async { + + final Map data = { + 'total': 5, + 'memberships': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.listMemberships( + teamId: '', + ); + expect(response, isA()); + + }); + + test('test method createMembership()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'userPhone': '+1 555 555 5555', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'roles': [],}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.createMembership( + teamId: '', + roles: [], + ); + expect(response, isA()); + + }); + + test('test method getMembership()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'userPhone': '+1 555 555 5555', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'roles': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.getMembership( + teamId: '', + membershipId: '', + ); + expect(response, isA()); + + }); + + test('test method updateMembership()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'userPhone': '+1 555 555 5555', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'roles': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.updateMembership( + teamId: '', + membershipId: '', + roles: [], + ); + expect(response, isA()); + + }); + + test('test method deleteMembership()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.deleteMembership( + teamId: '', + membershipId: '', + ); + }); + + test('test method updateMembershipStatus()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'userPhone': '+1 555 555 5555', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'roles': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.updateMembershipStatus( + teamId: '', + membershipId: '', + userId: '', + secret: '', + ); + expect(response, isA()); + + }); + + test('test method getPrefs()', () async { + + final Map data = {}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.getPrefs( + teamId: '', + ); + expect(response, isA()); + + }); + + test('test method updatePrefs()', () async { + + final Map data = {}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); - final response = await teams.getPrefs(teamId: ''); - expect(response, isA()); - }); - test('test method updatePrefs()', () async { - final Map data = {}; + final response = await teams.updatePrefs( + teamId: '', + prefs: {}, + ); + expect(response, isA()); - when( - client.call(HttpMethod.put), - ).thenAnswer((_) async => Response(data: data)); + }); - final response = await teams.updatePrefs(teamId: '', prefs: {}); - expect(response, isA()); }); - }); } diff --git a/test/src/cookie_manager_test.dart b/test/src/cookie_manager_test.dart index b20f6ff1..c6343f72 100644 --- a/test/src/cookie_manager_test.dart +++ b/test/src/cookie_manager_test.dart @@ -11,7 +11,10 @@ void main() { Cookie('name2', 'value2'), ]; - expect(CookieManager.getCookies(cookies), "name=value; name2=value2"); + expect( + CookieManager.getCookies(cookies), + "name=value; name2=value2", + ); }); }); @@ -32,12 +35,17 @@ void main() { test('with cookie', () async { final uri = Uri.parse('https://appwrite.io'); - final cookies = [Cookie('name', 'value'), Cookie('name2', 'value2')]; + final cookies = [ + Cookie('name', 'value'), + Cookie('name2', 'value2'), + ]; cookieJar.saveFromResponse(uri, cookies); final request = Request('GET', uri); await cookieManager.onRequest(request); - expect(request.headers, {'cookie': 'name=value; name2=value2'}); + expect(request.headers, { + 'cookie': 'name=value; name2=value2', + }); }); }); @@ -53,7 +61,12 @@ void main() { test('without cookie', () async { final uri = Uri.parse('https://appwrite.io'); final request = Request('POST', uri); - final response = Response('body', 200, headers: {}, request: request); + final response = Response( + 'body', + 200, + headers: {}, + request: request, + ); await cookieManager.onResponse(response); @@ -68,7 +81,9 @@ void main() { final response = Response( 'body', 200, - headers: {'set-cookie': 'name=value'}, + headers: { + 'set-cookie': 'name=value', + }, request: request, ); diff --git a/test/src/exception_test.dart b/test/src/exception_test.dart index 10db5745..c3de9fcb 100644 --- a/test/src/exception_test.dart +++ b/test/src/exception_test.dart @@ -20,7 +20,9 @@ void main() { ); expect( exception3.toString(), - equals('AppwriteException: ValidationError, Invalid request (400)'), + equals( + 'AppwriteException: ValidationError, Invalid request (400)', + ), ); }); }); diff --git a/test/src/input_file_test.dart b/test/src/input_file_test.dart index 046fa07b..3d301a85 100644 --- a/test/src/input_file_test.dart +++ b/test/src/input_file_test.dart @@ -7,26 +7,22 @@ void main() { test('throws exception when neither path nor bytes are provided', () { expect( () => InputFile(), - throwsA( - isA().having( - (e) => e.message, - 'message', - 'One of `path` or `bytes` is required', - ), - ), + throwsA(isA().having( + (e) => e.message, + 'message', + 'One of `path` or `bytes` is required', + )), ); }); test('throws exception when path and bytes are both null', () { expect( () => InputFile(path: null, bytes: null), - throwsA( - isA().having( - (e) => e.message, - 'message', - 'One of `path` or `bytes` is required', - ), - ), + throwsA(isA().having( + (e) => e.message, + 'message', + 'One of `path` or `bytes` is required', + )), ); }); diff --git a/test/src/models/algo_argon2_test.dart b/test/src/models/algo_argon2_test.dart index 261daa46..15e85f5a 100644 --- a/test/src/models/algo_argon2_test.dart +++ b/test/src/models/algo_argon2_test.dart @@ -14,10 +14,10 @@ void main() { final map = model.toMap(); final result = AlgoArgon2.fromMap(map); - expect(result.type, 'argon2'); - expect(result.memoryCost, 65536); - expect(result.timeCost, 4); - expect(result.threads, 3); - }); + expect(result.type, 'argon2'); + expect(result.memoryCost, 65536); + expect(result.timeCost, 4); + expect(result.threads, 3); + }); }); } diff --git a/test/src/models/algo_bcrypt_test.dart b/test/src/models/algo_bcrypt_test.dart index 949502ca..87a3ca3c 100644 --- a/test/src/models/algo_bcrypt_test.dart +++ b/test/src/models/algo_bcrypt_test.dart @@ -4,12 +4,14 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('AlgoBcrypt', () { test('model', () { - final model = AlgoBcrypt(type: 'bcrypt'); + final model = AlgoBcrypt( + type: 'bcrypt', + ); final map = model.toMap(); final result = AlgoBcrypt.fromMap(map); - expect(result.type, 'bcrypt'); - }); + expect(result.type, 'bcrypt'); + }); }); } diff --git a/test/src/models/algo_md5_test.dart b/test/src/models/algo_md5_test.dart index bfeb1de2..3b842e6c 100644 --- a/test/src/models/algo_md5_test.dart +++ b/test/src/models/algo_md5_test.dart @@ -4,12 +4,14 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('AlgoMd5', () { test('model', () { - final model = AlgoMd5(type: 'md5'); + final model = AlgoMd5( + type: 'md5', + ); final map = model.toMap(); final result = AlgoMd5.fromMap(map); - expect(result.type, 'md5'); - }); + expect(result.type, 'md5'); + }); }); } diff --git a/test/src/models/algo_phpass_test.dart b/test/src/models/algo_phpass_test.dart index 0141ca54..49b1e22c 100644 --- a/test/src/models/algo_phpass_test.dart +++ b/test/src/models/algo_phpass_test.dart @@ -4,12 +4,14 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('AlgoPhpass', () { test('model', () { - final model = AlgoPhpass(type: 'phpass'); + final model = AlgoPhpass( + type: 'phpass', + ); final map = model.toMap(); final result = AlgoPhpass.fromMap(map); - expect(result.type, 'phpass'); - }); + expect(result.type, 'phpass'); + }); }); } diff --git a/test/src/models/algo_scrypt_modified_test.dart b/test/src/models/algo_scrypt_modified_test.dart index 0103ed60..dd7fa8c3 100644 --- a/test/src/models/algo_scrypt_modified_test.dart +++ b/test/src/models/algo_scrypt_modified_test.dart @@ -8,20 +8,16 @@ void main() { type: 'scryptMod', salt: 'UxLMreBr6tYyjQ==', saltSeparator: 'Bw==', - signerKey: - 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ==', + signerKey: 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ==', ); final map = model.toMap(); final result = AlgoScryptModified.fromMap(map); - expect(result.type, 'scryptMod'); - expect(result.salt, 'UxLMreBr6tYyjQ=='); - expect(result.saltSeparator, 'Bw=='); - expect( - result.signerKey, - 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ==', - ); - }); + expect(result.type, 'scryptMod'); + expect(result.salt, 'UxLMreBr6tYyjQ=='); + expect(result.saltSeparator, 'Bw=='); + expect(result.signerKey, 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ=='); + }); }); } diff --git a/test/src/models/algo_scrypt_test.dart b/test/src/models/algo_scrypt_test.dart index 8c131568..c7d9cdbf 100644 --- a/test/src/models/algo_scrypt_test.dart +++ b/test/src/models/algo_scrypt_test.dart @@ -15,11 +15,11 @@ void main() { final map = model.toMap(); final result = AlgoScrypt.fromMap(map); - expect(result.type, 'scrypt'); - expect(result.costCpu, 8); - expect(result.costMemory, 14); - expect(result.costParallel, 1); - expect(result.length, 64); - }); + expect(result.type, 'scrypt'); + expect(result.costCpu, 8); + expect(result.costMemory, 14); + expect(result.costParallel, 1); + expect(result.length, 64); + }); }); } diff --git a/test/src/models/algo_sha_test.dart b/test/src/models/algo_sha_test.dart index 205ab2d3..ae58b57e 100644 --- a/test/src/models/algo_sha_test.dart +++ b/test/src/models/algo_sha_test.dart @@ -4,12 +4,14 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('AlgoSha', () { test('model', () { - final model = AlgoSha(type: 'sha'); + final model = AlgoSha( + type: 'sha', + ); final map = model.toMap(); final result = AlgoSha.fromMap(map); - expect(result.type, 'sha'); - }); + expect(result.type, 'sha'); + }); }); } diff --git a/test/src/models/continent_list_test.dart b/test/src/models/continent_list_test.dart index b12c806b..8de695b0 100644 --- a/test/src/models/continent_list_test.dart +++ b/test/src/models/continent_list_test.dart @@ -4,13 +4,16 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('ContinentList', () { test('model', () { - final model = ContinentList(total: 5, continents: []); + final model = ContinentList( + total: 5, + continents: [], + ); final map = model.toMap(); final result = ContinentList.fromMap(map); - expect(result.total, 5); - expect(result.continents, []); - }); + expect(result.total, 5); + expect(result.continents, []); + }); }); } diff --git a/test/src/models/continent_test.dart b/test/src/models/continent_test.dart index e8afc544..d5242a4e 100644 --- a/test/src/models/continent_test.dart +++ b/test/src/models/continent_test.dart @@ -4,13 +4,16 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('Continent', () { test('model', () { - final model = Continent(name: 'Europe', code: 'EU'); + final model = Continent( + name: 'Europe', + code: 'EU', + ); final map = model.toMap(); final result = Continent.fromMap(map); - expect(result.name, 'Europe'); - expect(result.code, 'EU'); - }); + expect(result.name, 'Europe'); + expect(result.code, 'EU'); + }); }); } diff --git a/test/src/models/country_list_test.dart b/test/src/models/country_list_test.dart index 42736ba9..869f5db6 100644 --- a/test/src/models/country_list_test.dart +++ b/test/src/models/country_list_test.dart @@ -4,13 +4,16 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('CountryList', () { test('model', () { - final model = CountryList(total: 5, countries: []); + final model = CountryList( + total: 5, + countries: [], + ); final map = model.toMap(); final result = CountryList.fromMap(map); - expect(result.total, 5); - expect(result.countries, []); - }); + expect(result.total, 5); + expect(result.countries, []); + }); }); } diff --git a/test/src/models/country_test.dart b/test/src/models/country_test.dart index 1fe85efe..bc66ab7b 100644 --- a/test/src/models/country_test.dart +++ b/test/src/models/country_test.dart @@ -4,13 +4,16 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('Country', () { test('model', () { - final model = Country(name: 'United States', code: 'US'); + final model = Country( + name: 'United States', + code: 'US', + ); final map = model.toMap(); final result = Country.fromMap(map); - expect(result.name, 'United States'); - expect(result.code, 'US'); - }); + expect(result.name, 'United States'); + expect(result.code, 'US'); + }); }); } diff --git a/test/src/models/currency_list_test.dart b/test/src/models/currency_list_test.dart index d110e0e9..09da675c 100644 --- a/test/src/models/currency_list_test.dart +++ b/test/src/models/currency_list_test.dart @@ -4,13 +4,16 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('CurrencyList', () { test('model', () { - final model = CurrencyList(total: 5, currencies: []); + final model = CurrencyList( + total: 5, + currencies: [], + ); final map = model.toMap(); final result = CurrencyList.fromMap(map); - expect(result.total, 5); - expect(result.currencies, []); - }); + expect(result.total, 5); + expect(result.currencies, []); + }); }); } diff --git a/test/src/models/currency_test.dart b/test/src/models/currency_test.dart index 00e046c7..29890008 100644 --- a/test/src/models/currency_test.dart +++ b/test/src/models/currency_test.dart @@ -17,13 +17,13 @@ void main() { final map = model.toMap(); final result = Currency.fromMap(map); - expect(result.symbol, '\$'); - expect(result.name, 'US dollar'); - expect(result.symbolNative, '\$'); - expect(result.decimalDigits, 2); - expect(result.rounding, 0); - expect(result.code, 'USD'); - expect(result.namePlural, 'US dollars'); - }); + expect(result.symbol, '\$'); + expect(result.name, 'US dollar'); + expect(result.symbolNative, '\$'); + expect(result.decimalDigits, 2); + expect(result.rounding, 0); + expect(result.code, 'USD'); + expect(result.namePlural, 'US dollars'); + }); }); } diff --git a/test/src/models/document_list_test.dart b/test/src/models/document_list_test.dart index 4cb4a66a..f1a5b3cc 100644 --- a/test/src/models/document_list_test.dart +++ b/test/src/models/document_list_test.dart @@ -4,13 +4,16 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('DocumentList', () { test('model', () { - final model = DocumentList(total: 5, documents: []); + final model = DocumentList( + total: 5, + documents: [], + ); final map = model.toMap(); final result = DocumentList.fromMap(map); - expect(result.total, 5); - expect(result.documents, []); - }); + expect(result.total, 5); + expect(result.documents, []); + }); }); } diff --git a/test/src/models/document_test.dart b/test/src/models/document_test.dart index 397b5fab..6c1fbb77 100644 --- a/test/src/models/document_test.dart +++ b/test/src/models/document_test.dart @@ -18,13 +18,13 @@ void main() { final map = model.toMap(); final result = Document.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$sequence, '1'); - expect(result.$collectionId, '5e5ea5c15117e'); - expect(result.$databaseId, '5e5ea5c15117e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$sequence, '1'); + expect(result.$collectionId, '5e5ea5c15117e'); + expect(result.$databaseId, '5e5ea5c15117e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + }); }); } diff --git a/test/src/models/execution_list_test.dart b/test/src/models/execution_list_test.dart index 32b82cb9..fe74af58 100644 --- a/test/src/models/execution_list_test.dart +++ b/test/src/models/execution_list_test.dart @@ -4,13 +4,16 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('ExecutionList', () { test('model', () { - final model = ExecutionList(total: 5, executions: []); + final model = ExecutionList( + total: 5, + executions: [], + ); final map = model.toMap(); final result = ExecutionList.fromMap(map); - expect(result.total, 5); - expect(result.executions, []); - }); + expect(result.total, 5); + expect(result.executions, []); + }); }); } diff --git a/test/src/models/execution_test.dart b/test/src/models/execution_test.dart index 80ef508a..6d9bf33c 100644 --- a/test/src/models/execution_test.dart +++ b/test/src/models/execution_test.dart @@ -28,23 +28,23 @@ void main() { final map = model.toMap(); final result = Execution.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - expect(result.functionId, '5e5ea6g16897e'); - expect(result.deploymentId, '5e5ea5c16897e'); - expect(result.trigger, ExecutionTrigger.http); - expect(result.status, ExecutionStatus.waiting); - expect(result.requestMethod, 'GET'); - expect(result.requestPath, '/articles?id=5'); - expect(result.requestHeaders, []); - expect(result.responseStatusCode, 200); - expect(result.responseBody, ''); - expect(result.responseHeaders, []); - expect(result.logs, ''); - expect(result.errors, ''); - expect(result.duration, 0.4); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + expect(result.functionId, '5e5ea6g16897e'); + expect(result.deploymentId, '5e5ea5c16897e'); + expect(result.trigger, ExecutionTrigger.http); + expect(result.status, ExecutionStatus.waiting); + expect(result.requestMethod, 'GET'); + expect(result.requestPath, '/articles?id=5'); + expect(result.requestHeaders, []); + expect(result.responseStatusCode, 200); + expect(result.responseBody, ''); + expect(result.responseHeaders, []); + expect(result.logs, ''); + expect(result.errors, ''); + expect(result.duration, 0.4); + }); }); } diff --git a/test/src/models/file_list_test.dart b/test/src/models/file_list_test.dart index 5761b36a..d8e6c95c 100644 --- a/test/src/models/file_list_test.dart +++ b/test/src/models/file_list_test.dart @@ -4,13 +4,16 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('FileList', () { test('model', () { - final model = FileList(total: 5, files: []); + final model = FileList( + total: 5, + files: [], + ); final map = model.toMap(); final result = FileList.fromMap(map); - expect(result.total, 5); - expect(result.files, []); - }); + expect(result.total, 5); + expect(result.files, []); + }); }); } diff --git a/test/src/models/file_test.dart b/test/src/models/file_test.dart index 7f132646..8a734a08 100644 --- a/test/src/models/file_test.dart +++ b/test/src/models/file_test.dart @@ -24,20 +24,20 @@ void main() { final map = model.toMap(); final result = File.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.bucketId, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - expect(result.name, 'Pink.png'); - expect(result.signature, '5d529fd02b544198ae075bd57c1762bb'); - expect(result.mimeType, 'image/png'); - expect(result.sizeOriginal, 17890); - expect(result.sizeActual, 12345); - expect(result.chunksTotal, 17890); - expect(result.chunksUploaded, 17890); - expect(result.encryption, true); - expect(result.compression, 'gzip'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.bucketId, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + expect(result.name, 'Pink.png'); + expect(result.signature, '5d529fd02b544198ae075bd57c1762bb'); + expect(result.mimeType, 'image/png'); + expect(result.sizeOriginal, 17890); + expect(result.sizeActual, 12345); + expect(result.chunksTotal, 17890); + expect(result.chunksUploaded, 17890); + expect(result.encryption, true); + expect(result.compression, 'gzip'); + }); }); } diff --git a/test/src/models/headers_test.dart b/test/src/models/headers_test.dart index 1c36d21a..489891d4 100644 --- a/test/src/models/headers_test.dart +++ b/test/src/models/headers_test.dart @@ -4,13 +4,16 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('Headers', () { test('model', () { - final model = Headers(name: 'Content-Type', value: 'application/json'); + final model = Headers( + name: 'Content-Type', + value: 'application/json', + ); final map = model.toMap(); final result = Headers.fromMap(map); - expect(result.name, 'Content-Type'); - expect(result.value, 'application/json'); - }); + expect(result.name, 'Content-Type'); + expect(result.value, 'application/json'); + }); }); } diff --git a/test/src/models/identity_list_test.dart b/test/src/models/identity_list_test.dart index f8078db9..65f562a7 100644 --- a/test/src/models/identity_list_test.dart +++ b/test/src/models/identity_list_test.dart @@ -4,13 +4,16 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('IdentityList', () { test('model', () { - final model = IdentityList(total: 5, identities: []); + final model = IdentityList( + total: 5, + identities: [], + ); final map = model.toMap(); final result = IdentityList.fromMap(map); - expect(result.total, 5); - expect(result.identities, []); - }); + expect(result.total, 5); + expect(result.identities, []); + }); }); } diff --git a/test/src/models/identity_test.dart b/test/src/models/identity_test.dart index 525af4ea..708c8c60 100644 --- a/test/src/models/identity_test.dart +++ b/test/src/models/identity_test.dart @@ -20,16 +20,16 @@ void main() { final map = model.toMap(); final result = Identity.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5bb8c16897e'); - expect(result.provider, 'email'); - expect(result.providerUid, '5e5bb8c16897e'); - expect(result.providerEmail, 'user@example.com'); - expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); - expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5bb8c16897e'); + expect(result.provider, 'email'); + expect(result.providerUid, '5e5bb8c16897e'); + expect(result.providerEmail, 'user@example.com'); + expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); + expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + }); }); } diff --git a/test/src/models/jwt_test.dart b/test/src/models/jwt_test.dart index c2166441..e616a956 100644 --- a/test/src/models/jwt_test.dart +++ b/test/src/models/jwt_test.dart @@ -5,17 +5,13 @@ void main() { group('Jwt', () { test('model', () { final model = Jwt( - jwt: - 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', + jwt: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', ); final map = model.toMap(); final result = Jwt.fromMap(map); - expect( - result.jwt, - 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', - ); - }); + expect(result.jwt, 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'); + }); }); } diff --git a/test/src/models/language_list_test.dart b/test/src/models/language_list_test.dart index 919fd9d1..94c1e33f 100644 --- a/test/src/models/language_list_test.dart +++ b/test/src/models/language_list_test.dart @@ -4,13 +4,16 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('LanguageList', () { test('model', () { - final model = LanguageList(total: 5, languages: []); + final model = LanguageList( + total: 5, + languages: [], + ); final map = model.toMap(); final result = LanguageList.fromMap(map); - expect(result.total, 5); - expect(result.languages, []); - }); + expect(result.total, 5); + expect(result.languages, []); + }); }); } diff --git a/test/src/models/language_test.dart b/test/src/models/language_test.dart index 4a6c96c1..d4087d5e 100644 --- a/test/src/models/language_test.dart +++ b/test/src/models/language_test.dart @@ -13,9 +13,9 @@ void main() { final map = model.toMap(); final result = Language.fromMap(map); - expect(result.name, 'Italian'); - expect(result.code, 'it'); - expect(result.nativeName, 'Italiano'); - }); + expect(result.name, 'Italian'); + expect(result.code, 'it'); + expect(result.nativeName, 'Italiano'); + }); }); } diff --git a/test/src/models/locale_code_list_test.dart b/test/src/models/locale_code_list_test.dart index 8896c83d..b6de5137 100644 --- a/test/src/models/locale_code_list_test.dart +++ b/test/src/models/locale_code_list_test.dart @@ -4,13 +4,16 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('LocaleCodeList', () { test('model', () { - final model = LocaleCodeList(total: 5, localeCodes: []); + final model = LocaleCodeList( + total: 5, + localeCodes: [], + ); final map = model.toMap(); final result = LocaleCodeList.fromMap(map); - expect(result.total, 5); - expect(result.localeCodes, []); - }); + expect(result.total, 5); + expect(result.localeCodes, []); + }); }); } diff --git a/test/src/models/locale_code_test.dart b/test/src/models/locale_code_test.dart index 831c4a17..f0fcdbce 100644 --- a/test/src/models/locale_code_test.dart +++ b/test/src/models/locale_code_test.dart @@ -4,13 +4,16 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('LocaleCode', () { test('model', () { - final model = LocaleCode(code: 'en-us', name: 'US'); + final model = LocaleCode( + code: 'en-us', + name: 'US', + ); final map = model.toMap(); final result = LocaleCode.fromMap(map); - expect(result.code, 'en-us'); - expect(result.name, 'US'); - }); + expect(result.code, 'en-us'); + expect(result.name, 'US'); + }); }); } diff --git a/test/src/models/locale_test.dart b/test/src/models/locale_test.dart index 49cb1fc9..72102045 100644 --- a/test/src/models/locale_test.dart +++ b/test/src/models/locale_test.dart @@ -17,13 +17,13 @@ void main() { final map = model.toMap(); final result = Locale.fromMap(map); - expect(result.ip, '127.0.0.1'); - expect(result.countryCode, 'US'); - expect(result.country, 'United States'); - expect(result.continentCode, 'NA'); - expect(result.continent, 'North America'); - expect(result.eu, true); - expect(result.currency, 'USD'); - }); + expect(result.ip, '127.0.0.1'); + expect(result.countryCode, 'US'); + expect(result.country, 'United States'); + expect(result.continentCode, 'NA'); + expect(result.continent, 'North America'); + expect(result.eu, true); + expect(result.currency, 'USD'); + }); }); } diff --git a/test/src/models/log_list_test.dart b/test/src/models/log_list_test.dart index 715cab0d..84c560c8 100644 --- a/test/src/models/log_list_test.dart +++ b/test/src/models/log_list_test.dart @@ -4,13 +4,16 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('LogList', () { test('model', () { - final model = LogList(total: 5, logs: []); + final model = LogList( + total: 5, + logs: [], + ); final map = model.toMap(); final result = LogList.fromMap(map); - expect(result.total, 5); - expect(result.logs, []); - }); + expect(result.total, 5); + expect(result.logs, []); + }); }); } diff --git a/test/src/models/log_test.dart b/test/src/models/log_test.dart index c8211d3b..1b463633 100644 --- a/test/src/models/log_test.dart +++ b/test/src/models/log_test.dart @@ -32,28 +32,28 @@ void main() { final map = model.toMap(); final result = Log.fromMap(map); - expect(result.event, 'account.sessions.create'); - expect(result.userId, '610fc2f985ee0'); - expect(result.userEmail, 'john@appwrite.io'); - expect(result.userName, 'John Doe'); - expect(result.mode, 'admin'); - expect(result.userType, 'user'); - expect(result.ip, '127.0.0.1'); - expect(result.time, '2020-10-15T06:38:00.000+00:00'); - expect(result.osCode, 'Mac'); - expect(result.osName, 'Mac'); - expect(result.osVersion, 'Mac'); - expect(result.clientType, 'browser'); - expect(result.clientCode, 'CM'); - expect(result.clientName, 'Chrome Mobile iOS'); - expect(result.clientVersion, '84.0'); - expect(result.clientEngine, 'WebKit'); - expect(result.clientEngineVersion, '605.1.15'); - expect(result.deviceName, 'smartphone'); - expect(result.deviceBrand, 'Google'); - expect(result.deviceModel, 'Nexus 5'); - expect(result.countryCode, 'US'); - expect(result.countryName, 'United States'); - }); + expect(result.event, 'account.sessions.create'); + expect(result.userId, '610fc2f985ee0'); + expect(result.userEmail, 'john@appwrite.io'); + expect(result.userName, 'John Doe'); + expect(result.mode, 'admin'); + expect(result.userType, 'user'); + expect(result.ip, '127.0.0.1'); + expect(result.time, '2020-10-15T06:38:00.000+00:00'); + expect(result.osCode, 'Mac'); + expect(result.osName, 'Mac'); + expect(result.osVersion, 'Mac'); + expect(result.clientType, 'browser'); + expect(result.clientCode, 'CM'); + expect(result.clientName, 'Chrome Mobile iOS'); + expect(result.clientVersion, '84.0'); + expect(result.clientEngine, 'WebKit'); + expect(result.clientEngineVersion, '605.1.15'); + expect(result.deviceName, 'smartphone'); + expect(result.deviceBrand, 'Google'); + expect(result.deviceModel, 'Nexus 5'); + expect(result.countryCode, 'US'); + expect(result.countryName, 'United States'); + }); }); } diff --git a/test/src/models/membership_list_test.dart b/test/src/models/membership_list_test.dart index 5a1f5ee8..bb1f0946 100644 --- a/test/src/models/membership_list_test.dart +++ b/test/src/models/membership_list_test.dart @@ -4,13 +4,16 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('MembershipList', () { test('model', () { - final model = MembershipList(total: 5, memberships: []); + final model = MembershipList( + total: 5, + memberships: [], + ); final map = model.toMap(); final result = MembershipList.fromMap(map); - expect(result.total, 5); - expect(result.memberships, []); - }); + expect(result.total, 5); + expect(result.memberships, []); + }); }); } diff --git a/test/src/models/membership_test.dart b/test/src/models/membership_test.dart index b2b8bd3d..ab136c24 100644 --- a/test/src/models/membership_test.dart +++ b/test/src/models/membership_test.dart @@ -25,21 +25,21 @@ void main() { final map = model.toMap(); final result = Membership.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5ea5c16897e'); - expect(result.userName, 'John Doe'); - expect(result.userEmail, 'john@appwrite.io'); - expect(result.userPhone, '+1 555 555 5555'); - expect(result.teamId, '5e5ea5c16897e'); - expect(result.teamName, 'VIP'); - expect(result.invited, '2020-10-15T06:38:00.000+00:00'); - expect(result.joined, '2020-10-15T06:38:00.000+00:00'); - expect(result.confirm, true); - expect(result.mfa, true); - expect(result.userAccessedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.roles, []); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5ea5c16897e'); + expect(result.userName, 'John Doe'); + expect(result.userEmail, 'john@appwrite.io'); + expect(result.userPhone, '+1 555 555 5555'); + expect(result.teamId, '5e5ea5c16897e'); + expect(result.teamName, 'VIP'); + expect(result.invited, '2020-10-15T06:38:00.000+00:00'); + expect(result.joined, '2020-10-15T06:38:00.000+00:00'); + expect(result.confirm, true); + expect(result.mfa, true); + expect(result.userAccessedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.roles, []); + }); }); } diff --git a/test/src/models/mfa_challenge_test.dart b/test/src/models/mfa_challenge_test.dart index 5d3febca..9410baa3 100644 --- a/test/src/models/mfa_challenge_test.dart +++ b/test/src/models/mfa_challenge_test.dart @@ -14,10 +14,10 @@ void main() { final map = model.toMap(); final result = MfaChallenge.fromMap(map); - expect(result.$id, 'bb8ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5ea5c168bb8'); - expect(result.expire, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, 'bb8ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5ea5c168bb8'); + expect(result.expire, '2020-10-15T06:38:00.000+00:00'); + }); }); } diff --git a/test/src/models/mfa_factors_test.dart b/test/src/models/mfa_factors_test.dart index 64cc55e4..ed6467d3 100644 --- a/test/src/models/mfa_factors_test.dart +++ b/test/src/models/mfa_factors_test.dart @@ -14,10 +14,10 @@ void main() { final map = model.toMap(); final result = MfaFactors.fromMap(map); - expect(result.totp, true); - expect(result.phone, true); - expect(result.email, true); - expect(result.recoveryCode, true); - }); + expect(result.totp, true); + expect(result.phone, true); + expect(result.email, true); + expect(result.recoveryCode, true); + }); }); } diff --git a/test/src/models/mfa_recovery_codes_test.dart b/test/src/models/mfa_recovery_codes_test.dart index 8202a631..fa097a49 100644 --- a/test/src/models/mfa_recovery_codes_test.dart +++ b/test/src/models/mfa_recovery_codes_test.dart @@ -4,12 +4,14 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('MfaRecoveryCodes', () { test('model', () { - final model = MfaRecoveryCodes(recoveryCodes: []); + final model = MfaRecoveryCodes( + recoveryCodes: [], + ); final map = model.toMap(); final result = MfaRecoveryCodes.fromMap(map); - expect(result.recoveryCodes, []); - }); + expect(result.recoveryCodes, []); + }); }); } diff --git a/test/src/models/mfa_type_test.dart b/test/src/models/mfa_type_test.dart index e50b7d4d..3f45d288 100644 --- a/test/src/models/mfa_type_test.dart +++ b/test/src/models/mfa_type_test.dart @@ -6,18 +6,14 @@ void main() { test('model', () { final model = MfaType( secret: '[SHARED_SECRET]', - uri: - 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', + uri: 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', ); final map = model.toMap(); final result = MfaType.fromMap(map); - expect(result.secret, '[SHARED_SECRET]'); - expect( - result.uri, - 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', - ); - }); + expect(result.secret, '[SHARED_SECRET]'); + expect(result.uri, 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite'); + }); }); } diff --git a/test/src/models/phone_list_test.dart b/test/src/models/phone_list_test.dart index bc3231a4..6ca46a63 100644 --- a/test/src/models/phone_list_test.dart +++ b/test/src/models/phone_list_test.dart @@ -4,13 +4,16 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('PhoneList', () { test('model', () { - final model = PhoneList(total: 5, phones: []); + final model = PhoneList( + total: 5, + phones: [], + ); final map = model.toMap(); final result = PhoneList.fromMap(map); - expect(result.total, 5); - expect(result.phones, []); - }); + expect(result.total, 5); + expect(result.phones, []); + }); }); } diff --git a/test/src/models/phone_test.dart b/test/src/models/phone_test.dart index f70db0e3..d0e5333b 100644 --- a/test/src/models/phone_test.dart +++ b/test/src/models/phone_test.dart @@ -13,9 +13,9 @@ void main() { final map = model.toMap(); final result = Phone.fromMap(map); - expect(result.code, '+1'); - expect(result.countryCode, 'US'); - expect(result.countryName, 'United States'); - }); + expect(result.code, '+1'); + expect(result.countryCode, 'US'); + expect(result.countryName, 'United States'); + }); }); } diff --git a/test/src/models/preferences_test.dart b/test/src/models/preferences_test.dart index 8977b11a..acde349c 100644 --- a/test/src/models/preferences_test.dart +++ b/test/src/models/preferences_test.dart @@ -4,10 +4,13 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('Preferences', () { test('model', () { - final model = Preferences(data: {}); + final model = Preferences( + data: {}, + ); final map = model.toMap(); final result = Preferences.fromMap(map); + }); }); } diff --git a/test/src/models/presence_list_test.dart b/test/src/models/presence_list_test.dart index 9a5d97a3..57a86348 100644 --- a/test/src/models/presence_list_test.dart +++ b/test/src/models/presence_list_test.dart @@ -4,13 +4,16 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('PresenceList', () { test('model', () { - final model = PresenceList(total: 5, presences: []); + final model = PresenceList( + total: 5, + presences: [], + ); final map = model.toMap(); final result = PresenceList.fromMap(map); - expect(result.total, 5); - expect(result.presences, []); - }); + expect(result.total, 5); + expect(result.presences, []); + }); }); } diff --git a/test/src/models/presence_test.dart b/test/src/models/presence_test.dart index ef2ebe31..edcfe5f5 100644 --- a/test/src/models/presence_test.dart +++ b/test/src/models/presence_test.dart @@ -16,12 +16,12 @@ void main() { final map = model.toMap(); final result = Presence.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - expect(result.userId, '674af8f3e12a5f9ac0be'); - expect(result.source, 'HTTP'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + expect(result.userId, '674af8f3e12a5f9ac0be'); + expect(result.source, 'HTTP'); + }); }); } diff --git a/test/src/models/row_list_test.dart b/test/src/models/row_list_test.dart index 7b7a9f0d..d4900dd4 100644 --- a/test/src/models/row_list_test.dart +++ b/test/src/models/row_list_test.dart @@ -4,13 +4,16 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('RowList', () { test('model', () { - final model = RowList(total: 5, rows: []); + final model = RowList( + total: 5, + rows: [], + ); final map = model.toMap(); final result = RowList.fromMap(map); - expect(result.total, 5); - expect(result.rows, []); - }); + expect(result.total, 5); + expect(result.rows, []); + }); }); } diff --git a/test/src/models/row_test.dart b/test/src/models/row_test.dart index 564bf303..4e72a449 100644 --- a/test/src/models/row_test.dart +++ b/test/src/models/row_test.dart @@ -18,13 +18,13 @@ void main() { final map = model.toMap(); final result = Row.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$sequence, '1'); - expect(result.$tableId, '5e5ea5c15117e'); - expect(result.$databaseId, '5e5ea5c15117e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$sequence, '1'); + expect(result.$tableId, '5e5ea5c15117e'); + expect(result.$databaseId, '5e5ea5c15117e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + }); }); } diff --git a/test/src/models/session_list_test.dart b/test/src/models/session_list_test.dart index 61f2eaeb..eaab249e 100644 --- a/test/src/models/session_list_test.dart +++ b/test/src/models/session_list_test.dart @@ -4,13 +4,16 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('SessionList', () { test('model', () { - final model = SessionList(total: 5, sessions: []); + final model = SessionList( + total: 5, + sessions: [], + ); final map = model.toMap(); final result = SessionList.fromMap(map); - expect(result.total, 5); - expect(result.sessions, []); - }); + expect(result.total, 5); + expect(result.sessions, []); + }); }); } diff --git a/test/src/models/session_test.dart b/test/src/models/session_test.dart index 689e6048..0177e477 100644 --- a/test/src/models/session_test.dart +++ b/test/src/models/session_test.dart @@ -39,35 +39,35 @@ void main() { final map = model.toMap(); final result = Session.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5bb8c16897e'); - expect(result.expire, '2020-10-15T06:38:00.000+00:00'); - expect(result.provider, 'email'); - expect(result.providerUid, 'user@example.com'); - expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); - expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - expect(result.ip, '127.0.0.1'); - expect(result.osCode, 'Mac'); - expect(result.osName, 'Mac'); - expect(result.osVersion, 'Mac'); - expect(result.clientType, 'browser'); - expect(result.clientCode, 'CM'); - expect(result.clientName, 'Chrome Mobile iOS'); - expect(result.clientVersion, '84.0'); - expect(result.clientEngine, 'WebKit'); - expect(result.clientEngineVersion, '605.1.15'); - expect(result.deviceName, 'smartphone'); - expect(result.deviceBrand, 'Google'); - expect(result.deviceModel, 'Nexus 5'); - expect(result.countryCode, 'US'); - expect(result.countryName, 'United States'); - expect(result.current, true); - expect(result.factors, []); - expect(result.secret, '5e5bb8c16897e'); - expect(result.mfaUpdatedAt, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5bb8c16897e'); + expect(result.expire, '2020-10-15T06:38:00.000+00:00'); + expect(result.provider, 'email'); + expect(result.providerUid, 'user@example.com'); + expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); + expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + expect(result.ip, '127.0.0.1'); + expect(result.osCode, 'Mac'); + expect(result.osName, 'Mac'); + expect(result.osVersion, 'Mac'); + expect(result.clientType, 'browser'); + expect(result.clientCode, 'CM'); + expect(result.clientName, 'Chrome Mobile iOS'); + expect(result.clientVersion, '84.0'); + expect(result.clientEngine, 'WebKit'); + expect(result.clientEngineVersion, '605.1.15'); + expect(result.deviceName, 'smartphone'); + expect(result.deviceBrand, 'Google'); + expect(result.deviceModel, 'Nexus 5'); + expect(result.countryCode, 'US'); + expect(result.countryName, 'United States'); + expect(result.current, true); + expect(result.factors, []); + expect(result.secret, '5e5bb8c16897e'); + expect(result.mfaUpdatedAt, '2020-10-15T06:38:00.000+00:00'); + }); }); } diff --git a/test/src/models/subscriber_test.dart b/test/src/models/subscriber_test.dart index 7445514c..94c6a502 100644 --- a/test/src/models/subscriber_test.dart +++ b/test/src/models/subscriber_test.dart @@ -10,15 +10,15 @@ void main() { $updatedAt: '2020-10-15T06:38:00.000+00:00', targetId: '259125845563242502', target: Target( - $id: '259125845563242502', - $createdAt: '2020-10-15T06:38:00.000+00:00', - $updatedAt: '2020-10-15T06:38:00.000+00:00', - name: 'Apple iPhone 12', - userId: '259125845563242502', - providerType: 'email', - identifier: 'token', - expired: true, - ), + $id: '259125845563242502', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Apple iPhone 12', + userId: '259125845563242502', + providerType: 'email', + identifier: 'token', + expired: true, + ), userId: '5e5ea5c16897e', userName: 'Aegon Targaryen', topicId: '259125845563242502', @@ -28,14 +28,14 @@ void main() { final map = model.toMap(); final result = Subscriber.fromMap(map); - expect(result.$id, '259125845563242502'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.targetId, '259125845563242502'); - expect(result.userId, '5e5ea5c16897e'); - expect(result.userName, 'Aegon Targaryen'); - expect(result.topicId, '259125845563242502'); - expect(result.providerType, 'email'); - }); + expect(result.$id, '259125845563242502'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.targetId, '259125845563242502'); + expect(result.userId, '5e5ea5c16897e'); + expect(result.userName, 'Aegon Targaryen'); + expect(result.topicId, '259125845563242502'); + expect(result.providerType, 'email'); + }); }); } diff --git a/test/src/models/target_test.dart b/test/src/models/target_test.dart index 49f1e75e..a49f3def 100644 --- a/test/src/models/target_test.dart +++ b/test/src/models/target_test.dart @@ -18,14 +18,14 @@ void main() { final map = model.toMap(); final result = Target.fromMap(map); - expect(result.$id, '259125845563242502'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.name, 'Apple iPhone 12'); - expect(result.userId, '259125845563242502'); - expect(result.providerType, 'email'); - expect(result.identifier, 'token'); - expect(result.expired, true); - }); + expect(result.$id, '259125845563242502'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.name, 'Apple iPhone 12'); + expect(result.userId, '259125845563242502'); + expect(result.providerType, 'email'); + expect(result.identifier, 'token'); + expect(result.expired, true); + }); }); } diff --git a/test/src/models/team_list_test.dart b/test/src/models/team_list_test.dart index eb459ac2..a19b667d 100644 --- a/test/src/models/team_list_test.dart +++ b/test/src/models/team_list_test.dart @@ -4,13 +4,16 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('TeamList', () { test('model', () { - final model = TeamList(total: 5, teams: []); + final model = TeamList( + total: 5, + teams: [], + ); final map = model.toMap(); final result = TeamList.fromMap(map); - expect(result.total, 5); - expect(result.teams, []); - }); + expect(result.total, 5); + expect(result.teams, []); + }); }); } diff --git a/test/src/models/team_test.dart b/test/src/models/team_test.dart index f652f2c1..43b2e45c 100644 --- a/test/src/models/team_test.dart +++ b/test/src/models/team_test.dart @@ -16,11 +16,11 @@ void main() { final map = model.toMap(); final result = Team.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.name, 'VIP'); - expect(result.total, 7); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.name, 'VIP'); + expect(result.total, 7); + }); }); } diff --git a/test/src/models/token_test.dart b/test/src/models/token_test.dart index 8f0957c9..7ee4b268 100644 --- a/test/src/models/token_test.dart +++ b/test/src/models/token_test.dart @@ -16,12 +16,12 @@ void main() { final map = model.toMap(); final result = Token.fromMap(map); - expect(result.$id, 'bb8ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5ea5c168bb8'); - expect(result.secret, ''); - expect(result.expire, '2020-10-15T06:38:00.000+00:00'); - expect(result.phrase, 'Golden Fox'); - }); + expect(result.$id, 'bb8ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5ea5c168bb8'); + expect(result.secret, ''); + expect(result.expire, '2020-10-15T06:38:00.000+00:00'); + expect(result.phrase, 'Golden Fox'); + }); }); } diff --git a/test/src/models/transaction_list_test.dart b/test/src/models/transaction_list_test.dart index 35acd271..68023e18 100644 --- a/test/src/models/transaction_list_test.dart +++ b/test/src/models/transaction_list_test.dart @@ -4,13 +4,16 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('TransactionList', () { test('model', () { - final model = TransactionList(total: 5, transactions: []); + final model = TransactionList( + total: 5, + transactions: [], + ); final map = model.toMap(); final result = TransactionList.fromMap(map); - expect(result.total, 5); - expect(result.transactions, []); - }); + expect(result.total, 5); + expect(result.transactions, []); + }); }); } diff --git a/test/src/models/transaction_test.dart b/test/src/models/transaction_test.dart index 0169427f..723ebac2 100644 --- a/test/src/models/transaction_test.dart +++ b/test/src/models/transaction_test.dart @@ -16,12 +16,12 @@ void main() { final map = model.toMap(); final result = Transaction.fromMap(map); - expect(result.$id, '259125845563242502'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.status, 'pending'); - expect(result.operations, 5); - expect(result.expiresAt, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, '259125845563242502'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.status, 'pending'); + expect(result.operations, 5); + expect(result.expiresAt, '2020-10-15T06:38:00.000+00:00'); + }); }); } diff --git a/test/src/models/user_test.dart b/test/src/models/user_test.dart index 77c7dd97..c058ea26 100644 --- a/test/src/models/user_test.dart +++ b/test/src/models/user_test.dart @@ -26,21 +26,21 @@ void main() { final map = model.toMap(); final result = User.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.name, 'John Doe'); - expect(result.registration, '2020-10-15T06:38:00.000+00:00'); - expect(result.status, true); - expect(result.labels, []); - expect(result.passwordUpdate, '2020-10-15T06:38:00.000+00:00'); - expect(result.email, 'john@appwrite.io'); - expect(result.phone, '+4930901820'); - expect(result.emailVerification, true); - expect(result.phoneVerification, true); - expect(result.mfa, true); - expect(result.targets, []); - expect(result.accessedAt, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.name, 'John Doe'); + expect(result.registration, '2020-10-15T06:38:00.000+00:00'); + expect(result.status, true); + expect(result.labels, []); + expect(result.passwordUpdate, '2020-10-15T06:38:00.000+00:00'); + expect(result.email, 'john@appwrite.io'); + expect(result.phone, '+4930901820'); + expect(result.emailVerification, true); + expect(result.phoneVerification, true); + expect(result.mfa, true); + expect(result.targets, []); + expect(result.accessedAt, '2020-10-15T06:38:00.000+00:00'); + }); }); } diff --git a/test/src/realtime_response_connected_test.dart b/test/src/realtime_response_connected_test.dart index 56897e43..7c43878b 100644 --- a/test/src/realtime_response_connected_test.dart +++ b/test/src/realtime_response_connected_test.dart @@ -52,7 +52,9 @@ void main() { expect( responseString, - equals('RealtimeResponseConnected(channels: $channels, user: $user)'), + equals( + 'RealtimeResponseConnected(channels: $channels, user: $user)', + ), ); }); diff --git a/test/src/realtime_response_test.dart b/test/src/realtime_response_test.dart index 029c35bf..4435280a 100644 --- a/test/src/realtime_response_test.dart +++ b/test/src/realtime_response_test.dart @@ -48,9 +48,7 @@ void main() { final responseString = response1.toString(); expect( - responseString, - equals('RealtimeResponse(type: $type, data: $data)'), - ); + responseString, equals('RealtimeResponse(type: $type, data: $data)')); }); test('equality operator should compare two instances', () { diff --git a/test/src/realtime_subscription_test.dart b/test/src/realtime_subscription_test.dart index d19e6eac..1515f1a3 100644 --- a/test/src/realtime_subscription_test.dart +++ b/test/src/realtime_subscription_test.dart @@ -8,18 +8,15 @@ void main() { final mockStream = StreamController.broadcast(); final mockCloseFunction = () async {}; final mockUnsubscribeFunction = () async {}; - Future mockUpdateFunction({ - List? channels, - List? queries, - }) async {} + Future mockUpdateFunction( + {List? channels, List? queries}) async {} final subscription = RealtimeSubscription( - controller: mockStream, - close: mockCloseFunction, - unsubscribe: mockUnsubscribeFunction, - update: mockUpdateFunction, - channels: ['documents'], - queries: const [], - ); + controller: mockStream, + close: mockCloseFunction, + unsubscribe: mockUnsubscribeFunction, + update: mockUpdateFunction, + channels: ['documents'], + queries: const []); test('should have the correct stream and close function', () { expect(subscription.controller, equals(mockStream)); diff --git a/test/src/upload_progress_test.dart b/test/src/upload_progress_test.dart index 3dce66c9..d21607ec 100644 --- a/test/src/upload_progress_test.dart +++ b/test/src/upload_progress_test.dart @@ -14,7 +14,7 @@ void main() { "progress": progress, "sizeUploaded": sizeUploaded, "chunksTotal": chunksTotal, - "chunksUploaded": chunksUploaded, + "chunksUploaded": chunksUploaded }; final uploadProgress = UploadProgress( $id: id, From e5f8bfd480a36d9ffa97c4402742b9b3274a36c4 Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Wed, 24 Jun 2026 11:35:05 +0000 Subject: [PATCH 2/8] Commit from GitHub Actions (Format and push) --- lib/appwrite.dart | 2 +- lib/channel.dart | 20 +- lib/client_browser.dart | 2 +- lib/client_io.dart | 2 +- lib/operator.dart | 11 +- lib/query.dart | 91 +- lib/realtime_browser.dart | 2 +- lib/realtime_io.dart | 2 +- lib/role.dart | 2 +- lib/services/account.dart | 1560 +++++----- lib/services/avatars.dart | 351 ++- lib/services/databases.dart | 603 ++-- lib/services/functions.dart | 115 +- lib/services/graphql.dart | 50 +- lib/services/locale.dart | 142 +- lib/services/messaging.dart | 70 +- lib/services/presences.dart | 182 +- lib/services/storage.dart | 342 ++- lib/services/tables_db.dart | 547 ++-- lib/services/teams.dart | 421 +-- lib/src/client.dart | 4 +- lib/src/client_base.dart | 7 + lib/src/client_browser.dart | 15 +- lib/src/client_io.dart | 15 +- lib/src/client_mixin.dart | 9 +- lib/src/enums/authentication_factor.dart | 18 +- lib/src/enums/authenticator_type.dart | 12 +- lib/src/enums/browser.dart | 38 +- lib/src/enums/browser_permission.dart | 50 +- lib/src/enums/browser_theme.dart | 14 +- lib/src/enums/credit_card.dart | 44 +- lib/src/enums/execution_method.dart | 24 +- lib/src/enums/execution_status.dart | 20 +- lib/src/enums/execution_trigger.dart | 16 +- 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 | 96 +- lib/src/enums/timezone.dart | 848 +++--- lib/src/exception.dart | 2 +- lib/src/models/algo_argon2.dart | 62 +- lib/src/models/algo_bcrypt.dart | 32 +- lib/src/models/algo_md5.dart | 32 +- lib/src/models/algo_phpass.dart | 32 +- lib/src/models/algo_scrypt.dart | 86 +- lib/src/models/algo_scrypt_modified.dart | 62 +- lib/src/models/algo_sha.dart | 32 +- lib/src/models/continent.dart | 42 +- lib/src/models/continent_list.dart | 43 +- lib/src/models/country.dart | 42 +- lib/src/models/country_list.dart | 43 +- lib/src/models/currency.dart | 110 +- lib/src/models/currency_list.dart | 43 +- lib/src/models/document.dart | 102 +- lib/src/models/document_list.dart | 47 +- lib/src/models/execution.dart | 246 +- lib/src/models/execution_list.dart | 43 +- lib/src/models/file.dart | 194 +- lib/src/models/file_list.dart | 42 +- lib/src/models/headers.dart | 42 +- lib/src/models/identity.dart | 122 +- lib/src/models/identity_list.dart | 43 +- lib/src/models/jwt.dart | 32 +- lib/src/models/language.dart | 52 +- lib/src/models/language_list.dart | 43 +- lib/src/models/locale.dart | 110 +- lib/src/models/locale_code.dart | 42 +- lib/src/models/locale_code_list.dart | 43 +- lib/src/models/log.dart | 290 +- lib/src/models/log_list.dart | 42 +- lib/src/models/membership.dart | 206 +- lib/src/models/membership_list.dart | 43 +- lib/src/models/mfa_challenge.dart | 62 +- lib/src/models/mfa_factors.dart | 62 +- lib/src/models/mfa_recovery_codes.dart | 32 +- lib/src/models/mfa_type.dart | 42 +- lib/src/models/model.dart | 2 +- lib/src/models/phone.dart | 52 +- lib/src/models/phone_list.dart | 42 +- lib/src/models/preferences.dart | 32 +- lib/src/models/presence.dart | 112 +- lib/src/models/presence_list.dart | 43 +- lib/src/models/row.dart | 102 +- lib/src/models/row_list.dart | 46 +- lib/src/models/session.dart | 360 +-- lib/src/models/session_list.dart | 43 +- lib/src/models/subscriber.dart | 112 +- lib/src/models/target.dart | 112 +- lib/src/models/team.dart | 98 +- lib/src/models/team_list.dart | 42 +- lib/src/models/token.dart | 98 +- lib/src/models/transaction.dart | 98 +- lib/src/models/transaction_list.dart | 43 +- lib/src/models/user.dart | 332 +- lib/src/realtime.dart | 6 +- lib/src/realtime_io.dart | 4 +- lib/src/realtime_message.dart | 2 +- lib/src/realtime_mixin.dart | 31 +- lib/src/realtime_response.dart | 10 +- lib/src/realtime_stub.dart | 4 +- test/channel_test.dart | 42 +- test/query_test.dart | 1 - test/services/account_test.dart | 2691 ++++++++--------- test/services/avatars_test.dart | 204 +- test/services/databases_test.dart | 585 ++-- test/services/functions_test.dart | 188 +- test/services/graphql_test.dart | 71 +- test/services/locale_test.dart | 253 +- test/services/messaging_test.dart | 122 +- test/services/presences_test.dart | 202 +- test/services/storage_test.dart | 341 +-- test/services/tables_db_test.dart | 585 ++-- test/services/teams_test.dart | 555 ++-- test/src/models/algo_argon2_test.dart | 10 +- test/src/models/algo_bcrypt_test.dart | 4 +- test/src/models/algo_md5_test.dart | 4 +- test/src/models/algo_phpass_test.dart | 4 +- .../src/models/algo_scrypt_modified_test.dart | 14 +- test/src/models/algo_scrypt_test.dart | 12 +- test/src/models/algo_sha_test.dart | 4 +- test/src/models/continent_list_test.dart | 6 +- test/src/models/continent_test.dart | 6 +- test/src/models/country_list_test.dart | 6 +- test/src/models/country_test.dart | 6 +- test/src/models/currency_list_test.dart | 6 +- test/src/models/currency_test.dart | 16 +- test/src/models/document_list_test.dart | 6 +- test/src/models/document_test.dart | 16 +- test/src/models/execution_list_test.dart | 6 +- test/src/models/execution_test.dart | 36 +- test/src/models/file_list_test.dart | 6 +- test/src/models/file_test.dart | 30 +- test/src/models/headers_test.dart | 6 +- test/src/models/identity_list_test.dart | 6 +- test/src/models/identity_test.dart | 22 +- test/src/models/jwt_test.dart | 8 +- test/src/models/language_list_test.dart | 6 +- test/src/models/language_test.dart | 8 +- test/src/models/locale_code_list_test.dart | 6 +- test/src/models/locale_code_test.dart | 6 +- test/src/models/locale_test.dart | 16 +- test/src/models/log_list_test.dart | 6 +- test/src/models/log_test.dart | 46 +- test/src/models/membership_list_test.dart | 6 +- test/src/models/membership_test.dart | 32 +- test/src/models/mfa_challenge_test.dart | 10 +- test/src/models/mfa_factors_test.dart | 10 +- test/src/models/mfa_recovery_codes_test.dart | 4 +- test/src/models/mfa_type_test.dart | 10 +- test/src/models/phone_list_test.dart | 6 +- test/src/models/phone_test.dart | 8 +- test/src/models/preferences_test.dart | 1 - test/src/models/presence_list_test.dart | 6 +- test/src/models/presence_test.dart | 14 +- test/src/models/row_list_test.dart | 6 +- test/src/models/row_test.dart | 16 +- test/src/models/session_list_test.dart | 6 +- test/src/models/session_test.dart | 60 +- test/src/models/subscriber_test.dart | 36 +- test/src/models/target_test.dart | 18 +- test/src/models/team_list_test.dart | 6 +- test/src/models/team_test.dart | 12 +- test/src/models/token_test.dart | 14 +- test/src/models/transaction_list_test.dart | 6 +- test/src/models/transaction_test.dart | 14 +- test/src/models/user_test.dart | 32 +- 166 files changed, 8516 insertions(+), 8661 deletions(-) diff --git a/lib/appwrite.dart b/lib/appwrite.dart index 6615de8a..ae51be5e 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.9.x. +/// This SDK is compatible with Appwrite server version 1.9.x. /// For older versions, please check /// [previous releases](https://github.com/appwrite/sdk-for-flutter/releases). library appwrite; diff --git a/lib/channel.dart b/lib/channel.dart index d511f5a4..afc68efa 100644 --- a/lib/channel.dart +++ b/lib/channel.dart @@ -2,19 +2,33 @@ part of appwrite; // Marker classes for type safety class _Root {} + class _Database {} + class _Collection {} + class _Document {} + class _TablesDB {} + class _Table {} + class _Row {} + class _Bucket {} + class _File {} + class _Func {} + class _Execution {} + class _Team {} + class _Membership {} + class _Presence {} + class _Resolved {} // Helper function for normalizing ID @@ -99,15 +113,15 @@ extension DatabaseChannel on Channel<_Database> { /// Only available on Channel<_Collection> extension CollectionChannel on Channel<_Collection> { - Channel<_Document> document([String? id]) => _next<_Document>('documents', id); + Channel<_Document> document([String? id]) => + _next<_Document>('documents', id); } // --- TABLESDB ROUTE --- /// Only available on Channel<_TablesDB> extension TablesDBChannel on Channel<_TablesDB> { - Channel<_Table> table(String id) => - _next<_Table>('tables', id); + Channel<_Table> table(String id) => _next<_Table>('tables', id); } /// Only available on Channel<_Table> 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/operator.dart b/lib/operator.dart index 9dd7f4c7..337dda30 100644 --- a/lib/operator.dart +++ b/lib/operator.dart @@ -31,7 +31,7 @@ class Operator { result['method'] = method; - if(values != null) { + if (values != null) { result['values'] = values is List ? values : [values]; } @@ -147,8 +147,7 @@ class Operator { Operator._('arrayRemove', [value]).toString(); /// Remove duplicate values from an array attribute. - static String arrayUnique() => - Operator._('arrayUnique', []).toString(); + static String arrayUnique() => Operator._('arrayUnique', []).toString(); /// Keep only values that exist in both the current array and the provided array. static String arrayIntersect(List values) => @@ -173,8 +172,7 @@ class Operator { Operator._('stringReplace', [search, replace]).toString(); /// Toggle a boolean attribute. - static String toggle() => - Operator._('toggle', []).toString(); + static String toggle() => Operator._('toggle', []).toString(); /// Add days to a date attribute. static String dateAddDays(int days) => @@ -185,6 +183,5 @@ class Operator { Operator._('dateSubDays', [days]).toString(); /// Set a date attribute to the current date and time. - static String dateSetNow() => - Operator._('dateSetNow', []).toString(); + static String dateSetNow() => Operator._('dateSetNow', []).toString(); } diff --git a/lib/query.dart b/lib/query.dart index 95365bf7..3693dce6 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. @@ -140,50 +140,46 @@ class Query { Query._('notEndsWith', attribute, value).toString(); /// Filter resources where document was created before [value]. - static String createdBefore(String value) => - lessThan('\$createdAt', value); + static String createdBefore(String value) => lessThan('\$createdAt', value); /// Filter resources where document was created after [value]. - static String createdAfter(String value) => - greaterThan('\$createdAt', value); + static String createdAfter(String value) => greaterThan('\$createdAt', value); /// Filter resources where document was created between [start] and [end] (inclusive). static String createdBetween(String start, String end) => between('\$createdAt', start, end); /// Filter resources where document was updated before [value]. - static String updatedBefore(String value) => - lessThan('\$updatedAt', value); + static String updatedBefore(String value) => lessThan('\$updatedAt', value); /// Filter resources where document was updated after [value]. - static String updatedAfter(String value) => - greaterThan('\$updatedAt', value); + static String updatedAfter(String value) => greaterThan('\$updatedAt', value); /// Filter resources where document was updated between [start] and [end] (inclusive). static String updatedBetween(String start, String end) => between('\$updatedAt', start, end); static String or(List queries) => Query._( - 'or', - null, - queries.map((query) => jsonDecode(query)).toList(), - ).toString(); + 'or', + null, + queries.map((query) => jsonDecode(query)).toList(), + ).toString(); static String and(List queries) => Query._( - 'and', - null, - queries.map((query) => jsonDecode(query)).toList(), - ).toString(); + 'and', + null, + queries.map((query) => jsonDecode(query)).toList(), + ).toString(); /// Filter array elements where at least one element matches all the specified queries. /// /// [attribute] The attribute containing the array to filter on. /// [queries] The list of query strings to match against array elements. static String elemMatch(String attribute, List queries) => Query._( - 'elemMatch', - attribute, - queries.map((query) => jsonDecode(query)).toList(), - ).toString(); + 'elemMatch', + attribute, + queries.map((query) => jsonDecode(query)).toList(), + ).toString(); /// Specify which attributes should be returned by the API call. static String select(List attributes) => @@ -198,18 +194,17 @@ class Query { Query._('orderDesc', attribute).toString(); /// Sort results randomly. - static String orderRandom() => - Query._('orderRandom').toString(); + static String orderRandom() => Query._('orderRandom').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) => @@ -219,27 +214,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) => @@ -272,4 +283,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 9c021e93..48b60041 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 { final String apiPath = '/account'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -30,29 +29,30 @@ 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 { final String apiPath = '/account'; - final Map apiParams = { - 'userId': userId, - - 'email': email, - - 'password': password, - - if (name != null) 'name': name, - - }; + final Map apiParams = { + 'userId': userId, + 'email': email, + 'password': password, + if (name != null) 'name': name, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - 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 @@ -62,66 +62,65 @@ 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 { final String apiPath = '/account/email'; - final Map apiParams = { - 'email': email, - - 'password': password, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + 'email': email, + 'password': password, + }; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 list of identities for the currently logged in user. - Future listIdentities({List? queries, bool? total}) async { + Future listIdentities( + {List? queries, bool? total}) async { final String apiPath = '/account/identities'; - final Map apiParams = { - if (queries != null) 'queries': queries, + final Map apiParams = { + if (queries != null) 'queries': queries, + if (total != null) 'total': total, + }; - if (total != null) 'total': total, + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: 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 Map apiParams = { - }; + final String apiPath = '/account/identities/{identityId}' + .replaceAll('{identityId}', identityId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - 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 @@ -132,20 +131,20 @@ class Account extends Service { Future createJWT({int? duration}) async { final String apiPath = '/account/jwts'; - final Map apiParams = { - if (duration != null) 'duration': duration, + final Map apiParams = { + if (duration != null) 'duration': duration, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - 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 @@ -153,212 +152,224 @@ class Account extends Service { Future listLogs({List? queries, bool? total}) async { final String apiPath = '/account/logs'; - final Map apiParams = { - if (queries != null) 'queries': queries, - - if (total != null) 'total': total, - - }; + final Map apiParams = { + if (queries != null) 'queries': queries, + if (total != null) 'total': total, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 { final String apiPath = '/account/mfa'; - final Map apiParams = { - 'mfa': mfa, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + 'mfa': mfa, + }; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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); + @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 apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.MfaType.fromMap(res.data); + 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 = { - }; + Future createMFAAuthenticator( + {required enums.AuthenticatorType type}) async { + final String apiPath = + '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - return models.MfaType.fromMap(res.data); + 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, - - }; + Future updateMFAAuthenticator( + {required enums.AuthenticatorType type, required String otp}) async { + final String apiPath = + '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + 'otp': otp, + }; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - return models.User.fromMap(res.data); + 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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 { final String apiPath = '/account/mfa/challenges'; - final Map apiParams = { - 'factor': factor.value, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + 'factor': factor.value, + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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); } /// 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 { final String apiPath = '/account/mfa/challenges'; - final Map apiParams = { - 'factor': factor.value, + final Map apiParams = { + 'factor': factor.value, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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); } /// Complete the MFA challenge by providing the one-time password. Finish the @@ -366,26 +377,27 @@ 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 { final String apiPath = '/account/mfa/challenges'; - final Map apiParams = { - 'challengeId': challengeId, - - 'otp': otp, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 @@ -393,84 +405,83 @@ 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 { final String apiPath = '/account/mfa/challenges'; - final Map apiParams = { - 'challengeId': challengeId, + final Map apiParams = { + 'challengeId': challengeId, + 'otp': otp, + }; - 'otp': otp, + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 { final String apiPath = '/account/mfa/factors'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 { final String apiPath = '/account/mfa/factors'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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); } /// 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 { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -480,18 +491,17 @@ class Account extends Service { Future getMFARecoveryCodes() async { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -499,22 +509,23 @@ 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 { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 @@ -525,40 +536,41 @@ class Account extends Service { Future createMFARecoveryCodes() async { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 @@ -568,62 +580,62 @@ class Account extends Service { Future updateMFARecoveryCodes() async { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - 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 { final String apiPath = '/account/name'; - final Map apiParams = { - 'name': name, - - }; + final Map apiParams = { + 'name': name, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 { final String apiPath = '/account/password'; - final Map apiParams = { - 'password': password, - - if (oldPassword != null) 'oldPassword': oldPassword, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + 'password': password, + if (oldPassword != null) 'oldPassword': oldPassword, + }; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 @@ -631,43 +643,42 @@ 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 { final String apiPath = '/account/phone'; - final Map apiParams = { - 'phone': phone, + final Map apiParams = { + 'phone': phone, + 'password': password, + }; - 'password': password, + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 preferences as a key-value object for the currently logged in user. Future getPrefs() async { final String apiPath = '/account/prefs'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -676,20 +687,20 @@ class Account extends Service { Future updatePrefs({required Map prefs}) async { final String apiPath = '/account/prefs'; - final Map apiParams = { - 'prefs': prefs, + final Map apiParams = { + 'prefs': prefs, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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. @@ -700,25 +711,25 @@ 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 { final String apiPath = '/account/recovery'; - final Map apiParams = { - 'email': email, - - 'url': url, - - }; + final Map apiParams = { + 'email': email, + 'url': url, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 account password reset. Both the @@ -726,32 +737,33 @@ 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 { final 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - 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 @@ -759,18 +771,17 @@ class Account extends Service { Future listSessions() async { final String apiPath = '/account/sessions'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -778,18 +789,17 @@ class Account extends Service { Future deleteSessions() async { final String apiPath = '/account/sessions'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - 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 @@ -802,213 +812,216 @@ class Account extends Service { Future createAnonymousSession() async { final String apiPath = '/account/sessions/anonymous'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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); } /// 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 { final String apiPath = '/account/sessions/email'; - final Map apiParams = { - 'email': email, - - 'password': password, + final Map apiParams = { + 'email': email, + 'password': password, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 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 { final String apiPath = '/account/sessions/magic-url'; - final Map apiParams = { - 'userId': userId, - - 'secret': secret, - - }; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 = { - - if (success != null) 'success': success, - - if (failure != null) 'failure': failure, - - if (scopes != null) 'scopes': scopes, - - - 'project': client.config['project'], - }; - - final List query = []; - - params.forEach((key, value) { - if (value is List) { - for (var item in value) { - query.add( + /// + 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 = { + if (success != null) 'success': success, + if (failure != null) 'failure': failure, + if (scopes != null) '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); + } + } 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 { final String apiPath = '/account/sessions/phone'; - final Map apiParams = { - 'userId': userId, - - 'secret': secret, + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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); } /// 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 { final String apiPath = '/account/sessions/token'; - final Map apiParams = { - 'userId': userId, - - 'secret': secret, - - }; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 String apiPath = + '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, @@ -1017,20 +1030,20 @@ 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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 @@ -1039,18 +1052,18 @@ class Account extends Service { Future updateStatus() async { final String apiPath = '/account/status'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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); } /// Use this endpoint to register a device for push notifications. Provide a @@ -1058,27 +1071,28 @@ 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 { final String apiPath = '/account/targets/push'; - final Map apiParams = { - 'targetId': targetId, - - 'identifier': identifier, - - if (providerId != null) 'providerId': providerId, - - }; + final Map apiParams = { + 'targetId': targetId, + 'identifier': identifier, + if (providerId != null) 'providerId': providerId, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 @@ -1086,43 +1100,45 @@ 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, + 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Target.fromMap(res.data); + 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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 @@ -1134,32 +1150,31 @@ 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 { final String apiPath = '/account/tokens/email'; - final Map apiParams = { - 'userId': userId, + final Map apiParams = { + 'userId': userId, + 'email': email, + if (phrase != null) 'phrase': phrase, + }; - 'email': email, + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - if (phrase != null) 'phrase': phrase, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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); } /// Sends the user an email with a secret key for creating a session. If the @@ -1171,87 +1186,88 @@ 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 { final String apiPath = '/account/tokens/magic-url'; - final Map apiParams = { - 'userId': userId, - - 'email': email, - - if (url != null) 'url': url, - - if (phrase != null) 'phrase': phrase, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + 'userId': userId, + 'email': email, + if (url != null) 'url': url, + if (phrase != null) 'phrase': phrase, + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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); } /// 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 = { - - if (success != null) 'success': success, - - if (failure != null) 'failure': failure, - - if (scopes != null) 'scopes': scopes, - - - 'project': client.config['project'], - }; - - final List query = []; - - params.forEach((key, value) { - if (value is List) { - for (var item in value) { - query.add( + 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 = { + if (success != null) 'success': success, + if (failure != null) 'failure': failure, + if (scopes != null) '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); + } + } 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 @@ -1260,29 +1276,29 @@ 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 { final String apiPath = '/account/tokens/phone'; - final Map apiParams = { - 'userId': userId, - - 'phone': phone, + final Map apiParams = { + 'userId': userId, + 'phone': phone, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 @@ -1294,29 +1310,29 @@ 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 createEmailVerification({required String url}) async { final String apiPath = '/account/verifications/email'; - final Map apiParams = { - 'url': url, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + 'url': url, + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 send a verification message to your user email address @@ -1328,81 +1344,83 @@ 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. - /// - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.createEmailVerification` instead.') + /// + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.createEmailVerification` instead.') Future createVerification({required String url}) async { final String apiPath = '/account/verifications/email'; - final Map apiParams = { - 'url': url, + final Map apiParams = { + 'url': url, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 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 updateEmailVerification({required String userId, required String secret}) async { + Future updateEmailVerification( + {required String userId, required String secret}) async { final String apiPath = '/account/verifications/email'; - final Map apiParams = { - 'userId': userId, - - 'secret': secret, - - }; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - 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 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. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.updateEmailVerification` instead.') - Future updateVerification({required String userId, required String secret}) async { + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.updateEmailVerification` instead.') + Future updateVerification( + {required String userId, required String secret}) async { final String apiPath = '/account/verifications/email'; - final Map apiParams = { - 'userId': userId, - - 'secret': secret, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 @@ -1416,42 +1434,42 @@ class Account extends Service { Future createPhoneVerification() async { final String apiPath = '/account/verifications/phone'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 { final String apiPath = '/account/verifications/phone'; - final Map apiParams = { - 'userId': userId, - - 'secret': secret, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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); } } diff --git a/lib/services/avatars.dart b/lib/services/avatars.dart index 4dca3b16..cdd93e6e 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,139 +11,134 @@ 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 = { - - if (width != null) 'width': width, - - if (height != null) 'height': height, - - if (quality != null) 'quality': quality, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + if (width != null) 'width': width, + if (height != null) 'height': height, + if (quality != null) 'quality': quality, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 = { - - if (width != null) 'width': width, - - if (height != null) 'height': height, - - if (quality != null) 'quality': quality, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + if (width != null) 'width': width, + if (height != null) 'height': height, + if (quality != null) 'quality': quality, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 { final String apiPath = '/avatars/favicon'; - final Map params = { - - 'url': url, + final Map params = { + 'url': url, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { - - if (width != null) 'width': width, - - if (height != null) 'height': height, - - if (quality != null) 'quality': quality, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + if (width != null) 'width': width, + if (height != null) 'height': height, + if (quality != null) 'quality': quality, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 { final String apiPath = '/avatars/image'; - final Map params = { - - 'url': url, - - if (width != null) 'width': width, - - if (height != null) 'height': height, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + 'url': url, + if (width != null) 'width': width, + if (height != null) 'height': height, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 @@ -151,125 +146,117 @@ 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 { final String apiPath = '/avatars/initials'; - final Map params = { - - if (name != null) 'name': name, - - if (width != null) 'width': width, - - if (height != null) 'height': height, - - if (background != null) 'background': background, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + if (name != null) 'name': name, + if (width != null) 'width': width, + if (height != null) 'height': height, + if (background != null) 'background': background, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 { final String apiPath = '/avatars/qr'; - final Map params = { - - 'text': text, - - if (size != null) 'size': size, - - if (margin != null) 'margin': margin, - - if (download != null) 'download': download, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + 'text': text, + if (size != null) 'size': size, + if (margin != null) 'margin': margin, + if (download != null) 'download': download, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + final res = await client.call(HttpMethod.get, + path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// Use this endpoint to capture a screenshot of any website URL. This endpoint /// uses a headless browser to render the webpage and capture it as an image. - /// + /// /// You can configure the browser viewport size, theme, user agent, /// geolocation, permissions, and more. Capture either just the viewport or the /// full page scroll. - /// + /// /// When width and height are specified, the image is resized accordingly. If /// both dimensions are 0, the API provides an image at original size. If /// dimensions are not specified, the default viewport size is 1280x720px. - Future getScreenshot({required String url, Map? headers, int? viewportWidth, int? viewportHeight, double? scale, enums.BrowserTheme? theme, String? userAgent, bool? fullpage, String? locale, enums.Timezone? timezone, double? latitude, double? longitude, double? accuracy, bool? touch, List? permissions, int? sleep, int? width, int? height, int? quality, enums.ImageFormat? output}) async { + Future getScreenshot( + {required String url, + Map? headers, + int? viewportWidth, + int? viewportHeight, + double? scale, + enums.BrowserTheme? theme, + String? userAgent, + bool? fullpage, + String? locale, + enums.Timezone? timezone, + double? latitude, + double? longitude, + double? accuracy, + bool? touch, + List? permissions, + int? sleep, + int? width, + int? height, + int? quality, + enums.ImageFormat? output}) async { final String apiPath = '/avatars/screenshots'; - final Map params = { - - 'url': url, - - if (headers != null) 'headers': headers, - - if (viewportWidth != null) 'viewportWidth': viewportWidth, - - if (viewportHeight != null) 'viewportHeight': viewportHeight, - - if (scale != null) 'scale': scale, - - if (theme != null) 'theme': theme.value, - - if (userAgent != null) 'userAgent': userAgent, - - if (fullpage != null) 'fullpage': fullpage, - - if (locale != null) 'locale': locale, - - if (timezone != null) 'timezone': timezone.value, - - if (latitude != null) 'latitude': latitude, - - if (longitude != null) 'longitude': longitude, - - if (accuracy != null) 'accuracy': accuracy, - - if (touch != null) 'touch': touch, - - if (permissions != null) 'permissions': permissions.map((e) => e.value).toList(), - - if (sleep != null) 'sleep': sleep, - - if (width != null) 'width': width, - - if (height != null) 'height': height, - - if (quality != null) 'quality': quality, - - if (output != null) 'output': output.value, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + 'url': url, + if (headers != null) 'headers': headers, + if (viewportWidth != null) 'viewportWidth': viewportWidth, + if (viewportHeight != null) 'viewportHeight': viewportHeight, + if (scale != null) 'scale': scale, + if (theme != null) 'theme': theme.value, + if (userAgent != null) 'userAgent': userAgent, + if (fullpage != null) 'fullpage': fullpage, + if (locale != null) 'locale': locale, + if (timezone != null) 'timezone': timezone.value, + if (latitude != null) 'latitude': latitude, + if (longitude != null) 'longitude': longitude, + if (accuracy != null) 'accuracy': accuracy, + if (touch != null) 'touch': touch, + if (permissions != null) + 'permissions': permissions.map((e) => e.value).toList(), + if (sleep != null) 'sleep': sleep, + if (width != null) 'width': width, + if (height != null) 'height': height, + if (quality != null) 'quality': quality, + if (output != null) 'output': output.value, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + final res = await client.call(HttpMethod.get, + path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } } diff --git a/lib/services/databases.dart b/lib/services/databases.dart index 0bfd935a..0ff3fb72 100644 --- a/lib/services/databases.dart +++ b/lib/services/databases.dart @@ -1,339 +1,418 @@ 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); /// List transactions across all databases. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.listTransactions` instead.') - Future listTransactions({List? queries}) async { + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.listTransactions` instead.') + Future listTransactions( + {List? queries}) async { final String apiPath = '/databases/transactions'; - final Map apiParams = { - if (queries != null) 'queries': queries, + final Map apiParams = { + if (queries != null) 'queries': queries, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.TransactionList.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.TransactionList.fromMap(res.data); } /// Create a new transaction. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.createTransaction` instead.') + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.createTransaction` instead.') Future createTransaction({int? ttl}) async { final String apiPath = '/databases/transactions'; - final Map apiParams = { - if (ttl != null) 'ttl': ttl, - - }; + final Map apiParams = { + if (ttl != null) 'ttl': ttl, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Transaction.fromMap(res.data); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.Transaction.fromMap(res.data); } /// Get a transaction by its unique ID. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.getTransaction` instead.') - Future getTransaction({required String transactionId}) async { - final String apiPath = '/databases/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - }; + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.getTransaction` instead.') + Future getTransaction( + {required String transactionId}) async { + final String apiPath = '/databases/transactions/{transactionId}' + .replaceAll('{transactionId}', transactionId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - return models.Transaction.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.Transaction.fromMap(res.data); } /// Update a transaction, to either commit or roll back its operations. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.updateTransaction` instead.') - Future updateTransaction({required String transactionId, bool? commit, bool? rollback}) async { - final String apiPath = '/databases/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - if (commit != null) 'commit': commit, - - if (rollback != null) 'rollback': rollback, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Transaction.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.updateTransaction` instead.') + Future updateTransaction( + {required String transactionId, bool? commit, bool? rollback}) async { + final String apiPath = '/databases/transactions/{transactionId}' + .replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + if (commit != null) 'commit': commit, + if (rollback != null) 'rollback': rollback, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Transaction.fromMap(res.data); } /// Delete a transaction by its unique ID. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.deleteTransaction` instead.') + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.deleteTransaction` instead.') Future deleteTransaction({required String transactionId}) async { - final String apiPath = '/databases/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - }; + final String apiPath = '/databases/transactions/{transactionId}' + .replaceAll('{transactionId}', transactionId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - return res.data; + final res = await client.call(HttpMethod.delete, + path: apiPath, params: apiParams, headers: apiHeaders); + return res.data; } /// Create multiple operations in a single transaction. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.createOperations` instead.') - Future createOperations({required String transactionId, List? operations}) async { - final String apiPath = '/databases/transactions/{transactionId}/operations'.replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - if (operations != null) 'operations': operations, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Transaction.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.createOperations` instead.') + Future createOperations( + {required String transactionId, List? operations}) async { + final String apiPath = '/databases/transactions/{transactionId}/operations' + .replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + if (operations != null) 'operations': operations, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Transaction.fromMap(res.data); } /// 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, String? transactionId, bool? total, int? ttl}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - - if (transactionId != null) 'transactionId': transactionId, - - if (total != null) 'total': total, - - if (ttl != null) 'ttl': ttl, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, + String? transactionId, + bool? total, + int? ttl}) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + if (transactionId != null) 'transactionId': transactionId, + if (total != null) 'total': total, + if (ttl != null) 'ttl': ttl, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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, String? transactionId}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); - - final Map apiParams = { - 'documentId': documentId, - - 'data': data, - - 'permissions': permissions, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + String? transactionId}) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId); + + final Map apiParams = { + 'documentId': documentId, + 'data': data, + 'permissions': permissions, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, String? transactionId}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - - if (transactionId != null) 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, + String? transactionId}) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + if (transactionId != null) 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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, Map? data, List? permissions, String? transactionId}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - - final Map apiParams = { - if (data != null) 'data': data, - - 'permissions': permissions, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + Map? data, + List? permissions, + String? transactionId}) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId); + + final Map apiParams = { + if (data != null) 'data': data, + 'permissions': permissions, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, String? transactionId}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - - final Map apiParams = { - if (data != null) 'data': data, - - 'permissions': permissions, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + String? transactionId}) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId); + + final Map apiParams = { + if (data != null) 'data': data, + 'permissions': permissions, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, String? transactionId}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - - final Map apiParams = { - if (transactionId != null) 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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, + String? transactionId}) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId); + + final Map apiParams = { + if (transactionId != null) 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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, String? transactionId}) 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 = { - if (value != null) 'value': value, - - 'min': min, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + String? transactionId}) 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 = { + if (value != null) 'value': value, + 'min': min, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, String? transactionId}) 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 = { - if (value != null) 'value': value, - - 'max': max, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + String? transactionId}) 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 = { + if (value != null) 'value': value, + 'max': max, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); } } diff --git a/lib/services/functions.dart b/lib/services/functions.dart index 0640f80f..ed97921b 100644 --- a/lib/services/functions.dart +++ b/lib/services/functions.dart @@ -1,82 +1,87 @@ 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, bool? total}) async { - final String apiPath = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); + Future listExecutions( + {required String functionId, List? queries, bool? total}) async { + final String apiPath = '/functions/{functionId}/executions' + .replaceAll('{functionId}', functionId); - final Map apiParams = { - if (queries != null) 'queries': queries, + final Map apiParams = { + if (queries != null) 'queries': queries, + if (total != null) 'total': total, + }; - if (total != null) 'total': total, + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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 = { - if (body != null) 'body': body, - - if (xasync != null) 'async': xasync, - - if (path != null) 'path': path, - - if (method != null) 'method': method.value, - - if (headers != null) 'headers': headers, - - 'scheduledAt': scheduledAt, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + if (body != null) 'body': body, + if (xasync != null) 'async': xasync, + if (path != null) 'path': path, + if (method != null) 'method': method.value, + if (headers != null) 'headers': headers, + 'scheduledAt': scheduledAt, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 = { - }; + Future getExecution( + {required String functionId, required String executionId}) async { + final String apiPath = '/functions/{functionId}/executions/{executionId}' + .replaceAll('{functionId}', functionId) + .replaceAll('{executionId}', executionId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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); } } diff --git a/lib/services/graphql.dart b/lib/services/graphql.dart index 978331fa..c86f3719 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,39 +10,41 @@ class Graphql extends Service { Future query({required Map query}) async { final String apiPath = '/graphql'; - final Map apiParams = { - 'query': query, + final Map apiParams = { + 'query': query, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'x-sdk-graphql': 'true', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'x-sdk-graphql': 'true', 'content-type': 'application/json', 'accept': '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 { final String apiPath = '/graphql/mutation'; - final Map apiParams = { - 'query': query, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'x-sdk-graphql': 'true', 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + 'query': query, + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'x-sdk-graphql': 'true', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - return res.data; + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); + return res.data; } } diff --git a/lib/services/locale.dart b/lib/services/locale.dart index c45a1269..87ea162e 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 { final String apiPath = '/locale'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -34,18 +33,17 @@ class Locale extends Service { Future listCodes() async { final String apiPath = '/locale/codes'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -53,18 +51,17 @@ class Locale extends Service { Future listContinents() async { final String apiPath = '/locale/continents'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -72,18 +69,17 @@ class Locale extends Service { Future listCountries() async { final String apiPath = '/locale/countries'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -91,18 +87,17 @@ class Locale extends Service { Future listCountriesEU() async { final String apiPath = '/locale/countries/eu'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -110,18 +105,17 @@ class Locale extends Service { Future listCountriesPhones() async { final String apiPath = '/locale/countries/phones'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -130,18 +124,17 @@ class Locale extends Service { Future listCurrencies() async { final String apiPath = '/locale/currencies'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -149,17 +142,16 @@ class Locale extends Service { Future listLanguages() async { final String apiPath = '/locale/languages'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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); } } diff --git a/lib/services/messaging.dart b/lib/services/messaging.dart index 3dffe41b..61ecefee 100644 --- a/lib/services/messaging.dart +++ b/lib/services/messaging.dart @@ -1,48 +1,54 @@ 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - return res.data; + final res = await client.call(HttpMethod.delete, + path: apiPath, params: apiParams, headers: apiHeaders); + return res.data; } } diff --git a/lib/services/presences.dart b/lib/services/presences.dart index 088700cb..1c9b651b 100644 --- a/lib/services/presences.dart +++ b/lib/services/presences.dart @@ -5,123 +5,127 @@ class Presences extends Service { Presences(super.client); /// List presence logs. Expired entries are filtered out automatically. - /// - Future list({List? queries, bool? total, int? ttl}) async { + /// + Future list( + {List? queries, bool? total, int? ttl}) async { final String apiPath = '/presences'; - final Map apiParams = { - if (queries != null) 'queries': queries, + final Map apiParams = { + if (queries != null) 'queries': queries, + if (total != null) 'total': total, + if (ttl != null) 'ttl': ttl, + }; - if (total != null) 'total': total, + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - if (ttl != null) 'ttl': ttl, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.PresenceList.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.PresenceList.fromMap(res.data); } /// Get a presence log by its unique ID. Entries whose `expiresAt` is in the /// past are treated as not found. - /// + /// Future get({required String presenceId}) async { - final String apiPath = '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); + final String apiPath = + '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Presence.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.Presence.fromMap(res.data); } /// Create or update a presence log by its user ID. - /// - Future upsert({required String presenceId, required String status, List? permissions, String? expiresAt, Map? metadata}) async { - final String apiPath = '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); - - final Map apiParams = { - 'status': status, - - if (permissions != null) 'permissions': permissions, - - if (expiresAt != null) 'expiresAt': expiresAt, - - if (metadata != null) 'metadata': metadata, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Presence.fromMap(res.data); - + /// + Future upsert( + {required String presenceId, + required String status, + List? permissions, + String? expiresAt, + Map? metadata}) async { + final String apiPath = + '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); + + final Map apiParams = { + 'status': status, + if (permissions != null) 'permissions': permissions, + if (expiresAt != null) 'expiresAt': expiresAt, + if (metadata != null) 'metadata': metadata, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Presence.fromMap(res.data); } /// Update a presence log by its unique ID. Using the patch method you can pass /// only specific fields that will get updated. - /// - Future update({required String presenceId, String? status, String? expiresAt, Map? metadata, List? permissions, bool? purge}) async { - final String apiPath = '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); - - final Map apiParams = { - if (status != null) 'status': status, - - if (expiresAt != null) 'expiresAt': expiresAt, - - if (metadata != null) 'metadata': metadata, - - if (permissions != null) 'permissions': permissions, - - if (purge != null) 'purge': purge, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Presence.fromMap(res.data); - + /// + Future update( + {required String presenceId, + String? status, + String? expiresAt, + Map? metadata, + List? permissions, + bool? purge}) async { + final String apiPath = + '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); + + final Map apiParams = { + if (status != null) 'status': status, + if (expiresAt != null) 'expiresAt': expiresAt, + if (metadata != null) 'metadata': metadata, + if (permissions != null) 'permissions': permissions, + if (purge != null) 'purge': purge, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Presence.fromMap(res.data); } /// Delete a presence log by its unique ID. - /// + /// Future delete({required String presenceId}) async { - final String apiPath = '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); - - final Map apiParams = { - }; + final String apiPath = + '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - return res.data; + final res = await client.call(HttpMethod.delete, + path: apiPath, params: apiParams, headers: apiHeaders); + return res.data; } } diff --git a/lib/services/storage.dart b/lib/services/storage.dart index c9499a99..cdb626de 100644 --- a/lib/services/storage.dart +++ b/lib/services/storage.dart @@ -1,166 +1,178 @@ 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, bool? total}) async { - final String apiPath = '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - - if (search != null) 'search': search, - - if (total != null) 'total': total, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, + bool? total}) async { + final String apiPath = + '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + if (search != null) 'search': search, + if (total != null) 'total': total, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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, - - if (permissions != null) 'permissions': permissions, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'multipart/form-data', 'accept': 'application/json', - }; - - 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, + if (permissions != null) 'permissions': permissions, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'multipart/form-data', + 'accept': 'application/json', + }; + + 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); + 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 apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.File.fromMap(res.data); + 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 = { - if (name != null) 'name': name, - - 'permissions': permissions, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + if (name != null) 'name': name, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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 = { - - if (token != null) 'token': token, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + if (token != null) 'token': token, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 @@ -168,60 +180,64 @@ 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 = { - - if (width != null) 'width': width, - - if (height != null) 'height': height, - - if (gravity != null) 'gravity': gravity.value, - - if (quality != null) 'quality': quality, - - if (borderWidth != null) 'borderWidth': borderWidth, - - if (borderColor != null) 'borderColor': borderColor, - - if (borderRadius != null) 'borderRadius': borderRadius, - - if (opacity != null) 'opacity': opacity, - - if (rotation != null) 'rotation': rotation, - - if (background != null) 'background': background, - - if (output != null) 'output': output.value, - - if (token != null) 'token': token, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + if (width != null) 'width': width, + if (height != null) 'height': height, + if (gravity != null) 'gravity': gravity.value, + if (quality != null) 'quality': quality, + if (borderWidth != null) 'borderWidth': borderWidth, + if (borderColor != null) 'borderColor': borderColor, + if (borderRadius != null) 'borderRadius': borderRadius, + if (opacity != null) 'opacity': opacity, + if (rotation != null) 'rotation': rotation, + if (background != null) 'background': background, + if (output != null) 'output': output.value, + if (token != null) 'token': token, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 = { - - if (token != null) 'token': token, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + if (token != null) 'token': token, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + final res = await client.call(HttpMethod.get, + path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } } diff --git a/lib/services/tables_db.dart b/lib/services/tables_db.dart index 42572021..8b6284b3 100644 --- a/lib/services/tables_db.dart +++ b/lib/services/tables_db.dart @@ -5,319 +5,382 @@ class TablesDB extends Service { TablesDB(super.client); /// List transactions across all databases. - Future listTransactions({List? queries}) async { + Future listTransactions( + {List? queries}) async { final String apiPath = '/tablesdb/transactions'; - final Map apiParams = { - if (queries != null) 'queries': queries, + final Map apiParams = { + if (queries != null) 'queries': queries, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.TransactionList.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.TransactionList.fromMap(res.data); } /// Create a new transaction. Future createTransaction({int? ttl}) async { final String apiPath = '/tablesdb/transactions'; - final Map apiParams = { - if (ttl != null) 'ttl': ttl, - - }; + final Map apiParams = { + if (ttl != null) 'ttl': ttl, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Transaction.fromMap(res.data); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.Transaction.fromMap(res.data); } /// Get a transaction by its unique ID. - Future getTransaction({required String transactionId}) async { - final String apiPath = '/tablesdb/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - }; + Future getTransaction( + {required String transactionId}) async { + final String apiPath = '/tablesdb/transactions/{transactionId}' + .replaceAll('{transactionId}', transactionId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - return models.Transaction.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.Transaction.fromMap(res.data); } /// Update a transaction, to either commit or roll back its operations. - Future updateTransaction({required String transactionId, bool? commit, bool? rollback}) async { - final String apiPath = '/tablesdb/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - if (commit != null) 'commit': commit, - - if (rollback != null) 'rollback': rollback, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Transaction.fromMap(res.data); - + Future updateTransaction( + {required String transactionId, bool? commit, bool? rollback}) async { + final String apiPath = '/tablesdb/transactions/{transactionId}' + .replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + if (commit != null) 'commit': commit, + if (rollback != null) 'rollback': rollback, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Transaction.fromMap(res.data); } /// Delete a transaction by its unique ID. Future deleteTransaction({required String transactionId}) async { - final String apiPath = '/tablesdb/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - }; + final String apiPath = '/tablesdb/transactions/{transactionId}' + .replaceAll('{transactionId}', transactionId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - return res.data; + final res = await client.call(HttpMethod.delete, + path: apiPath, params: apiParams, headers: apiHeaders); + return res.data; } /// Create multiple operations in a single transaction. - Future createOperations({required String transactionId, List? operations}) async { - final String apiPath = '/tablesdb/transactions/{transactionId}/operations'.replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - if (operations != null) 'operations': operations, - - }; + Future createOperations( + {required String transactionId, List? operations}) async { + final String apiPath = '/tablesdb/transactions/{transactionId}/operations' + .replaceAll('{transactionId}', transactionId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + if (operations != null) 'operations': operations, + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - return models.Transaction.fromMap(res.data); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.Transaction.fromMap(res.data); } /// 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, String? transactionId, bool? total, int? ttl}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - - if (transactionId != null) 'transactionId': transactionId, - - if (total != null) 'total': total, - - if (ttl != null) 'ttl': ttl, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, + String? transactionId, + bool? total, + int? ttl}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + if (transactionId != null) 'transactionId': transactionId, + if (total != null) 'total': total, + if (ttl != null) 'ttl': ttl, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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/references/cloud/server-dart/tablesDB#createTable) /// API or directly from your database console. - Future createRow({required String databaseId, required String tableId, required String rowId, required Map data, List? permissions, String? transactionId}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); - - final Map apiParams = { - 'rowId': rowId, - - 'data': data, - - 'permissions': permissions, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + String? transactionId}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId); + + final Map apiParams = { + 'rowId': rowId, + 'data': data, + 'permissions': permissions, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, String? transactionId}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - - if (transactionId != null) 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, + String? transactionId}) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + if (transactionId != null) 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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/references/cloud/server-dart/tablesDB#createTable) /// API or directly from your database console. - Future upsertRow({required String databaseId, required String tableId, required String rowId, Map? data, List? permissions, String? transactionId}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - if (data != null) 'data': data, - - 'permissions': permissions, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + String? transactionId}) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId); + + final Map apiParams = { + if (data != null) 'data': data, + 'permissions': permissions, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, String? transactionId}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - if (data != null) 'data': data, - - 'permissions': permissions, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + String? transactionId}) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId); + + final Map apiParams = { + if (data != null) 'data': data, + 'permissions': permissions, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, String? transactionId}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - if (transactionId != null) 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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, + String? transactionId}) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId); + + final Map apiParams = { + if (transactionId != null) 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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, String? transactionId}) 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 = { - if (value != null) 'value': value, - - 'min': min, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + String? transactionId}) 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 = { + if (value != null) 'value': value, + 'min': min, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, String? transactionId}) 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 = { - if (value != null) 'value': value, - - 'max': max, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + String? transactionId}) 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 = { + if (value != null) 'value': value, + 'max': max, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); } } diff --git a/lib/services/teams.dart b/lib/services/teams.dart index 27bc561e..1f4022f6 100644 --- a/lib/services/teams.dart +++ b/lib/services/teams.dart @@ -1,98 +1,97 @@ 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); /// Get a list of all the teams in which the current user is a member. You can /// use the parameters to filter your results. - Future list({List? queries, String? search, bool? total}) async { + Future list( + {List? queries, String? search, bool? total}) async { final String apiPath = '/teams'; - final Map apiParams = { - if (queries != null) 'queries': queries, + final Map apiParams = { + if (queries != null) 'queries': queries, + if (search != null) 'search': search, + if (total != null) 'total': total, + }; - if (search != null) 'search': search, + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - if (total != null) 'total': total, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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 { final String apiPath = '/teams'; - final Map apiParams = { - 'teamId': teamId, - - 'name': name, - - if (roles != null) 'roles': roles, - - }; + final Map apiParams = { + 'teamId': teamId, + 'name': name, + if (roles != null) 'roles': roles, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 apiParams = { + 'name': name, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - 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 @@ -100,44 +99,45 @@ class Teams extends Service { Future delete({required String teamId}) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - 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, bool? total}) async { - final String apiPath = '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - - if (search != null) 'search': search, - - if (total != null) 'total': total, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, + bool? total}) async { + final String apiPath = + '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + if (search != null) 'search': search, + if (total != null) 'total': total, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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 @@ -146,180 +146,199 @@ 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 = { - if (email != null) 'email': email, - - if (userId != null) 'userId': userId, - - if (phone != null) 'phone': phone, - - 'roles': roles, - - if (url != null) 'url': url, - - if (name != null) 'name': name, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + if (email != null) 'email': email, + if (userId != null) 'userId': userId, + if (phone != null) 'phone': phone, + 'roles': roles, + if (url != null) 'url': url, + if (name != null) 'name': name, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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); + 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 apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 = { - }; + Future deleteMembership( + {required String teamId, required String membershipId}) async { + final String apiPath = '/teams/{teamId}/memberships/{membershipId}' + .replaceAll('{teamId}', teamId) + .replaceAll('{membershipId}', membershipId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + 'prefs': prefs, + }; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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); } } diff --git a/lib/src/client.dart b/lib/src/client.dart index 65b2f044..cc077e56 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -27,7 +27,8 @@ abstract class Client { factory Client({ String endPoint = 'https://cloud.appwrite.io/v1', bool selfSigned = false, - }) => createClient(endPoint: endPoint, selfSigned: selfSigned); + }) => + createClient(endPoint: endPoint, selfSigned: selfSigned); /// Handle OAuth2 session creation. Future webAuth(Uri url, {String? callbackUrlScheme}); @@ -107,7 +108,6 @@ abstract class Client { /// Send a ping to project as part of onboarding. Future ping(); - /// Send the API request. Future call( HttpMethod method, { diff --git a/lib/src/client_base.dart b/lib/src/client_base.dart index 9e964a79..da1a5225 100644 --- a/lib/src/client_base.dart +++ b/lib/src/client_base.dart @@ -6,26 +6,33 @@ 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); + /// The user cookie to authenticate with. Used by SDKs that forward an incoming Cookie header in server-side runtimes. @override ClientBase setCookie(value); + /// Impersonate a user by ID @override ClientBase setImpersonateUserId(value); + /// Impersonate a user by email @override ClientBase setImpersonateUserEmail(value); + /// Impersonate a user by phone @override ClientBase setImpersonateUserPhone(value); diff --git a/lib/src/client_browser.dart b/lib/src/client_browser.dart index 2f4c7b48..32945efd 100644 --- a/lib/src/client_browser.dart +++ b/lib/src/client_browser.dart @@ -62,6 +62,7 @@ class ClientBrowser extends ClientBase with ClientMixin { config['project'] = value; return this; } + /// Your secret JSON Web Token @override ClientBrowser setJWT(value) { @@ -69,12 +70,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) { @@ -82,6 +85,7 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Session', value); return this; } + /// Your secret dev API key @override ClientBrowser setDevKey(value) { @@ -89,6 +93,7 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Dev-Key', value); return this; } + /// The user cookie to authenticate with. Used by SDKs that forward an incoming Cookie header in server-side runtimes. @override ClientBrowser setCookie(value) { @@ -96,6 +101,7 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('Cookie', value); return this; } + /// Impersonate a user by ID @override ClientBrowser setImpersonateUserId(value) { @@ -103,6 +109,7 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Impersonate-User-Id', value); return this; } + /// Impersonate a user by email @override ClientBrowser setImpersonateUserEmail(value) { @@ -110,6 +117,7 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Impersonate-User-Email', value); return this; } + /// Impersonate a user by phone @override ClientBrowser setImpersonateUserPhone(value) { @@ -219,7 +227,8 @@ class ClientBrowser extends ClientBase with ClientMixin { final totalChunks = (size / chunkSize).ceil(); - Future uploadChunk(int index, int start, int end, String? id) async { + Future uploadChunk( + int index, int start, int end, String? id) async { List chunk = []; chunk = file.bytes!.getRange(start, end).toList(); @@ -257,7 +266,9 @@ class ClientBrowser extends ClientBase with ClientMixin { bool isUploadComplete(Response response) { final chunksUploaded = response.data['chunksUploaded']; final chunksTotal = response.data['chunksTotal'] ?? totalChunks; - return chunksUploaded is num && chunksTotal is num && chunksUploaded >= chunksTotal; + return chunksUploaded is num && + chunksTotal is num && + chunksUploaded >= chunksTotal; } final progress = UploadProgress( diff --git a/lib/src/client_io.dart b/lib/src/client_io.dart index 6e6e2ee8..78a368ae 100644 --- a/lib/src/client_io.dart +++ b/lib/src/client_io.dart @@ -88,6 +88,7 @@ class ClientIO extends ClientBase with ClientMixin { config['project'] = value; return this; } + /// Your secret JSON Web Token @override ClientIO setJWT(value) { @@ -95,12 +96,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) { @@ -108,6 +111,7 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Session', value); return this; } + /// Your secret dev API key @override ClientIO setDevKey(value) { @@ -115,6 +119,7 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Dev-Key', value); return this; } + /// The user cookie to authenticate with. Used by SDKs that forward an incoming Cookie header in server-side runtimes. @override ClientIO setCookie(value) { @@ -122,6 +127,7 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('Cookie', value); return this; } + /// Impersonate a user by ID @override ClientIO setImpersonateUserId(value) { @@ -129,6 +135,7 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Impersonate-User-Id', value); return this; } + /// Impersonate a user by email @override ClientIO setImpersonateUserEmail(value) { @@ -136,6 +143,7 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Impersonate-User-Email', value); return this; } + /// Impersonate a user by phone @override ClientIO setImpersonateUserPhone(value) { @@ -394,7 +402,9 @@ class ClientIO extends ClientBase with ClientMixin { bool isUploadComplete(Response response) { final chunksUploaded = response.data['chunksUploaded']; final chunksTotal = response.data['chunksTotal'] ?? totalChunks; - return chunksUploaded is num && chunksTotal is num && chunksUploaded >= chunksTotal; + return chunksUploaded is num && + chunksTotal is num && + chunksUploaded >= chunksTotal; } final progress = UploadProgress( @@ -418,7 +428,8 @@ class ClientIO extends ClientBase with ClientMixin { var nextChunk = 0; Future uploadNext() async { - final raf = file.bytes == null ? await iofile!.open(mode: FileMode.read) : null; + final raf = + file.bytes == null ? await iofile!.open(mode: FileMode.read) : null; try { while (nextChunk < chunks.length) { final chunk = chunks[nextChunk++]; diff --git a/lib/src/client_mixin.dart b/lib/src/client_mixin.dart index 40484946..89aad359 100644 --- a/lib/src/client_mixin.dart +++ b/lib/src/client_mixin.dart @@ -12,7 +12,6 @@ mixin ClientMixin { required Map headers, required Map params, }) { - http.BaseRequest request = http.Request(method.name(), uri); if (headers['content-type'] == 'multipart/form-data') { request = http.MultipartRequest(method.name(), uri); @@ -128,9 +127,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/browser_permission.dart b/lib/src/enums/browser_permission.dart index 765b3e0c..fb4983db 100644 --- a/lib/src/enums/browser_permission.dart +++ b/lib/src/enums/browser_permission.dart @@ -1,32 +1,30 @@ part of '../../enums.dart'; enum BrowserPermission { - geolocation(value: 'geolocation'), - camera(value: 'camera'), - microphone(value: 'microphone'), - notifications(value: 'notifications'), - midi(value: 'midi'), - push(value: 'push'), - clipboardRead(value: 'clipboard-read'), - clipboardWrite(value: 'clipboard-write'), - paymentHandler(value: 'payment-handler'), - usb(value: 'usb'), - bluetooth(value: 'bluetooth'), - accelerometer(value: 'accelerometer'), - gyroscope(value: 'gyroscope'), - magnetometer(value: 'magnetometer'), - ambientLightSensor(value: 'ambient-light-sensor'), - backgroundSync(value: 'background-sync'), - persistentStorage(value: 'persistent-storage'), - screenWakeLock(value: 'screen-wake-lock'), - webShare(value: 'web-share'), - xrSpatialTracking(value: 'xr-spatial-tracking'); + geolocation(value: 'geolocation'), + camera(value: 'camera'), + microphone(value: 'microphone'), + notifications(value: 'notifications'), + midi(value: 'midi'), + push(value: 'push'), + clipboardRead(value: 'clipboard-read'), + clipboardWrite(value: 'clipboard-write'), + paymentHandler(value: 'payment-handler'), + usb(value: 'usb'), + bluetooth(value: 'bluetooth'), + accelerometer(value: 'accelerometer'), + gyroscope(value: 'gyroscope'), + magnetometer(value: 'magnetometer'), + ambientLightSensor(value: 'ambient-light-sensor'), + backgroundSync(value: 'background-sync'), + persistentStorage(value: 'persistent-storage'), + screenWakeLock(value: 'screen-wake-lock'), + webShare(value: 'web-share'), + xrSpatialTracking(value: 'xr-spatial-tracking'); - const BrowserPermission({ - required this.value - }); + const BrowserPermission({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_theme.dart b/lib/src/enums/browser_theme.dart index e81a0f68..1e059c2c 100644 --- a/lib/src/enums/browser_theme.dart +++ b/lib/src/enums/browser_theme.dart @@ -1,14 +1,12 @@ part of '../../enums.dart'; enum BrowserTheme { - light(value: 'light'), - dark(value: 'dark'); + light(value: 'light'), + dark(value: 'dark'); - const BrowserTheme({ - required this.value - }); + const BrowserTheme({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/execution_status.dart b/lib/src/enums/execution_status.dart index f54859c9..7ea9865e 100644 --- a/lib/src/enums/execution_status.dart +++ b/lib/src/enums/execution_status.dart @@ -1,17 +1,15 @@ part of '../../enums.dart'; enum ExecutionStatus { - waiting(value: 'waiting'), - processing(value: 'processing'), - completed(value: 'completed'), - failed(value: 'failed'), - scheduled(value: 'scheduled'); + waiting(value: 'waiting'), + processing(value: 'processing'), + completed(value: 'completed'), + failed(value: 'failed'), + scheduled(value: 'scheduled'); - const ExecutionStatus({ - required this.value - }); + const ExecutionStatus({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_trigger.dart b/lib/src/enums/execution_trigger.dart index 8a14ae60..fb05eb7d 100644 --- a/lib/src/enums/execution_trigger.dart +++ b/lib/src/enums/execution_trigger.dart @@ -1,15 +1,13 @@ part of '../../enums.dart'; enum ExecutionTrigger { - http(value: 'http'), - schedule(value: 'schedule'), - event(value: 'event'); + http(value: 'http'), + schedule(value: 'schedule'), + event(value: 'event'); - const ExecutionTrigger({ - required this.value - }); + const ExecutionTrigger({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 8ed7ecff..b88e0a55 100644 --- a/lib/src/enums/o_auth_provider.dart +++ b/lib/src/enums/o_auth_provider.dart @@ -1,55 +1,53 @@ 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'), - fusionauth(value: 'fusionauth'), - github(value: 'github'), - gitlab(value: 'gitlab'), - google(value: 'google'), - keycloak(value: 'keycloak'), - kick(value: 'kick'), - 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'), - x(value: 'x'), - yahoo(value: 'yahoo'), - yammer(value: 'yammer'), - yandex(value: 'yandex'), - zoho(value: 'zoho'), - zoom(value: 'zoom'); + 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'), + fusionauth(value: 'fusionauth'), + github(value: 'github'), + gitlab(value: 'gitlab'), + google(value: 'google'), + keycloak(value: 'keycloak'), + kick(value: 'kick'), + 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'), + x(value: 'x'), + yahoo(value: 'yahoo'), + yammer(value: 'yammer'), + yandex(value: 'yandex'), + zoho(value: 'zoho'), + zoom(value: 'zoom'); - 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/enums/timezone.dart b/lib/src/enums/timezone.dart index 4a8de1ce..d5d8d94a 100644 --- a/lib/src/enums/timezone.dart +++ b/lib/src/enums/timezone.dart @@ -1,431 +1,429 @@ part of '../../enums.dart'; enum Timezone { - africaAbidjan(value: 'africa/abidjan'), - africaAccra(value: 'africa/accra'), - africaAddisAbaba(value: 'africa/addis_ababa'), - africaAlgiers(value: 'africa/algiers'), - africaAsmara(value: 'africa/asmara'), - africaBamako(value: 'africa/bamako'), - africaBangui(value: 'africa/bangui'), - africaBanjul(value: 'africa/banjul'), - africaBissau(value: 'africa/bissau'), - africaBlantyre(value: 'africa/blantyre'), - africaBrazzaville(value: 'africa/brazzaville'), - africaBujumbura(value: 'africa/bujumbura'), - africaCairo(value: 'africa/cairo'), - africaCasablanca(value: 'africa/casablanca'), - africaCeuta(value: 'africa/ceuta'), - africaConakry(value: 'africa/conakry'), - africaDakar(value: 'africa/dakar'), - africaDarEsSalaam(value: 'africa/dar_es_salaam'), - africaDjibouti(value: 'africa/djibouti'), - africaDouala(value: 'africa/douala'), - africaElAaiun(value: 'africa/el_aaiun'), - africaFreetown(value: 'africa/freetown'), - africaGaborone(value: 'africa/gaborone'), - africaHarare(value: 'africa/harare'), - africaJohannesburg(value: 'africa/johannesburg'), - africaJuba(value: 'africa/juba'), - africaKampala(value: 'africa/kampala'), - africaKhartoum(value: 'africa/khartoum'), - africaKigali(value: 'africa/kigali'), - africaKinshasa(value: 'africa/kinshasa'), - africaLagos(value: 'africa/lagos'), - africaLibreville(value: 'africa/libreville'), - africaLome(value: 'africa/lome'), - africaLuanda(value: 'africa/luanda'), - africaLubumbashi(value: 'africa/lubumbashi'), - africaLusaka(value: 'africa/lusaka'), - africaMalabo(value: 'africa/malabo'), - africaMaputo(value: 'africa/maputo'), - africaMaseru(value: 'africa/maseru'), - africaMbabane(value: 'africa/mbabane'), - africaMogadishu(value: 'africa/mogadishu'), - africaMonrovia(value: 'africa/monrovia'), - africaNairobi(value: 'africa/nairobi'), - africaNdjamena(value: 'africa/ndjamena'), - africaNiamey(value: 'africa/niamey'), - africaNouakchott(value: 'africa/nouakchott'), - africaOuagadougou(value: 'africa/ouagadougou'), - africaPortoNovo(value: 'africa/porto-novo'), - africaSaoTome(value: 'africa/sao_tome'), - africaTripoli(value: 'africa/tripoli'), - africaTunis(value: 'africa/tunis'), - africaWindhoek(value: 'africa/windhoek'), - americaAdak(value: 'america/adak'), - americaAnchorage(value: 'america/anchorage'), - americaAnguilla(value: 'america/anguilla'), - americaAntigua(value: 'america/antigua'), - americaAraguaina(value: 'america/araguaina'), - americaArgentinaBuenosAires(value: 'america/argentina/buenos_aires'), - americaArgentinaCatamarca(value: 'america/argentina/catamarca'), - americaArgentinaCordoba(value: 'america/argentina/cordoba'), - americaArgentinaJujuy(value: 'america/argentina/jujuy'), - americaArgentinaLaRioja(value: 'america/argentina/la_rioja'), - americaArgentinaMendoza(value: 'america/argentina/mendoza'), - americaArgentinaRioGallegos(value: 'america/argentina/rio_gallegos'), - americaArgentinaSalta(value: 'america/argentina/salta'), - americaArgentinaSanJuan(value: 'america/argentina/san_juan'), - americaArgentinaSanLuis(value: 'america/argentina/san_luis'), - americaArgentinaTucuman(value: 'america/argentina/tucuman'), - americaArgentinaUshuaia(value: 'america/argentina/ushuaia'), - americaAruba(value: 'america/aruba'), - americaAsuncion(value: 'america/asuncion'), - americaAtikokan(value: 'america/atikokan'), - americaBahia(value: 'america/bahia'), - americaBahiaBanderas(value: 'america/bahia_banderas'), - americaBarbados(value: 'america/barbados'), - americaBelem(value: 'america/belem'), - americaBelize(value: 'america/belize'), - americaBlancSablon(value: 'america/blanc-sablon'), - americaBoaVista(value: 'america/boa_vista'), - americaBogota(value: 'america/bogota'), - americaBoise(value: 'america/boise'), - americaCambridgeBay(value: 'america/cambridge_bay'), - americaCampoGrande(value: 'america/campo_grande'), - americaCancun(value: 'america/cancun'), - americaCaracas(value: 'america/caracas'), - americaCayenne(value: 'america/cayenne'), - americaCayman(value: 'america/cayman'), - americaChicago(value: 'america/chicago'), - americaChihuahua(value: 'america/chihuahua'), - americaCiudadJuarez(value: 'america/ciudad_juarez'), - americaCostaRica(value: 'america/costa_rica'), - americaCoyhaique(value: 'america/coyhaique'), - americaCreston(value: 'america/creston'), - americaCuiaba(value: 'america/cuiaba'), - americaCuracao(value: 'america/curacao'), - americaDanmarkshavn(value: 'america/danmarkshavn'), - americaDawson(value: 'america/dawson'), - americaDawsonCreek(value: 'america/dawson_creek'), - americaDenver(value: 'america/denver'), - americaDetroit(value: 'america/detroit'), - americaDominica(value: 'america/dominica'), - americaEdmonton(value: 'america/edmonton'), - americaEirunepe(value: 'america/eirunepe'), - americaElSalvador(value: 'america/el_salvador'), - americaFortNelson(value: 'america/fort_nelson'), - americaFortaleza(value: 'america/fortaleza'), - americaGlaceBay(value: 'america/glace_bay'), - americaGooseBay(value: 'america/goose_bay'), - americaGrandTurk(value: 'america/grand_turk'), - americaGrenada(value: 'america/grenada'), - americaGuadeloupe(value: 'america/guadeloupe'), - americaGuatemala(value: 'america/guatemala'), - americaGuayaquil(value: 'america/guayaquil'), - americaGuyana(value: 'america/guyana'), - americaHalifax(value: 'america/halifax'), - americaHavana(value: 'america/havana'), - americaHermosillo(value: 'america/hermosillo'), - americaIndianaIndianapolis(value: 'america/indiana/indianapolis'), - americaIndianaKnox(value: 'america/indiana/knox'), - americaIndianaMarengo(value: 'america/indiana/marengo'), - americaIndianaPetersburg(value: 'america/indiana/petersburg'), - americaIndianaTellCity(value: 'america/indiana/tell_city'), - americaIndianaVevay(value: 'america/indiana/vevay'), - americaIndianaVincennes(value: 'america/indiana/vincennes'), - americaIndianaWinamac(value: 'america/indiana/winamac'), - americaInuvik(value: 'america/inuvik'), - americaIqaluit(value: 'america/iqaluit'), - americaJamaica(value: 'america/jamaica'), - americaJuneau(value: 'america/juneau'), - americaKentuckyLouisville(value: 'america/kentucky/louisville'), - americaKentuckyMonticello(value: 'america/kentucky/monticello'), - americaKralendijk(value: 'america/kralendijk'), - americaLaPaz(value: 'america/la_paz'), - americaLima(value: 'america/lima'), - americaLosAngeles(value: 'america/los_angeles'), - americaLowerPrinces(value: 'america/lower_princes'), - americaMaceio(value: 'america/maceio'), - americaManagua(value: 'america/managua'), - americaManaus(value: 'america/manaus'), - americaMarigot(value: 'america/marigot'), - americaMartinique(value: 'america/martinique'), - americaMatamoros(value: 'america/matamoros'), - americaMazatlan(value: 'america/mazatlan'), - americaMenominee(value: 'america/menominee'), - americaMerida(value: 'america/merida'), - americaMetlakatla(value: 'america/metlakatla'), - americaMexicoCity(value: 'america/mexico_city'), - americaMiquelon(value: 'america/miquelon'), - americaMoncton(value: 'america/moncton'), - americaMonterrey(value: 'america/monterrey'), - americaMontevideo(value: 'america/montevideo'), - americaMontserrat(value: 'america/montserrat'), - americaNassau(value: 'america/nassau'), - americaNewYork(value: 'america/new_york'), - americaNome(value: 'america/nome'), - americaNoronha(value: 'america/noronha'), - americaNorthDakotaBeulah(value: 'america/north_dakota/beulah'), - americaNorthDakotaCenter(value: 'america/north_dakota/center'), - americaNorthDakotaNewSalem(value: 'america/north_dakota/new_salem'), - americaNuuk(value: 'america/nuuk'), - americaOjinaga(value: 'america/ojinaga'), - americaPanama(value: 'america/panama'), - americaParamaribo(value: 'america/paramaribo'), - americaPhoenix(value: 'america/phoenix'), - americaPortAuPrince(value: 'america/port-au-prince'), - americaPortOfSpain(value: 'america/port_of_spain'), - americaPortoVelho(value: 'america/porto_velho'), - americaPuertoRico(value: 'america/puerto_rico'), - americaPuntaArenas(value: 'america/punta_arenas'), - americaRankinInlet(value: 'america/rankin_inlet'), - americaRecife(value: 'america/recife'), - americaRegina(value: 'america/regina'), - americaResolute(value: 'america/resolute'), - americaRioBranco(value: 'america/rio_branco'), - americaSantarem(value: 'america/santarem'), - americaSantiago(value: 'america/santiago'), - americaSantoDomingo(value: 'america/santo_domingo'), - americaSaoPaulo(value: 'america/sao_paulo'), - americaScoresbysund(value: 'america/scoresbysund'), - americaSitka(value: 'america/sitka'), - americaStBarthelemy(value: 'america/st_barthelemy'), - americaStJohns(value: 'america/st_johns'), - americaStKitts(value: 'america/st_kitts'), - americaStLucia(value: 'america/st_lucia'), - americaStThomas(value: 'america/st_thomas'), - americaStVincent(value: 'america/st_vincent'), - americaSwiftCurrent(value: 'america/swift_current'), - americaTegucigalpa(value: 'america/tegucigalpa'), - americaThule(value: 'america/thule'), - americaTijuana(value: 'america/tijuana'), - americaToronto(value: 'america/toronto'), - americaTortola(value: 'america/tortola'), - americaVancouver(value: 'america/vancouver'), - americaWhitehorse(value: 'america/whitehorse'), - americaWinnipeg(value: 'america/winnipeg'), - americaYakutat(value: 'america/yakutat'), - antarcticaCasey(value: 'antarctica/casey'), - antarcticaDavis(value: 'antarctica/davis'), - antarcticaDumontdurville(value: 'antarctica/dumontdurville'), - antarcticaMacquarie(value: 'antarctica/macquarie'), - antarcticaMawson(value: 'antarctica/mawson'), - antarcticaMcmurdo(value: 'antarctica/mcmurdo'), - antarcticaPalmer(value: 'antarctica/palmer'), - antarcticaRothera(value: 'antarctica/rothera'), - antarcticaSyowa(value: 'antarctica/syowa'), - antarcticaTroll(value: 'antarctica/troll'), - antarcticaVostok(value: 'antarctica/vostok'), - arcticLongyearbyen(value: 'arctic/longyearbyen'), - asiaAden(value: 'asia/aden'), - asiaAlmaty(value: 'asia/almaty'), - asiaAmman(value: 'asia/amman'), - asiaAnadyr(value: 'asia/anadyr'), - asiaAqtau(value: 'asia/aqtau'), - asiaAqtobe(value: 'asia/aqtobe'), - asiaAshgabat(value: 'asia/ashgabat'), - asiaAtyrau(value: 'asia/atyrau'), - asiaBaghdad(value: 'asia/baghdad'), - asiaBahrain(value: 'asia/bahrain'), - asiaBaku(value: 'asia/baku'), - asiaBangkok(value: 'asia/bangkok'), - asiaBarnaul(value: 'asia/barnaul'), - asiaBeirut(value: 'asia/beirut'), - asiaBishkek(value: 'asia/bishkek'), - asiaBrunei(value: 'asia/brunei'), - asiaChita(value: 'asia/chita'), - asiaColombo(value: 'asia/colombo'), - asiaDamascus(value: 'asia/damascus'), - asiaDhaka(value: 'asia/dhaka'), - asiaDili(value: 'asia/dili'), - asiaDubai(value: 'asia/dubai'), - asiaDushanbe(value: 'asia/dushanbe'), - asiaFamagusta(value: 'asia/famagusta'), - asiaGaza(value: 'asia/gaza'), - asiaHebron(value: 'asia/hebron'), - asiaHoChiMinh(value: 'asia/ho_chi_minh'), - asiaHongKong(value: 'asia/hong_kong'), - asiaHovd(value: 'asia/hovd'), - asiaIrkutsk(value: 'asia/irkutsk'), - asiaJakarta(value: 'asia/jakarta'), - asiaJayapura(value: 'asia/jayapura'), - asiaJerusalem(value: 'asia/jerusalem'), - asiaKabul(value: 'asia/kabul'), - asiaKamchatka(value: 'asia/kamchatka'), - asiaKarachi(value: 'asia/karachi'), - asiaKathmandu(value: 'asia/kathmandu'), - asiaKhandyga(value: 'asia/khandyga'), - asiaKolkata(value: 'asia/kolkata'), - asiaKrasnoyarsk(value: 'asia/krasnoyarsk'), - asiaKualaLumpur(value: 'asia/kuala_lumpur'), - asiaKuching(value: 'asia/kuching'), - asiaKuwait(value: 'asia/kuwait'), - asiaMacau(value: 'asia/macau'), - asiaMagadan(value: 'asia/magadan'), - asiaMakassar(value: 'asia/makassar'), - asiaManila(value: 'asia/manila'), - asiaMuscat(value: 'asia/muscat'), - asiaNicosia(value: 'asia/nicosia'), - asiaNovokuznetsk(value: 'asia/novokuznetsk'), - asiaNovosibirsk(value: 'asia/novosibirsk'), - asiaOmsk(value: 'asia/omsk'), - asiaOral(value: 'asia/oral'), - asiaPhnomPenh(value: 'asia/phnom_penh'), - asiaPontianak(value: 'asia/pontianak'), - asiaPyongyang(value: 'asia/pyongyang'), - asiaQatar(value: 'asia/qatar'), - asiaQostanay(value: 'asia/qostanay'), - asiaQyzylorda(value: 'asia/qyzylorda'), - asiaRiyadh(value: 'asia/riyadh'), - asiaSakhalin(value: 'asia/sakhalin'), - asiaSamarkand(value: 'asia/samarkand'), - asiaSeoul(value: 'asia/seoul'), - asiaShanghai(value: 'asia/shanghai'), - asiaSingapore(value: 'asia/singapore'), - asiaSrednekolymsk(value: 'asia/srednekolymsk'), - asiaTaipei(value: 'asia/taipei'), - asiaTashkent(value: 'asia/tashkent'), - asiaTbilisi(value: 'asia/tbilisi'), - asiaTehran(value: 'asia/tehran'), - asiaThimphu(value: 'asia/thimphu'), - asiaTokyo(value: 'asia/tokyo'), - asiaTomsk(value: 'asia/tomsk'), - asiaUlaanbaatar(value: 'asia/ulaanbaatar'), - asiaUrumqi(value: 'asia/urumqi'), - asiaUstNera(value: 'asia/ust-nera'), - asiaVientiane(value: 'asia/vientiane'), - asiaVladivostok(value: 'asia/vladivostok'), - asiaYakutsk(value: 'asia/yakutsk'), - asiaYangon(value: 'asia/yangon'), - asiaYekaterinburg(value: 'asia/yekaterinburg'), - asiaYerevan(value: 'asia/yerevan'), - atlanticAzores(value: 'atlantic/azores'), - atlanticBermuda(value: 'atlantic/bermuda'), - atlanticCanary(value: 'atlantic/canary'), - atlanticCapeVerde(value: 'atlantic/cape_verde'), - atlanticFaroe(value: 'atlantic/faroe'), - atlanticMadeira(value: 'atlantic/madeira'), - atlanticReykjavik(value: 'atlantic/reykjavik'), - atlanticSouthGeorgia(value: 'atlantic/south_georgia'), - atlanticStHelena(value: 'atlantic/st_helena'), - atlanticStanley(value: 'atlantic/stanley'), - australiaAdelaide(value: 'australia/adelaide'), - australiaBrisbane(value: 'australia/brisbane'), - australiaBrokenHill(value: 'australia/broken_hill'), - australiaDarwin(value: 'australia/darwin'), - australiaEucla(value: 'australia/eucla'), - australiaHobart(value: 'australia/hobart'), - australiaLindeman(value: 'australia/lindeman'), - australiaLordHowe(value: 'australia/lord_howe'), - australiaMelbourne(value: 'australia/melbourne'), - australiaPerth(value: 'australia/perth'), - australiaSydney(value: 'australia/sydney'), - europeAmsterdam(value: 'europe/amsterdam'), - europeAndorra(value: 'europe/andorra'), - europeAstrakhan(value: 'europe/astrakhan'), - europeAthens(value: 'europe/athens'), - europeBelgrade(value: 'europe/belgrade'), - europeBerlin(value: 'europe/berlin'), - europeBratislava(value: 'europe/bratislava'), - europeBrussels(value: 'europe/brussels'), - europeBucharest(value: 'europe/bucharest'), - europeBudapest(value: 'europe/budapest'), - europeBusingen(value: 'europe/busingen'), - europeChisinau(value: 'europe/chisinau'), - europeCopenhagen(value: 'europe/copenhagen'), - europeDublin(value: 'europe/dublin'), - europeGibraltar(value: 'europe/gibraltar'), - europeGuernsey(value: 'europe/guernsey'), - europeHelsinki(value: 'europe/helsinki'), - europeIsleOfMan(value: 'europe/isle_of_man'), - europeIstanbul(value: 'europe/istanbul'), - europeJersey(value: 'europe/jersey'), - europeKaliningrad(value: 'europe/kaliningrad'), - europeKirov(value: 'europe/kirov'), - europeKyiv(value: 'europe/kyiv'), - europeLisbon(value: 'europe/lisbon'), - europeLjubljana(value: 'europe/ljubljana'), - europeLondon(value: 'europe/london'), - europeLuxembourg(value: 'europe/luxembourg'), - europeMadrid(value: 'europe/madrid'), - europeMalta(value: 'europe/malta'), - europeMariehamn(value: 'europe/mariehamn'), - europeMinsk(value: 'europe/minsk'), - europeMonaco(value: 'europe/monaco'), - europeMoscow(value: 'europe/moscow'), - europeOslo(value: 'europe/oslo'), - europeParis(value: 'europe/paris'), - europePodgorica(value: 'europe/podgorica'), - europePrague(value: 'europe/prague'), - europeRiga(value: 'europe/riga'), - europeRome(value: 'europe/rome'), - europeSamara(value: 'europe/samara'), - europeSanMarino(value: 'europe/san_marino'), - europeSarajevo(value: 'europe/sarajevo'), - europeSaratov(value: 'europe/saratov'), - europeSimferopol(value: 'europe/simferopol'), - europeSkopje(value: 'europe/skopje'), - europeSofia(value: 'europe/sofia'), - europeStockholm(value: 'europe/stockholm'), - europeTallinn(value: 'europe/tallinn'), - europeTirane(value: 'europe/tirane'), - europeUlyanovsk(value: 'europe/ulyanovsk'), - europeVaduz(value: 'europe/vaduz'), - europeVatican(value: 'europe/vatican'), - europeVienna(value: 'europe/vienna'), - europeVilnius(value: 'europe/vilnius'), - europeVolgograd(value: 'europe/volgograd'), - europeWarsaw(value: 'europe/warsaw'), - europeZagreb(value: 'europe/zagreb'), - europeZurich(value: 'europe/zurich'), - indianAntananarivo(value: 'indian/antananarivo'), - indianChagos(value: 'indian/chagos'), - indianChristmas(value: 'indian/christmas'), - indianCocos(value: 'indian/cocos'), - indianComoro(value: 'indian/comoro'), - indianKerguelen(value: 'indian/kerguelen'), - indianMahe(value: 'indian/mahe'), - indianMaldives(value: 'indian/maldives'), - indianMauritius(value: 'indian/mauritius'), - indianMayotte(value: 'indian/mayotte'), - indianReunion(value: 'indian/reunion'), - pacificApia(value: 'pacific/apia'), - pacificAuckland(value: 'pacific/auckland'), - pacificBougainville(value: 'pacific/bougainville'), - pacificChatham(value: 'pacific/chatham'), - pacificChuuk(value: 'pacific/chuuk'), - pacificEaster(value: 'pacific/easter'), - pacificEfate(value: 'pacific/efate'), - pacificFakaofo(value: 'pacific/fakaofo'), - pacificFiji(value: 'pacific/fiji'), - pacificFunafuti(value: 'pacific/funafuti'), - pacificGalapagos(value: 'pacific/galapagos'), - pacificGambier(value: 'pacific/gambier'), - pacificGuadalcanal(value: 'pacific/guadalcanal'), - pacificGuam(value: 'pacific/guam'), - pacificHonolulu(value: 'pacific/honolulu'), - pacificKanton(value: 'pacific/kanton'), - pacificKiritimati(value: 'pacific/kiritimati'), - pacificKosrae(value: 'pacific/kosrae'), - pacificKwajalein(value: 'pacific/kwajalein'), - pacificMajuro(value: 'pacific/majuro'), - pacificMarquesas(value: 'pacific/marquesas'), - pacificMidway(value: 'pacific/midway'), - pacificNauru(value: 'pacific/nauru'), - pacificNiue(value: 'pacific/niue'), - pacificNorfolk(value: 'pacific/norfolk'), - pacificNoumea(value: 'pacific/noumea'), - pacificPagoPago(value: 'pacific/pago_pago'), - pacificPalau(value: 'pacific/palau'), - pacificPitcairn(value: 'pacific/pitcairn'), - pacificPohnpei(value: 'pacific/pohnpei'), - pacificPortMoresby(value: 'pacific/port_moresby'), - pacificRarotonga(value: 'pacific/rarotonga'), - pacificSaipan(value: 'pacific/saipan'), - pacificTahiti(value: 'pacific/tahiti'), - pacificTarawa(value: 'pacific/tarawa'), - pacificTongatapu(value: 'pacific/tongatapu'), - pacificWake(value: 'pacific/wake'), - pacificWallis(value: 'pacific/wallis'), - utc(value: 'utc'); + africaAbidjan(value: 'africa/abidjan'), + africaAccra(value: 'africa/accra'), + africaAddisAbaba(value: 'africa/addis_ababa'), + africaAlgiers(value: 'africa/algiers'), + africaAsmara(value: 'africa/asmara'), + africaBamako(value: 'africa/bamako'), + africaBangui(value: 'africa/bangui'), + africaBanjul(value: 'africa/banjul'), + africaBissau(value: 'africa/bissau'), + africaBlantyre(value: 'africa/blantyre'), + africaBrazzaville(value: 'africa/brazzaville'), + africaBujumbura(value: 'africa/bujumbura'), + africaCairo(value: 'africa/cairo'), + africaCasablanca(value: 'africa/casablanca'), + africaCeuta(value: 'africa/ceuta'), + africaConakry(value: 'africa/conakry'), + africaDakar(value: 'africa/dakar'), + africaDarEsSalaam(value: 'africa/dar_es_salaam'), + africaDjibouti(value: 'africa/djibouti'), + africaDouala(value: 'africa/douala'), + africaElAaiun(value: 'africa/el_aaiun'), + africaFreetown(value: 'africa/freetown'), + africaGaborone(value: 'africa/gaborone'), + africaHarare(value: 'africa/harare'), + africaJohannesburg(value: 'africa/johannesburg'), + africaJuba(value: 'africa/juba'), + africaKampala(value: 'africa/kampala'), + africaKhartoum(value: 'africa/khartoum'), + africaKigali(value: 'africa/kigali'), + africaKinshasa(value: 'africa/kinshasa'), + africaLagos(value: 'africa/lagos'), + africaLibreville(value: 'africa/libreville'), + africaLome(value: 'africa/lome'), + africaLuanda(value: 'africa/luanda'), + africaLubumbashi(value: 'africa/lubumbashi'), + africaLusaka(value: 'africa/lusaka'), + africaMalabo(value: 'africa/malabo'), + africaMaputo(value: 'africa/maputo'), + africaMaseru(value: 'africa/maseru'), + africaMbabane(value: 'africa/mbabane'), + africaMogadishu(value: 'africa/mogadishu'), + africaMonrovia(value: 'africa/monrovia'), + africaNairobi(value: 'africa/nairobi'), + africaNdjamena(value: 'africa/ndjamena'), + africaNiamey(value: 'africa/niamey'), + africaNouakchott(value: 'africa/nouakchott'), + africaOuagadougou(value: 'africa/ouagadougou'), + africaPortoNovo(value: 'africa/porto-novo'), + africaSaoTome(value: 'africa/sao_tome'), + africaTripoli(value: 'africa/tripoli'), + africaTunis(value: 'africa/tunis'), + africaWindhoek(value: 'africa/windhoek'), + americaAdak(value: 'america/adak'), + americaAnchorage(value: 'america/anchorage'), + americaAnguilla(value: 'america/anguilla'), + americaAntigua(value: 'america/antigua'), + americaAraguaina(value: 'america/araguaina'), + americaArgentinaBuenosAires(value: 'america/argentina/buenos_aires'), + americaArgentinaCatamarca(value: 'america/argentina/catamarca'), + americaArgentinaCordoba(value: 'america/argentina/cordoba'), + americaArgentinaJujuy(value: 'america/argentina/jujuy'), + americaArgentinaLaRioja(value: 'america/argentina/la_rioja'), + americaArgentinaMendoza(value: 'america/argentina/mendoza'), + americaArgentinaRioGallegos(value: 'america/argentina/rio_gallegos'), + americaArgentinaSalta(value: 'america/argentina/salta'), + americaArgentinaSanJuan(value: 'america/argentina/san_juan'), + americaArgentinaSanLuis(value: 'america/argentina/san_luis'), + americaArgentinaTucuman(value: 'america/argentina/tucuman'), + americaArgentinaUshuaia(value: 'america/argentina/ushuaia'), + americaAruba(value: 'america/aruba'), + americaAsuncion(value: 'america/asuncion'), + americaAtikokan(value: 'america/atikokan'), + americaBahia(value: 'america/bahia'), + americaBahiaBanderas(value: 'america/bahia_banderas'), + americaBarbados(value: 'america/barbados'), + americaBelem(value: 'america/belem'), + americaBelize(value: 'america/belize'), + americaBlancSablon(value: 'america/blanc-sablon'), + americaBoaVista(value: 'america/boa_vista'), + americaBogota(value: 'america/bogota'), + americaBoise(value: 'america/boise'), + americaCambridgeBay(value: 'america/cambridge_bay'), + americaCampoGrande(value: 'america/campo_grande'), + americaCancun(value: 'america/cancun'), + americaCaracas(value: 'america/caracas'), + americaCayenne(value: 'america/cayenne'), + americaCayman(value: 'america/cayman'), + americaChicago(value: 'america/chicago'), + americaChihuahua(value: 'america/chihuahua'), + americaCiudadJuarez(value: 'america/ciudad_juarez'), + americaCostaRica(value: 'america/costa_rica'), + americaCoyhaique(value: 'america/coyhaique'), + americaCreston(value: 'america/creston'), + americaCuiaba(value: 'america/cuiaba'), + americaCuracao(value: 'america/curacao'), + americaDanmarkshavn(value: 'america/danmarkshavn'), + americaDawson(value: 'america/dawson'), + americaDawsonCreek(value: 'america/dawson_creek'), + americaDenver(value: 'america/denver'), + americaDetroit(value: 'america/detroit'), + americaDominica(value: 'america/dominica'), + americaEdmonton(value: 'america/edmonton'), + americaEirunepe(value: 'america/eirunepe'), + americaElSalvador(value: 'america/el_salvador'), + americaFortNelson(value: 'america/fort_nelson'), + americaFortaleza(value: 'america/fortaleza'), + americaGlaceBay(value: 'america/glace_bay'), + americaGooseBay(value: 'america/goose_bay'), + americaGrandTurk(value: 'america/grand_turk'), + americaGrenada(value: 'america/grenada'), + americaGuadeloupe(value: 'america/guadeloupe'), + americaGuatemala(value: 'america/guatemala'), + americaGuayaquil(value: 'america/guayaquil'), + americaGuyana(value: 'america/guyana'), + americaHalifax(value: 'america/halifax'), + americaHavana(value: 'america/havana'), + americaHermosillo(value: 'america/hermosillo'), + americaIndianaIndianapolis(value: 'america/indiana/indianapolis'), + americaIndianaKnox(value: 'america/indiana/knox'), + americaIndianaMarengo(value: 'america/indiana/marengo'), + americaIndianaPetersburg(value: 'america/indiana/petersburg'), + americaIndianaTellCity(value: 'america/indiana/tell_city'), + americaIndianaVevay(value: 'america/indiana/vevay'), + americaIndianaVincennes(value: 'america/indiana/vincennes'), + americaIndianaWinamac(value: 'america/indiana/winamac'), + americaInuvik(value: 'america/inuvik'), + americaIqaluit(value: 'america/iqaluit'), + americaJamaica(value: 'america/jamaica'), + americaJuneau(value: 'america/juneau'), + americaKentuckyLouisville(value: 'america/kentucky/louisville'), + americaKentuckyMonticello(value: 'america/kentucky/monticello'), + americaKralendijk(value: 'america/kralendijk'), + americaLaPaz(value: 'america/la_paz'), + americaLima(value: 'america/lima'), + americaLosAngeles(value: 'america/los_angeles'), + americaLowerPrinces(value: 'america/lower_princes'), + americaMaceio(value: 'america/maceio'), + americaManagua(value: 'america/managua'), + americaManaus(value: 'america/manaus'), + americaMarigot(value: 'america/marigot'), + americaMartinique(value: 'america/martinique'), + americaMatamoros(value: 'america/matamoros'), + americaMazatlan(value: 'america/mazatlan'), + americaMenominee(value: 'america/menominee'), + americaMerida(value: 'america/merida'), + americaMetlakatla(value: 'america/metlakatla'), + americaMexicoCity(value: 'america/mexico_city'), + americaMiquelon(value: 'america/miquelon'), + americaMoncton(value: 'america/moncton'), + americaMonterrey(value: 'america/monterrey'), + americaMontevideo(value: 'america/montevideo'), + americaMontserrat(value: 'america/montserrat'), + americaNassau(value: 'america/nassau'), + americaNewYork(value: 'america/new_york'), + americaNome(value: 'america/nome'), + americaNoronha(value: 'america/noronha'), + americaNorthDakotaBeulah(value: 'america/north_dakota/beulah'), + americaNorthDakotaCenter(value: 'america/north_dakota/center'), + americaNorthDakotaNewSalem(value: 'america/north_dakota/new_salem'), + americaNuuk(value: 'america/nuuk'), + americaOjinaga(value: 'america/ojinaga'), + americaPanama(value: 'america/panama'), + americaParamaribo(value: 'america/paramaribo'), + americaPhoenix(value: 'america/phoenix'), + americaPortAuPrince(value: 'america/port-au-prince'), + americaPortOfSpain(value: 'america/port_of_spain'), + americaPortoVelho(value: 'america/porto_velho'), + americaPuertoRico(value: 'america/puerto_rico'), + americaPuntaArenas(value: 'america/punta_arenas'), + americaRankinInlet(value: 'america/rankin_inlet'), + americaRecife(value: 'america/recife'), + americaRegina(value: 'america/regina'), + americaResolute(value: 'america/resolute'), + americaRioBranco(value: 'america/rio_branco'), + americaSantarem(value: 'america/santarem'), + americaSantiago(value: 'america/santiago'), + americaSantoDomingo(value: 'america/santo_domingo'), + americaSaoPaulo(value: 'america/sao_paulo'), + americaScoresbysund(value: 'america/scoresbysund'), + americaSitka(value: 'america/sitka'), + americaStBarthelemy(value: 'america/st_barthelemy'), + americaStJohns(value: 'america/st_johns'), + americaStKitts(value: 'america/st_kitts'), + americaStLucia(value: 'america/st_lucia'), + americaStThomas(value: 'america/st_thomas'), + americaStVincent(value: 'america/st_vincent'), + americaSwiftCurrent(value: 'america/swift_current'), + americaTegucigalpa(value: 'america/tegucigalpa'), + americaThule(value: 'america/thule'), + americaTijuana(value: 'america/tijuana'), + americaToronto(value: 'america/toronto'), + americaTortola(value: 'america/tortola'), + americaVancouver(value: 'america/vancouver'), + americaWhitehorse(value: 'america/whitehorse'), + americaWinnipeg(value: 'america/winnipeg'), + americaYakutat(value: 'america/yakutat'), + antarcticaCasey(value: 'antarctica/casey'), + antarcticaDavis(value: 'antarctica/davis'), + antarcticaDumontdurville(value: 'antarctica/dumontdurville'), + antarcticaMacquarie(value: 'antarctica/macquarie'), + antarcticaMawson(value: 'antarctica/mawson'), + antarcticaMcmurdo(value: 'antarctica/mcmurdo'), + antarcticaPalmer(value: 'antarctica/palmer'), + antarcticaRothera(value: 'antarctica/rothera'), + antarcticaSyowa(value: 'antarctica/syowa'), + antarcticaTroll(value: 'antarctica/troll'), + antarcticaVostok(value: 'antarctica/vostok'), + arcticLongyearbyen(value: 'arctic/longyearbyen'), + asiaAden(value: 'asia/aden'), + asiaAlmaty(value: 'asia/almaty'), + asiaAmman(value: 'asia/amman'), + asiaAnadyr(value: 'asia/anadyr'), + asiaAqtau(value: 'asia/aqtau'), + asiaAqtobe(value: 'asia/aqtobe'), + asiaAshgabat(value: 'asia/ashgabat'), + asiaAtyrau(value: 'asia/atyrau'), + asiaBaghdad(value: 'asia/baghdad'), + asiaBahrain(value: 'asia/bahrain'), + asiaBaku(value: 'asia/baku'), + asiaBangkok(value: 'asia/bangkok'), + asiaBarnaul(value: 'asia/barnaul'), + asiaBeirut(value: 'asia/beirut'), + asiaBishkek(value: 'asia/bishkek'), + asiaBrunei(value: 'asia/brunei'), + asiaChita(value: 'asia/chita'), + asiaColombo(value: 'asia/colombo'), + asiaDamascus(value: 'asia/damascus'), + asiaDhaka(value: 'asia/dhaka'), + asiaDili(value: 'asia/dili'), + asiaDubai(value: 'asia/dubai'), + asiaDushanbe(value: 'asia/dushanbe'), + asiaFamagusta(value: 'asia/famagusta'), + asiaGaza(value: 'asia/gaza'), + asiaHebron(value: 'asia/hebron'), + asiaHoChiMinh(value: 'asia/ho_chi_minh'), + asiaHongKong(value: 'asia/hong_kong'), + asiaHovd(value: 'asia/hovd'), + asiaIrkutsk(value: 'asia/irkutsk'), + asiaJakarta(value: 'asia/jakarta'), + asiaJayapura(value: 'asia/jayapura'), + asiaJerusalem(value: 'asia/jerusalem'), + asiaKabul(value: 'asia/kabul'), + asiaKamchatka(value: 'asia/kamchatka'), + asiaKarachi(value: 'asia/karachi'), + asiaKathmandu(value: 'asia/kathmandu'), + asiaKhandyga(value: 'asia/khandyga'), + asiaKolkata(value: 'asia/kolkata'), + asiaKrasnoyarsk(value: 'asia/krasnoyarsk'), + asiaKualaLumpur(value: 'asia/kuala_lumpur'), + asiaKuching(value: 'asia/kuching'), + asiaKuwait(value: 'asia/kuwait'), + asiaMacau(value: 'asia/macau'), + asiaMagadan(value: 'asia/magadan'), + asiaMakassar(value: 'asia/makassar'), + asiaManila(value: 'asia/manila'), + asiaMuscat(value: 'asia/muscat'), + asiaNicosia(value: 'asia/nicosia'), + asiaNovokuznetsk(value: 'asia/novokuznetsk'), + asiaNovosibirsk(value: 'asia/novosibirsk'), + asiaOmsk(value: 'asia/omsk'), + asiaOral(value: 'asia/oral'), + asiaPhnomPenh(value: 'asia/phnom_penh'), + asiaPontianak(value: 'asia/pontianak'), + asiaPyongyang(value: 'asia/pyongyang'), + asiaQatar(value: 'asia/qatar'), + asiaQostanay(value: 'asia/qostanay'), + asiaQyzylorda(value: 'asia/qyzylorda'), + asiaRiyadh(value: 'asia/riyadh'), + asiaSakhalin(value: 'asia/sakhalin'), + asiaSamarkand(value: 'asia/samarkand'), + asiaSeoul(value: 'asia/seoul'), + asiaShanghai(value: 'asia/shanghai'), + asiaSingapore(value: 'asia/singapore'), + asiaSrednekolymsk(value: 'asia/srednekolymsk'), + asiaTaipei(value: 'asia/taipei'), + asiaTashkent(value: 'asia/tashkent'), + asiaTbilisi(value: 'asia/tbilisi'), + asiaTehran(value: 'asia/tehran'), + asiaThimphu(value: 'asia/thimphu'), + asiaTokyo(value: 'asia/tokyo'), + asiaTomsk(value: 'asia/tomsk'), + asiaUlaanbaatar(value: 'asia/ulaanbaatar'), + asiaUrumqi(value: 'asia/urumqi'), + asiaUstNera(value: 'asia/ust-nera'), + asiaVientiane(value: 'asia/vientiane'), + asiaVladivostok(value: 'asia/vladivostok'), + asiaYakutsk(value: 'asia/yakutsk'), + asiaYangon(value: 'asia/yangon'), + asiaYekaterinburg(value: 'asia/yekaterinburg'), + asiaYerevan(value: 'asia/yerevan'), + atlanticAzores(value: 'atlantic/azores'), + atlanticBermuda(value: 'atlantic/bermuda'), + atlanticCanary(value: 'atlantic/canary'), + atlanticCapeVerde(value: 'atlantic/cape_verde'), + atlanticFaroe(value: 'atlantic/faroe'), + atlanticMadeira(value: 'atlantic/madeira'), + atlanticReykjavik(value: 'atlantic/reykjavik'), + atlanticSouthGeorgia(value: 'atlantic/south_georgia'), + atlanticStHelena(value: 'atlantic/st_helena'), + atlanticStanley(value: 'atlantic/stanley'), + australiaAdelaide(value: 'australia/adelaide'), + australiaBrisbane(value: 'australia/brisbane'), + australiaBrokenHill(value: 'australia/broken_hill'), + australiaDarwin(value: 'australia/darwin'), + australiaEucla(value: 'australia/eucla'), + australiaHobart(value: 'australia/hobart'), + australiaLindeman(value: 'australia/lindeman'), + australiaLordHowe(value: 'australia/lord_howe'), + australiaMelbourne(value: 'australia/melbourne'), + australiaPerth(value: 'australia/perth'), + australiaSydney(value: 'australia/sydney'), + europeAmsterdam(value: 'europe/amsterdam'), + europeAndorra(value: 'europe/andorra'), + europeAstrakhan(value: 'europe/astrakhan'), + europeAthens(value: 'europe/athens'), + europeBelgrade(value: 'europe/belgrade'), + europeBerlin(value: 'europe/berlin'), + europeBratislava(value: 'europe/bratislava'), + europeBrussels(value: 'europe/brussels'), + europeBucharest(value: 'europe/bucharest'), + europeBudapest(value: 'europe/budapest'), + europeBusingen(value: 'europe/busingen'), + europeChisinau(value: 'europe/chisinau'), + europeCopenhagen(value: 'europe/copenhagen'), + europeDublin(value: 'europe/dublin'), + europeGibraltar(value: 'europe/gibraltar'), + europeGuernsey(value: 'europe/guernsey'), + europeHelsinki(value: 'europe/helsinki'), + europeIsleOfMan(value: 'europe/isle_of_man'), + europeIstanbul(value: 'europe/istanbul'), + europeJersey(value: 'europe/jersey'), + europeKaliningrad(value: 'europe/kaliningrad'), + europeKirov(value: 'europe/kirov'), + europeKyiv(value: 'europe/kyiv'), + europeLisbon(value: 'europe/lisbon'), + europeLjubljana(value: 'europe/ljubljana'), + europeLondon(value: 'europe/london'), + europeLuxembourg(value: 'europe/luxembourg'), + europeMadrid(value: 'europe/madrid'), + europeMalta(value: 'europe/malta'), + europeMariehamn(value: 'europe/mariehamn'), + europeMinsk(value: 'europe/minsk'), + europeMonaco(value: 'europe/monaco'), + europeMoscow(value: 'europe/moscow'), + europeOslo(value: 'europe/oslo'), + europeParis(value: 'europe/paris'), + europePodgorica(value: 'europe/podgorica'), + europePrague(value: 'europe/prague'), + europeRiga(value: 'europe/riga'), + europeRome(value: 'europe/rome'), + europeSamara(value: 'europe/samara'), + europeSanMarino(value: 'europe/san_marino'), + europeSarajevo(value: 'europe/sarajevo'), + europeSaratov(value: 'europe/saratov'), + europeSimferopol(value: 'europe/simferopol'), + europeSkopje(value: 'europe/skopje'), + europeSofia(value: 'europe/sofia'), + europeStockholm(value: 'europe/stockholm'), + europeTallinn(value: 'europe/tallinn'), + europeTirane(value: 'europe/tirane'), + europeUlyanovsk(value: 'europe/ulyanovsk'), + europeVaduz(value: 'europe/vaduz'), + europeVatican(value: 'europe/vatican'), + europeVienna(value: 'europe/vienna'), + europeVilnius(value: 'europe/vilnius'), + europeVolgograd(value: 'europe/volgograd'), + europeWarsaw(value: 'europe/warsaw'), + europeZagreb(value: 'europe/zagreb'), + europeZurich(value: 'europe/zurich'), + indianAntananarivo(value: 'indian/antananarivo'), + indianChagos(value: 'indian/chagos'), + indianChristmas(value: 'indian/christmas'), + indianCocos(value: 'indian/cocos'), + indianComoro(value: 'indian/comoro'), + indianKerguelen(value: 'indian/kerguelen'), + indianMahe(value: 'indian/mahe'), + indianMaldives(value: 'indian/maldives'), + indianMauritius(value: 'indian/mauritius'), + indianMayotte(value: 'indian/mayotte'), + indianReunion(value: 'indian/reunion'), + pacificApia(value: 'pacific/apia'), + pacificAuckland(value: 'pacific/auckland'), + pacificBougainville(value: 'pacific/bougainville'), + pacificChatham(value: 'pacific/chatham'), + pacificChuuk(value: 'pacific/chuuk'), + pacificEaster(value: 'pacific/easter'), + pacificEfate(value: 'pacific/efate'), + pacificFakaofo(value: 'pacific/fakaofo'), + pacificFiji(value: 'pacific/fiji'), + pacificFunafuti(value: 'pacific/funafuti'), + pacificGalapagos(value: 'pacific/galapagos'), + pacificGambier(value: 'pacific/gambier'), + pacificGuadalcanal(value: 'pacific/guadalcanal'), + pacificGuam(value: 'pacific/guam'), + pacificHonolulu(value: 'pacific/honolulu'), + pacificKanton(value: 'pacific/kanton'), + pacificKiritimati(value: 'pacific/kiritimati'), + pacificKosrae(value: 'pacific/kosrae'), + pacificKwajalein(value: 'pacific/kwajalein'), + pacificMajuro(value: 'pacific/majuro'), + pacificMarquesas(value: 'pacific/marquesas'), + pacificMidway(value: 'pacific/midway'), + pacificNauru(value: 'pacific/nauru'), + pacificNiue(value: 'pacific/niue'), + pacificNorfolk(value: 'pacific/norfolk'), + pacificNoumea(value: 'pacific/noumea'), + pacificPagoPago(value: 'pacific/pago_pago'), + pacificPalau(value: 'pacific/palau'), + pacificPitcairn(value: 'pacific/pitcairn'), + pacificPohnpei(value: 'pacific/pohnpei'), + pacificPortMoresby(value: 'pacific/port_moresby'), + pacificRarotonga(value: 'pacific/rarotonga'), + pacificSaipan(value: 'pacific/saipan'), + pacificTahiti(value: 'pacific/tahiti'), + pacificTarawa(value: 'pacific/tarawa'), + pacificTongatapu(value: 'pacific/tongatapu'), + pacificWake(value: 'pacific/wake'), + pacificWallis(value: 'pacific/wallis'), + utc(value: 'utc'); - const Timezone({ - required this.value - }); + const Timezone({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 f80fa854..344a8770 100644 --- a/lib/src/models/algo_argon2.dart +++ b/lib/src/models/algo_argon2.dart @@ -2,41 +2,41 @@ 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'], + ); + } - @override - Map toMap() { - return { - "type": type, - "memoryCost": memoryCost, - "timeCost": timeCost, - "threads": threads, - }; - } + @override + 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 c51da4bb..9909265e 100644 --- a/lib/src/models/algo_bcrypt.dart +++ b/lib/src/models/algo_bcrypt.dart @@ -2,23 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return { - "type": type, - }; - } + @override + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_md5.dart b/lib/src/models/algo_md5.dart index 43523ab1..746fbd52 100644 --- a/lib/src/models/algo_md5.dart +++ b/lib/src/models/algo_md5.dart @@ -2,23 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return { - "type": type, - }; - } + @override + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_phpass.dart b/lib/src/models/algo_phpass.dart index 8562c4e3..cab45e49 100644 --- a/lib/src/models/algo_phpass.dart +++ b/lib/src/models/algo_phpass.dart @@ -2,23 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return { - "type": type, - }; - } + @override + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_scrypt.dart b/lib/src/models/algo_scrypt.dart index 8e844839..a1648843 100644 --- a/lib/src/models/algo_scrypt.dart +++ b/lib/src/models/algo_scrypt.dart @@ -2,47 +2,47 @@ 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'], - ); - } - - @override - 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'], + ); + } + + @override + 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 5202db05..33ef4a6f 100644 --- a/lib/src/models/algo_scrypt_modified.dart +++ b/lib/src/models/algo_scrypt_modified.dart @@ -2,41 +2,41 @@ 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(), + ); + } - @override - Map toMap() { - return { - "type": type, - "salt": salt, - "saltSeparator": saltSeparator, - "signerKey": signerKey, - }; - } + @override + 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 3d08af9f..4984df75 100644 --- a/lib/src/models/algo_sha.dart +++ b/lib/src/models/algo_sha.dart @@ -2,23 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return { - "type": type, - }; - } + @override + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/continent.dart b/lib/src/models/continent.dart index 930900bf..ec3c41be 100644 --- a/lib/src/models/continent.dart +++ b/lib/src/models/continent.dart @@ -2,29 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return { - "name": name, - "code": code, - }; - } + @override + Map toMap() { + return { + "name": name, + "code": code, + }; + } } diff --git a/lib/src/models/continent_list.dart b/lib/src/models/continent_list.dart index 753bcacc..df28f04b 100644 --- a/lib/src/models/continent_list.dart +++ b/lib/src/models/continent_list.dart @@ -2,29 +2,30 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "continents": continents.map((p) => p.toMap()).toList(), - }; - } + @override + 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 c4838ba3..3bcbb76d 100644 --- a/lib/src/models/country.dart +++ b/lib/src/models/country.dart @@ -2,29 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return { - "name": name, - "code": code, - }; - } + @override + Map toMap() { + return { + "name": name, + "code": code, + }; + } } diff --git a/lib/src/models/country_list.dart b/lib/src/models/country_list.dart index f363a54b..79cb1256 100644 --- a/lib/src/models/country_list.dart +++ b/lib/src/models/country_list.dart @@ -2,29 +2,30 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "countries": countries.map((p) => p.toMap()).toList(), - }; - } + @override + 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 b6bb455f..f2b18093 100644 --- a/lib/src/models/currency.dart +++ b/lib/src/models/currency.dart @@ -2,59 +2,59 @@ 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(), - ); - } - - @override - 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(), + ); + } + + @override + 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 eb2bad19..6c39ae2e 100644 --- a/lib/src/models/currency_list.dart +++ b/lib/src/models/currency_list.dart @@ -2,29 +2,30 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "currencies": currencies.map((p) => p.toMap()).toList(), - }; - } + @override + 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 0d1fdeb0..be08d599 100644 --- a/lib/src/models/document.dart +++ b/lib/src/models/document.dart @@ -2,66 +2,66 @@ part of '../../models.dart'; /// Document class Document implements Model { - /// Document ID. - final String $id; + /// Document ID. + final String $id; - /// Document sequence ID. - final String $sequence; + /// Document sequence ID. + final String $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'].toString(), - $collectionId: map['\$collectionId'].toString(), - $databaseId: map['\$databaseId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - data: map["data"] ?? map, - ); - } + factory Document.fromMap(Map map) { + return Document( + $id: map['\$id'].toString(), + $sequence: map['\$sequence'].toString(), + $collectionId: map['\$collectionId'].toString(), + $databaseId: map['\$databaseId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + data: map["data"] ?? map, + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$sequence": $sequence, - "\$collectionId": $collectionId, - "\$databaseId": $databaseId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "data": data, - }; - } + @override + 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 0e30844a..76a07309 100644 --- a/lib/src/models/document_list.dart +++ b/lib/src/models/document_list.dart @@ -2,32 +2,33 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "documents": documents.map((p) => p.toMap()).toList(), - }; - } + @override + 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 3e767ca3..3629e1d6 100644 --- a/lib/src/models/execution.dart +++ b/lib/src/models/execution.dart @@ -2,125 +2,129 @@ 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 enums.ExecutionTrigger trigger; - - /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, `failed`, or `scheduled`. - final enums.ExecutionStatus status; - - /// HTTP request method type. - final String requestMethod; - - /// HTTP request path and query. - final String requestPath; - - /// HTTP request 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: enums.ExecutionTrigger.values.firstWhere((e) => e.value == map['trigger']), - status: enums.ExecutionStatus.values.firstWhere((e) => e.value == map['status']), - 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(), - ); - } - - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "functionId": functionId, - "deploymentId": deploymentId, - "trigger": trigger.value, - "status": status.value, - "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 enums.ExecutionTrigger trigger; + + /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, `failed`, or `scheduled`. + final enums.ExecutionStatus status; + + /// HTTP request method type. + final String requestMethod; + + /// HTTP request path and query. + final String requestPath; + + /// HTTP request 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: enums.ExecutionTrigger.values + .firstWhere((e) => e.value == map['trigger']), + status: enums.ExecutionStatus.values + .firstWhere((e) => e.value == map['status']), + 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(), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "functionId": functionId, + "deploymentId": deploymentId, + "trigger": trigger.value, + "status": status.value, + "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 45b60682..63c2ad7e 100644 --- a/lib/src/models/execution_list.dart +++ b/lib/src/models/execution_list.dart @@ -2,29 +2,30 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "executions": executions.map((p) => p.toMap()).toList(), - }; - } + @override + 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 9e5f9eb1..01cdcb3a 100644 --- a/lib/src/models/file.dart +++ b/lib/src/models/file.dart @@ -2,101 +2,101 @@ part of '../../models.dart'; /// File class File implements Model { - /// File ID. - final String $id; - - /// Bucket ID. - final String bucketId; - - /// File creation date in ISO 8601 format. - final String $createdAt; - - /// 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 name. - final String name; - - /// File MD5 signature. - final String signature; - - /// File mime type. - final String mimeType; - - /// File original size in bytes. - final int sizeOriginal; - - /// File actual stored size in bytes after compression and/or encryption. - final int sizeActual; - - /// Total number of chunks available - final int chunksTotal; - - /// Total number of chunks uploaded - final int chunksUploaded; - - /// Whether file contents are encrypted at rest. - final bool encryption; - - /// Compression algorithm used for the file. Will be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd). - final String compression; - - 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.sizeActual, - required this.chunksTotal, - required this.chunksUploaded, - required this.encryption, - required this.compression, - }); - - 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'], - sizeActual: map['sizeActual'], - chunksTotal: map['chunksTotal'], - chunksUploaded: map['chunksUploaded'], - encryption: map['encryption'], - compression: map['compression'].toString(), - ); - } - - @override - Map toMap() { - return { - "\$id": $id, - "bucketId": bucketId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "name": name, - "signature": signature, - "mimeType": mimeType, - "sizeOriginal": sizeOriginal, - "sizeActual": sizeActual, - "chunksTotal": chunksTotal, - "chunksUploaded": chunksUploaded, - "encryption": encryption, - "compression": compression, - }; - } + /// File ID. + final String $id; + + /// Bucket ID. + final String bucketId; + + /// File creation date in ISO 8601 format. + final String $createdAt; + + /// 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 name. + final String name; + + /// File MD5 signature. + final String signature; + + /// File mime type. + final String mimeType; + + /// File original size in bytes. + final int sizeOriginal; + + /// File actual stored size in bytes after compression and/or encryption. + final int sizeActual; + + /// Total number of chunks available + final int chunksTotal; + + /// Total number of chunks uploaded + final int chunksUploaded; + + /// Whether file contents are encrypted at rest. + final bool encryption; + + /// Compression algorithm used for the file. Will be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd). + final String compression; + + 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.sizeActual, + required this.chunksTotal, + required this.chunksUploaded, + required this.encryption, + required this.compression, + }); + + 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'], + sizeActual: map['sizeActual'], + chunksTotal: map['chunksTotal'], + chunksUploaded: map['chunksUploaded'], + encryption: map['encryption'], + compression: map['compression'].toString(), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "bucketId": bucketId, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "name": name, + "signature": signature, + "mimeType": mimeType, + "sizeOriginal": sizeOriginal, + "sizeActual": sizeActual, + "chunksTotal": chunksTotal, + "chunksUploaded": chunksUploaded, + "encryption": encryption, + "compression": compression, + }; + } } diff --git a/lib/src/models/file_list.dart b/lib/src/models/file_list.dart index 84c54b2e..1157554a 100644 --- a/lib/src/models/file_list.dart +++ b/lib/src/models/file_list.dart @@ -2,29 +2,29 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "files": files.map((p) => p.toMap()).toList(), - }; - } + @override + 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 bbccf88a..fa054420 100644 --- a/lib/src/models/headers.dart +++ b/lib/src/models/headers.dart @@ -2,29 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return { - "name": name, - "value": value, - }; - } + @override + Map toMap() { + return { + "name": name, + "value": value, + }; + } } diff --git a/lib/src/models/identity.dart b/lib/src/models/identity.dart index 7e90020c..cc659043 100644 --- a/lib/src/models/identity.dart +++ b/lib/src/models/identity.dart @@ -2,77 +2,77 @@ 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(), + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "userId": userId, - "provider": provider, - "providerUid": providerUid, - "providerEmail": providerEmail, - "providerAccessToken": providerAccessToken, - "providerAccessTokenExpiry": providerAccessTokenExpiry, - "providerRefreshToken": providerRefreshToken, - }; - } + @override + 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 d9cc09a2..a5d39ea0 100644 --- a/lib/src/models/identity_list.dart +++ b/lib/src/models/identity_list.dart @@ -2,29 +2,30 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "identities": identities.map((p) => p.toMap()).toList(), - }; - } + @override + 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 2000acb6..cda66c70 100644 --- a/lib/src/models/jwt.dart +++ b/lib/src/models/jwt.dart @@ -2,23 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return { - "jwt": jwt, - }; - } + @override + Map toMap() { + return { + "jwt": jwt, + }; + } } diff --git a/lib/src/models/language.dart b/lib/src/models/language.dart index 1422d065..87dc3606 100644 --- a/lib/src/models/language.dart +++ b/lib/src/models/language.dart @@ -2,35 +2,35 @@ 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(), + ); + } - @override - Map toMap() { - return { - "name": name, - "code": code, - "nativeName": nativeName, - }; - } + @override + 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 5d78a367..6198d61e 100644 --- a/lib/src/models/language_list.dart +++ b/lib/src/models/language_list.dart @@ -2,29 +2,30 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "languages": languages.map((p) => p.toMap()).toList(), - }; - } + @override + 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 3292a896..54dd0c29 100644 --- a/lib/src/models/locale.dart +++ b/lib/src/models/locale.dart @@ -2,59 +2,59 @@ 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(), - ); - } - - @override - 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(), + ); + } + + @override + 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 49ef3b0b..21405aff 100644 --- a/lib/src/models/locale_code.dart +++ b/lib/src/models/locale_code.dart @@ -2,29 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return { - "code": code, - "name": name, - }; - } + @override + 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 a3a26b61..202355a4 100644 --- a/lib/src/models/locale_code_list.dart +++ b/lib/src/models/locale_code_list.dart @@ -2,29 +2,30 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "localeCodes": localeCodes.map((p) => p.toMap()).toList(), - }; - } + @override + 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 406fcbcf..572cce50 100644 --- a/lib/src/models/log.dart +++ b/lib/src/models/log.dart @@ -2,149 +2,149 @@ part of '../../models.dart'; /// Log class Log implements Model { - /// Event name. - final String event; - - /// User ID of the actor recorded for this log. During impersonation, this is the original impersonator, not the impersonated target user. - final String userId; - - /// User email of the actor recorded for this log. During impersonation, this is the original impersonator. - final String userEmail; - - /// User name of the actor recorded for this log. During impersonation, this is the original impersonator. - final String userName; - - /// API mode when event triggered. - final String mode; - - /// User type who triggered the audit log. Possible values: user, admin, guest, keyProject, keyAccount, keyOrganization. - final String userType; - - /// 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.userType, - 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(), - userType: map['userType'].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(), - ); - } - - @override - Map toMap() { - return { - "event": event, - "userId": userId, - "userEmail": userEmail, - "userName": userName, - "mode": mode, - "userType": userType, - "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 of the actor recorded for this log. During impersonation, this is the original impersonator, not the impersonated target user. + final String userId; + + /// User email of the actor recorded for this log. During impersonation, this is the original impersonator. + final String userEmail; + + /// User name of the actor recorded for this log. During impersonation, this is the original impersonator. + final String userName; + + /// API mode when event triggered. + final String mode; + + /// User type who triggered the audit log. Possible values: user, admin, guest, keyProject, keyAccount, keyOrganization. + final String userType; + + /// 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.userType, + 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(), + userType: map['userType'].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(), + ); + } + + @override + Map toMap() { + return { + "event": event, + "userId": userId, + "userEmail": userEmail, + "userName": userName, + "mode": mode, + "userType": userType, + "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 ebf593c2..3494b111 100644 --- a/lib/src/models/log_list.dart +++ b/lib/src/models/log_list.dart @@ -2,29 +2,29 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "logs": logs.map((p) => p.toMap()).toList(), - }; - } + @override + 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 4baffb71..4d8a2f9b 100644 --- a/lib/src/models/membership.dart +++ b/lib/src/models/membership.dart @@ -2,107 +2,107 @@ 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; - - /// User phone number. Hide this attribute by toggling membership privacy in the Console. - final String userPhone; - - /// 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; - - /// Most recent access date in ISO 8601 format. Show this attribute by toggling membership privacy in the Console. - final String userAccessedAt; - - /// 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.userPhone, - required this.teamId, - required this.teamName, - required this.invited, - required this.joined, - required this.confirm, - required this.mfa, - required this.userAccessedAt, - 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(), - userPhone: map['userPhone'].toString(), - teamId: map['teamId'].toString(), - teamName: map['teamName'].toString(), - invited: map['invited'].toString(), - joined: map['joined'].toString(), - confirm: map['confirm'], - mfa: map['mfa'], - userAccessedAt: map['userAccessedAt'].toString(), - roles: List.from(map['roles'] ?? []), - ); - } - - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "userId": userId, - "userName": userName, - "userEmail": userEmail, - "userPhone": userPhone, - "teamId": teamId, - "teamName": teamName, - "invited": invited, - "joined": joined, - "confirm": confirm, - "mfa": mfa, - "userAccessedAt": userAccessedAt, - "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; + + /// User phone number. Hide this attribute by toggling membership privacy in the Console. + final String userPhone; + + /// 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; + + /// Most recent access date in ISO 8601 format. Show this attribute by toggling membership privacy in the Console. + final String userAccessedAt; + + /// 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.userPhone, + required this.teamId, + required this.teamName, + required this.invited, + required this.joined, + required this.confirm, + required this.mfa, + required this.userAccessedAt, + 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(), + userPhone: map['userPhone'].toString(), + teamId: map['teamId'].toString(), + teamName: map['teamName'].toString(), + invited: map['invited'].toString(), + joined: map['joined'].toString(), + confirm: map['confirm'], + mfa: map['mfa'], + userAccessedAt: map['userAccessedAt'].toString(), + roles: List.from(map['roles'] ?? []), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "userId": userId, + "userName": userName, + "userEmail": userEmail, + "userPhone": userPhone, + "teamId": teamId, + "teamName": teamName, + "invited": invited, + "joined": joined, + "confirm": confirm, + "mfa": mfa, + "userAccessedAt": userAccessedAt, + "roles": roles, + }; + } } diff --git a/lib/src/models/membership_list.dart b/lib/src/models/membership_list.dart index a0641a28..cc664c9f 100644 --- a/lib/src/models/membership_list.dart +++ b/lib/src/models/membership_list.dart @@ -2,29 +2,30 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "memberships": memberships.map((p) => p.toMap()).toList(), - }; - } + @override + 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 3d2e2335..fa385541 100644 --- a/lib/src/models/mfa_challenge.dart +++ b/lib/src/models/mfa_challenge.dart @@ -2,41 +2,41 @@ 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(), + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "userId": userId, - "expire": expire, - }; - } + @override + 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 a7e5fefc..2777de7f 100644 --- a/lib/src/models/mfa_factors.dart +++ b/lib/src/models/mfa_factors.dart @@ -2,41 +2,41 @@ 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'], + ); + } - @override - Map toMap() { - return { - "totp": totp, - "phone": phone, - "email": email, - "recoveryCode": recoveryCode, - }; - } + @override + 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 33036476..864a5db8 100644 --- a/lib/src/models/mfa_recovery_codes.dart +++ b/lib/src/models/mfa_recovery_codes.dart @@ -2,23 +2,23 @@ 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'] ?? []), + ); + } - @override - Map toMap() { - return { - "recoveryCodes": recoveryCodes, - }; - } + @override + Map toMap() { + return { + "recoveryCodes": recoveryCodes, + }; + } } diff --git a/lib/src/models/mfa_type.dart b/lib/src/models/mfa_type.dart index 05cab363..fe5327fc 100644 --- a/lib/src/models/mfa_type.dart +++ b/lib/src/models/mfa_type.dart @@ -2,29 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return { - "secret": secret, - "uri": uri, - }; - } + @override + 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 7ac578e2..60e2abd9 100644 --- a/lib/src/models/phone.dart +++ b/lib/src/models/phone.dart @@ -2,35 +2,35 @@ 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(), + ); + } - @override - Map toMap() { - return { - "code": code, - "countryCode": countryCode, - "countryName": countryName, - }; - } + @override + 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 9791d590..1a197fc7 100644 --- a/lib/src/models/phone_list.dart +++ b/lib/src/models/phone_list.dart @@ -2,29 +2,29 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "phones": phones.map((p) => p.toMap()).toList(), - }; - } + @override + 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 b107afe5..3ca04118 100644 --- a/lib/src/models/preferences.dart +++ b/lib/src/models/preferences.dart @@ -2,24 +2,24 @@ 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["data"] ?? map, - ); - } + factory Preferences.fromMap(Map map) { + return Preferences( + data: map["data"] ?? map, + ); + } - @override - Map toMap() { - return { - "data": data, - }; - } + @override + 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/presence.dart b/lib/src/models/presence.dart index 133fe66d..d31911de 100644 --- a/lib/src/models/presence.dart +++ b/lib/src/models/presence.dart @@ -2,71 +2,71 @@ part of '../../models.dart'; /// Presence class Presence implements Model { - /// Presence ID. - final String $id; + /// Presence ID. + final String $id; - /// Presence creation date in ISO 8601 format. - final String $createdAt; + /// Presence creation date in ISO 8601 format. + final String $createdAt; - /// Presence update date in ISO 8601 format. - final String $updatedAt; + /// Presence update date in ISO 8601 format. + final String $updatedAt; - /// Presence permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; + /// Presence permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Presence status. - final String? status; + /// Presence status. + final String? status; - /// Presence source. - final String source; + /// Presence source. + final String source; - /// Presence expiry date in ISO 8601 format. - final String? expiresAt; + /// Presence expiry date in ISO 8601 format. + final String? expiresAt; - /// Presence metadata. - final Map? metadata; + /// Presence metadata. + final Map? metadata; - Presence({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.userId, - this.status, - required this.source, - this.expiresAt, - this.metadata, - }); + Presence({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.userId, + this.status, + required this.source, + this.expiresAt, + this.metadata, + }); - factory Presence.fromMap(Map map) { - return Presence( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - userId: map['userId'].toString(), - status: map['status']?.toString(), - source: map['source'].toString(), - expiresAt: map['expiresAt']?.toString(), - metadata: map['metadata'], - ); - } + factory Presence.fromMap(Map map) { + return Presence( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + userId: map['userId'].toString(), + status: map['status']?.toString(), + source: map['source'].toString(), + expiresAt: map['expiresAt']?.toString(), + metadata: map['metadata'], + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "userId": userId, - "status": status, - "source": source, - "expiresAt": expiresAt, - "metadata": metadata, - }; - } + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "userId": userId, + "status": status, + "source": source, + "expiresAt": expiresAt, + "metadata": metadata, + }; + } } diff --git a/lib/src/models/presence_list.dart b/lib/src/models/presence_list.dart index aebbe880..3d010b1c 100644 --- a/lib/src/models/presence_list.dart +++ b/lib/src/models/presence_list.dart @@ -2,29 +2,30 @@ part of '../../models.dart'; /// Presences List class PresenceList implements Model { - /// Total number of presences that matched your query. - final int total; + /// Total number of presences that matched your query. + final int total; - /// List of presences. - final List presences; + /// List of presences. + final List presences; - PresenceList({ - required this.total, - required this.presences, - }); + PresenceList({ + required this.total, + required this.presences, + }); - factory PresenceList.fromMap(Map map) { - return PresenceList( - total: map['total'], - presences: List.from(map['presences'].map((p) => Presence.fromMap(p))), - ); - } + factory PresenceList.fromMap(Map map) { + return PresenceList( + total: map['total'], + presences: + List.from(map['presences'].map((p) => Presence.fromMap(p))), + ); + } - @override - Map toMap() { - return { - "total": total, - "presences": presences.map((p) => p.toMap()).toList(), - }; - } + @override + Map toMap() { + return { + "total": total, + "presences": presences.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/row.dart b/lib/src/models/row.dart index c5f233b4..a825eab0 100644 --- a/lib/src/models/row.dart +++ b/lib/src/models/row.dart @@ -2,66 +2,66 @@ part of '../../models.dart'; /// Row class Row implements Model { - /// Row ID. - final String $id; + /// Row ID. + final String $id; - /// Row sequence ID. - final String $sequence; + /// Row sequence ID. + final String $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'].toString(), - $tableId: map['\$tableId'].toString(), - $databaseId: map['\$databaseId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - data: map["data"] ?? map, - ); - } + factory Row.fromMap(Map map) { + return Row( + $id: map['\$id'].toString(), + $sequence: map['\$sequence'].toString(), + $tableId: map['\$tableId'].toString(), + $databaseId: map['\$databaseId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + data: map["data"] ?? map, + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$sequence": $sequence, - "\$tableId": $tableId, - "\$databaseId": $databaseId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "data": data, - }; - } + @override + 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 90efa95f..5023c633 100644 --- a/lib/src/models/row_list.dart +++ b/lib/src/models/row_list.dart @@ -2,32 +2,32 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "rows": rows.map((p) => p.toMap()).toList(), - }; - } + @override + 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 c37de95a..92e4034e 100644 --- a/lib/src/models/session.dart +++ b/lib/src/models/session.dart @@ -2,191 +2,191 @@ 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(), - ); - } - - @override - 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(), + ); + } + + @override + 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 d823d0e6..4ea12394 100644 --- a/lib/src/models/session_list.dart +++ b/lib/src/models/session_list.dart @@ -2,29 +2,30 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "sessions": sessions.map((p) => p.toMap()).toList(), - }; - } + @override + 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 850ab8d2..450aafd1 100644 --- a/lib/src/models/subscriber.dart +++ b/lib/src/models/subscriber.dart @@ -2,71 +2,71 @@ 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(), + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "targetId": targetId, - "target": target.toMap(), - "userId": userId, - "userName": userName, - "topicId": topicId, - "providerType": providerType, - }; - } + @override + 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 742e7590..c2e8c4dc 100644 --- a/lib/src/models/target.dart +++ b/lib/src/models/target.dart @@ -2,71 +2,71 @@ 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'], + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "userId": userId, - "providerId": providerId, - "providerType": providerType, - "identifier": identifier, - "expired": expired, - }; - } + @override + 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 21e65e95..91b888b9 100644 --- a/lib/src/models/team.dart +++ b/lib/src/models/team.dart @@ -2,53 +2,53 @@ 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']), - ); - } - - @override - 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']), + ); + } + + @override + 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 ffca5e98..e8f1c621 100644 --- a/lib/src/models/team_list.dart +++ b/lib/src/models/team_list.dart @@ -2,29 +2,29 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "teams": teams.map((p) => p.toMap()).toList(), - }; - } + @override + 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 b05320da..b5ea87c8 100644 --- a/lib/src/models/token.dart +++ b/lib/src/models/token.dart @@ -2,53 +2,53 @@ 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(), - ); - } - - @override - 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(), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "userId": userId, + "secret": secret, + "expire": expire, + "phrase": phrase, + }; + } } diff --git a/lib/src/models/transaction.dart b/lib/src/models/transaction.dart index e3f3e43d..b0606dd8 100644 --- a/lib/src/models/transaction.dart +++ b/lib/src/models/transaction.dart @@ -2,53 +2,53 @@ part of '../../models.dart'; /// Transaction class Transaction implements Model { - /// Transaction ID. - final String $id; - - /// Transaction creation time in ISO 8601 format. - final String $createdAt; - - /// Transaction update date in ISO 8601 format. - final String $updatedAt; - - /// Current status of the transaction. One of: pending, committing, committed, rolled_back, failed. - final String status; - - /// Number of operations in the transaction. - final int operations; - - /// Expiration time in ISO 8601 format. - final String expiresAt; - - Transaction({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.status, - required this.operations, - required this.expiresAt, - }); - - factory Transaction.fromMap(Map map) { - return Transaction( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - status: map['status'].toString(), - operations: map['operations'], - expiresAt: map['expiresAt'].toString(), - ); - } - - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "status": status, - "operations": operations, - "expiresAt": expiresAt, - }; - } + /// Transaction ID. + final String $id; + + /// Transaction creation time in ISO 8601 format. + final String $createdAt; + + /// Transaction update date in ISO 8601 format. + final String $updatedAt; + + /// Current status of the transaction. One of: pending, committing, committed, rolled_back, failed. + final String status; + + /// Number of operations in the transaction. + final int operations; + + /// Expiration time in ISO 8601 format. + final String expiresAt; + + Transaction({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.status, + required this.operations, + required this.expiresAt, + }); + + factory Transaction.fromMap(Map map) { + return Transaction( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + status: map['status'].toString(), + operations: map['operations'], + expiresAt: map['expiresAt'].toString(), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "status": status, + "operations": operations, + "expiresAt": expiresAt, + }; + } } diff --git a/lib/src/models/transaction_list.dart b/lib/src/models/transaction_list.dart index 19ea651d..7f321175 100644 --- a/lib/src/models/transaction_list.dart +++ b/lib/src/models/transaction_list.dart @@ -2,29 +2,30 @@ part of '../../models.dart'; /// Transaction List class TransactionList implements Model { - /// Total number of transactions that matched your query. - final int total; + /// Total number of transactions that matched your query. + final int total; - /// List of transactions. - final List transactions; + /// List of transactions. + final List transactions; - TransactionList({ - required this.total, - required this.transactions, - }); + TransactionList({ + required this.total, + required this.transactions, + }); - factory TransactionList.fromMap(Map map) { - return TransactionList( - total: map['total'], - transactions: List.from(map['transactions'].map((p) => Transaction.fromMap(p))), - ); - } + factory TransactionList.fromMap(Map map) { + return TransactionList( + total: map['total'], + transactions: List.from( + map['transactions'].map((p) => Transaction.fromMap(p))), + ); + } - @override - Map toMap() { - return { - "total": total, - "transactions": transactions.map((p) => p.toMap()).toList(), - }; - } + @override + Map toMap() { + return { + "total": total, + "transactions": transactions.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/user.dart b/lib/src/models/user.dart index e3b9536b..5a6cad30 100644 --- a/lib/src/models/user.dart +++ b/lib/src/models/user.dart @@ -2,173 +2,173 @@ part of '../../models.dart'; /// User class User implements Model { - /// User ID. - final String $id; + /// User ID. + final String $id; - /// User creation date in ISO 8601 format. - final String $createdAt; + /// User creation date in ISO 8601 format. + final String $createdAt; - /// User update date in ISO 8601 format. - final String $updatedAt; + /// 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; - - /// Canonical form of the user email address. - final String? emailCanonical; - - /// Whether the user email is from a free email provider. - final bool? emailIsFree; - - /// Whether the user email is from a disposable email provider. - final bool? emailIsDisposable; - - /// Whether the user email is from a corporate domain. - final bool? emailIsCorporate; - - /// Whether the user email is in its canonical form. - final bool? emailIsCanonical; - - /// 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; - - /// Whether the user can impersonate other users. - final bool? impersonator; - - /// ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data. - final String? impersonatorUserId; - - 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, - this.emailCanonical, - this.emailIsFree, - this.emailIsDisposable, - this.emailIsCorporate, - this.emailIsCanonical, - required this.phoneVerification, - required this.mfa, - required this.prefs, - required this.targets, - required this.accessedAt, - this.impersonator, - this.impersonatorUserId, - }); - - 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'], - emailCanonical: map['emailCanonical']?.toString(), - emailIsFree: map['emailIsFree'], - emailIsDisposable: map['emailIsDisposable'], - emailIsCorporate: map['emailIsCorporate'], - emailIsCanonical: map['emailIsCanonical'], - 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(), - impersonator: map['impersonator'], - impersonatorUserId: map['impersonatorUserId']?.toString(), - ); - } - - @override - 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, - "emailCanonical": emailCanonical, - "emailIsFree": emailIsFree, - "emailIsDisposable": emailIsDisposable, - "emailIsCorporate": emailIsCorporate, - "emailIsCanonical": emailIsCanonical, - "phoneVerification": phoneVerification, - "mfa": mfa, - "prefs": prefs.toMap(), - "targets": targets.map((p) => p.toMap()).toList(), - "accessedAt": accessedAt, - "impersonator": impersonator, - "impersonatorUserId": impersonatorUserId, - }; - } + /// 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; + + /// Canonical form of the user email address. + final String? emailCanonical; + + /// Whether the user email is from a free email provider. + final bool? emailIsFree; + + /// Whether the user email is from a disposable email provider. + final bool? emailIsDisposable; + + /// Whether the user email is from a corporate domain. + final bool? emailIsCorporate; + + /// Whether the user email is in its canonical form. + final bool? emailIsCanonical; + + /// 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; + + /// Whether the user can impersonate other users. + final bool? impersonator; + + /// ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data. + final String? impersonatorUserId; + + 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, + this.emailCanonical, + this.emailIsFree, + this.emailIsDisposable, + this.emailIsCorporate, + this.emailIsCanonical, + required this.phoneVerification, + required this.mfa, + required this.prefs, + required this.targets, + required this.accessedAt, + this.impersonator, + this.impersonatorUserId, + }); + + 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'], + emailCanonical: map['emailCanonical']?.toString(), + emailIsFree: map['emailIsFree'], + emailIsDisposable: map['emailIsDisposable'], + emailIsCorporate: map['emailIsCorporate'], + emailIsCanonical: map['emailIsCanonical'], + 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(), + impersonator: map['impersonator'], + impersonatorUserId: map['impersonatorUserId']?.toString(), + ); + } + + @override + 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, + "emailCanonical": emailCanonical, + "emailIsFree": emailIsFree, + "emailIsDisposable": emailIsDisposable, + "emailIsCorporate": emailIsCorporate, + "emailIsCanonical": emailIsCanonical, + "phoneVerification": phoneVerification, + "mfa": mfa, + "prefs": prefs.toMap(), + "targets": targets.map((p) => p.toMap()).toList(), + "accessedAt": accessedAt, + "impersonator": impersonator, + "impersonatorUserId": impersonatorUserId, + }; + } } diff --git a/lib/src/realtime.dart b/lib/src/realtime.dart index 7a5e6303..28e4c43d 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(); /// ``` - /// + /// /// You can also use Channel builders: /// ```dart /// final subscription = realtime.subscribe([ diff --git a/lib/src/realtime_io.dart b/lib/src/realtime_io.dart index 83f01b4c..0ed367a6 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 6cebb5b1..72edf5ee 100644 --- a/lib/src/realtime_mixin.dart +++ b/lib/src/realtime_mixin.dart @@ -58,9 +58,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"})); } }); } @@ -140,9 +138,11 @@ mixin RealtimeMixin { case 'event': final messageData = data.data as Map; final message = RealtimeMessage.fromMap(messageData); - final subscriptions = (messageData['subscriptions'] as List?) - ?.map((x) => x.toString()) - .toList() ?? []; + final subscriptions = + (messageData['subscriptions'] as List?) + ?.map((x) => x.toString()) + .toList() ?? + []; if (subscriptions.isEmpty) { break; @@ -209,13 +209,15 @@ mixin RealtimeMixin { "Please set endPointRealtime to connect to realtime server"); } var uri = Uri.parse(client.endPointRealtime!); - - var queryParams = "project=${Uri.encodeComponent(client.config['project']!)}"; + + var queryParams = + "project=${Uri.encodeComponent(client.config['project']!)}"; final portPart = (uri.hasPort && uri.port != 80 && uri.port != 443) ? ':${uri.port}' : ''; - return Uri.parse("${uri.scheme}://${uri.host}$portPart${uri.path}/realtime?$queryParams"); + return Uri.parse( + "${uri.scheme}://${uri.host}$portPart${uri.path}/realtime?$queryParams"); } void _sendUnsubscribeMessage(List subscriptionIds) { @@ -310,9 +312,11 @@ mixin RealtimeMixin { return channel is String ? channel : channel.toString(); } - RealtimeSubscription subscribeTo(List channels, [List queries = const []]) { + RealtimeSubscription subscribeTo(List channels, + [List queries = const []]) { StreamController controller = StreamController.broadcast(); - final channelStrings = channels.map((ch) => _channelToString(ch)).toList().cast(); + final channelStrings = + channels.map((ch) => _channelToString(ch)).toList().cast(); final queryStrings = List.from(queries); final subscriptionId = _generateUniqueSubscriptionId(); @@ -329,8 +333,7 @@ mixin RealtimeMixin { _sendUnsubscribeMessage([subscriptionId]); } - Future update( - {List? channels, List? queries}) async { + Future update({List? channels, List? queries}) async { final current = _subscriptions[subscriptionId]; if (current == null) { return; @@ -417,4 +420,4 @@ mixin RealtimeMixin { // until the application-level handshake completes. _flushPendingPresence(); } -} \ 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 diff --git a/lib/src/realtime_stub.dart b/lib/src/realtime_stub.dart index ce0b7e95..3aab4e03 100644 --- a/lib/src/realtime_stub.dart +++ b/lib/src/realtime_stub.dart @@ -3,5 +3,5 @@ import 'client.dart'; /// Implemented in `realtime_browser.dart` and `realtime_io.dart`. RealtimeBase createRealtime(Client client) => throw UnsupportedError( - 'Cannot create a client without dart:html or dart:io.', -); + 'Cannot create a client without dart:html or dart:io.', + ); diff --git a/test/channel_test.dart b/test/channel_test.dart index 62031aec..9e0e11d3 100644 --- a/test/channel_test.dart +++ b/test/channel_test.dart @@ -13,12 +13,22 @@ void main() { }); test('returns database channel with action', () { - expect(Channel.database('db1').collection('col1').document('doc1').create().toString(), + expect( + Channel.database('db1') + .collection('col1') + .document('doc1') + .create() + .toString(), 'databases.db1.collections.col1.documents.doc1.create'); }); test('returns database channel with upsert action', () { - expect(Channel.database('db1').collection('col1').document('doc1').upsert().toString(), + expect( + Channel.database('db1') + .collection('col1') + .document('doc1') + .upsert() + .toString(), 'databases.db1.collections.col1.documents.doc1.upsert'); }); }); @@ -34,7 +44,12 @@ void main() { }); test('returns tablesdb channel with action', () { - expect(Channel.tablesdb('db1').table('table1').row('row1').update().toString(), + expect( + Channel.tablesdb('db1') + .table('table1') + .row('row1') + .update() + .toString(), 'tablesdb.db1.tables.table1.rows.row1.update'); }); }); @@ -47,16 +62,16 @@ void main() { group('bucket()', () { test('throws when bucket id is missing', () { - expect(() => Channel.bucket(''), throwsArgumentError); + expect(() => Channel.bucket(''), throwsArgumentError); }); test('returns buckets channel with specific IDs', () { - expect(Channel.bucket('bucket1').file().toString(), - 'buckets.bucket1.files'); + expect( + Channel.bucket('bucket1').file().toString(), 'buckets.bucket1.files'); }); test('returns buckets channel with action', () { - expect(Channel.bucket('bucket1').file('file1').delete().toString(), + expect(Channel.bucket('bucket1').file('file1').delete().toString(), 'buckets.bucket1.files.file1.delete'); }); }); @@ -83,29 +98,30 @@ void main() { group('teams()', () { test('throws when team id is missing', () { - expect(() => Channel.team(''), throwsArgumentError); + expect(() => Channel.team(''), throwsArgumentError); }); test('returns teams channel with specific team ID', () { - expect(Channel.team('team1').toString(), 'teams.team1'); + expect(Channel.team('team1').toString(), 'teams.team1'); }); test('returns teams channel with action', () { - expect(Channel.team('team1').create().toString(), 'teams.team1.create'); + expect(Channel.team('team1').create().toString(), 'teams.team1.create'); }); }); group('memberships()', () { test('throws when membership id is missing', () { - expect(() => Channel.membership(''), throwsArgumentError); + expect(() => Channel.membership(''), throwsArgumentError); }); test('returns memberships channel with specific membership ID', () { - expect(Channel.membership('membership1').toString(), 'memberships.membership1'); + expect(Channel.membership('membership1').toString(), + 'memberships.membership1'); }); test('returns memberships channel with action', () { - expect(Channel.membership('membership1').update().toString(), + expect(Channel.membership('membership1').update().toString(), 'memberships.membership1.update'); }); }); diff --git a/test/query_test.dart b/test/query_test.dart index 25388fad..db7b9214 100644 --- a/test/query_test.dart +++ b/test/query_test.dart @@ -354,4 +354,3 @@ void main() { expect(query['method'], 'between'); }); } - diff --git a/test/services/account_test.dart b/test/services/account_test.dart index bd65aa32..d5d61fe7 100644 --- a/test/services/account_test.dart +++ b/test/services/account_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,1540 +40,1356 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Account test', () { - late MockClient client; - late Account account; - - setUp(() { - client = MockClient(); - account = Account(client); - }); - - test('test method get()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.get( - ); - expect(response, isA()); - - }); - - test('test method create()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.create( - userId: '', - email: 'email@example.com', - password: 'password', - ); - expect(response, isA()); - - }); - - test('test method updateEmail()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateEmail( - email: 'email@example.com', - password: 'password', - ); - expect(response, isA()); - - }); - - test('test method listIdentities()', () async { - - final Map data = { - 'total': 5, - 'identities': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.listIdentities( - ); - expect(response, isA()); - - }); - - test('test method deleteIdentity()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.deleteIdentity( - identityId: '', - ); - }); - - test('test method createJWT()', () async { - - final Map data = { - 'jwt': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createJWT( - ); - expect(response, isA()); - - }); - - test('test method listLogs()', () async { - - final Map data = { - 'total': 5, - 'logs': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.listLogs( - ); - expect(response, isA()); - - }); - - test('test method updateMFA()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateMFA( - mfa: true, - ); - expect(response, isA()); - - }); - - test('test method createMfaAuthenticator()', () async { - - final Map data = { - 'secret': '[SHARED_SECRET]', - 'uri': 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createMfaAuthenticator( - type: enums.AuthenticatorType.totp, - ); - expect(response, isA()); - - }); - - test('test method createMFAAuthenticator()', () async { - - final Map data = { - 'secret': '[SHARED_SECRET]', - 'uri': 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createMFAAuthenticator( - type: enums.AuthenticatorType.totp, - ); - expect(response, isA()); - - }); - - test('test method updateMfaAuthenticator()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateMfaAuthenticator( - type: enums.AuthenticatorType.totp, - otp: '', - ); - expect(response, isA()); - - }); - - test('test method updateMFAAuthenticator()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateMFAAuthenticator( - type: enums.AuthenticatorType.totp, - otp: '', - ); - expect(response, isA()); - - }); - - test('test method deleteMfaAuthenticator()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.deleteMfaAuthenticator( - type: enums.AuthenticatorType.totp, - ); - }); - - test('test method deleteMFAAuthenticator()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.deleteMFAAuthenticator( - type: enums.AuthenticatorType.totp, - ); - }); - - test('test method createMfaChallenge()', () async { - - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'expire': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createMfaChallenge( - factor: enums.AuthenticationFactor.email, - ); - expect(response, isA()); - - }); - - test('test method createMFAChallenge()', () async { - - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'expire': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createMFAChallenge( - factor: enums.AuthenticationFactor.email, - ); - expect(response, isA()); - - }); - - test('test method updateMfaChallenge()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateMfaChallenge( - challengeId: '', - otp: '', - ); - expect(response, isA()); - - }); - - test('test method updateMFAChallenge()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateMFAChallenge( - challengeId: '', - otp: '', - ); - expect(response, isA()); - - }); - - test('test method listMfaFactors()', () async { - - final Map data = { - 'totp': true, - 'phone': true, - 'email': true, - 'recoveryCode': true,}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.listMfaFactors( - ); - expect(response, isA()); - - }); - - test('test method listMFAFactors()', () async { - - final Map data = { - 'totp': true, - 'phone': true, - 'email': true, - 'recoveryCode': true,}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.listMFAFactors( - ); - expect(response, isA()); - - }); - - test('test method getMfaRecoveryCodes()', () async { - - final Map data = { - 'recoveryCodes': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.getMfaRecoveryCodes( - ); - expect(response, isA()); - - }); - - test('test method getMFARecoveryCodes()', () async { - - final Map data = { - 'recoveryCodes': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.getMFARecoveryCodes( - ); - expect(response, isA()); - - }); - - test('test method createMfaRecoveryCodes()', () async { - - final Map data = { - 'recoveryCodes': [],}; - + group('Account test', () { + late MockClient client; + late Account account; - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createMfaRecoveryCodes( - ); - expect(response, isA()); - - }); - - test('test method createMFARecoveryCodes()', () async { - - final Map data = { - 'recoveryCodes': [],}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createMFARecoveryCodes( - ); - expect(response, isA()); - - }); - - test('test method updateMfaRecoveryCodes()', () async { - - final Map data = { - 'recoveryCodes': [],}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateMfaRecoveryCodes( - ); - expect(response, isA()); - - }); - - test('test method updateMFARecoveryCodes()', () async { - - final Map data = { - 'recoveryCodes': [],}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateMFARecoveryCodes( - ); - expect(response, isA()); - - }); - - test('test method updateName()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateName( - name: '', - ); - expect(response, isA()); - - }); - - test('test method updatePassword()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updatePassword( - password: 'password', - ); - expect(response, isA()); - - }); - - test('test method updatePhone()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updatePhone( - phone: '+12065550100', - password: 'password', - ); - expect(response, isA()); - - }); - - test('test method getPrefs()', () async { - - final Map data = {}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.getPrefs( - ); - expect(response, isA()); - - }); - - test('test method updatePrefs()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updatePrefs( - prefs: {}, - ); - expect(response, isA()); - - }); - - test('test method createRecovery()', () async { - - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createRecovery( - email: 'email@example.com', - url: 'https://example.com', - ); - expect(response, isA()); - - }); - - test('test method updateRecovery()', () async { - - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + setUp(() { + client = MockClient(); + account = Account(client); + }); + test('test method get()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.get(); + expect(response, isA()); + }); - final response = await account.updateRecovery( - userId: '', - secret: '', - password: 'password', - ); - expect(response, isA()); + test('test method create()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.create( + userId: '', + email: 'email@example.com', + password: 'password', + ); + expect(response, isA()); + }); - }); + test('test method updateEmail()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateEmail( + email: 'email@example.com', + password: 'password', + ); + expect(response, isA()); + }); - test('test method listSessions()', () async { - - final Map data = { - 'total': 5, - 'sessions': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.listSessions( - ); - expect(response, isA()); - - }); - - test('test method deleteSessions()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.deleteSessions( - ); - }); - - test('test method createAnonymousSession()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createAnonymousSession( - ); - expect(response, isA()); - - }); - - test('test method createEmailPasswordSession()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createEmailPasswordSession( - email: 'email@example.com', - password: 'password', - ); - expect(response, isA()); - - }); - - test('test method updateMagicURLSession()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateMagicURLSession( - userId: '', - secret: '', - ); - expect(response, isA()); - - }); - - test('test method createOAuth2Session()', () async { - - - when(client.webAuth( - argThat(isNotNull), - )).thenAnswer((_) async => 'done'); - - - final response = await account.createOAuth2Session( - provider: enums.OAuthProvider.amazon, - ); - expect(response, equals('done')); - - }); - - test('test method updatePhoneSession()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updatePhoneSession( - userId: '', - secret: '', - ); - expect(response, isA()); - - }); - - test('test method createSession()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createSession( - userId: '', - secret: '', - ); - expect(response, isA()); - - }); - - test('test method getSession()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.getSession( - sessionId: '', - ); - expect(response, isA()); - - }); - - test('test method updateSession()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateSession( - sessionId: '', - ); - expect(response, isA()); - - }); - - test('test method deleteSession()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.deleteSession( - sessionId: '', - ); - }); - - test('test method updateStatus()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + test('test method listIdentities()', () async { + final Map data = { + 'total': 5, + 'identities': [], + }; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + final response = await account.listIdentities(); + expect(response, isA()); + }); + test('test method deleteIdentity()', () async { + final data = ''; - final response = await account.updateStatus( - ); - expect(response, isA()); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await account.deleteIdentity( + identityId: '', + ); + }); - test('test method createPushTarget()', () async { + test('test method createJWT()', () async { + final Map data = { + 'jwt': + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', + }; - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'Apple iPhone 12', - 'userId': '259125845563242502', - 'providerType': 'email', - 'identifier': 'token', - 'expired': true,}; + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + final response = await account.createJWT(); + expect(response, isA()); + }); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + test('test method listLogs()', () async { + final Map data = { + 'total': 5, + 'logs': [], + }; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await account.createPushTarget( - targetId: '', - identifier: '', - ); - expect(response, isA()); + final response = await account.listLogs(); + expect(response, isA()); + }); - }); + test('test method updateMFA()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateMFA( + mfa: true, + ); + expect(response, isA()); + }); - test('test method updatePushTarget()', () async { + test('test method createMfaAuthenticator()', () async { + final Map data = { + 'secret': '[SHARED_SECRET]', + 'uri': + 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createMfaAuthenticator( + type: enums.AuthenticatorType.totp, + ); + expect(response, isA()); + }); - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'Apple iPhone 12', - 'userId': '259125845563242502', - 'providerType': 'email', - 'identifier': 'token', - 'expired': true,}; + test('test method createMFAAuthenticator()', () async { + final Map data = { + 'secret': '[SHARED_SECRET]', + 'uri': + 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createMFAAuthenticator( + type: enums.AuthenticatorType.totp, + ); + expect(response, isA()); + }); + test('test method updateMfaAuthenticator()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateMfaAuthenticator( + type: enums.AuthenticatorType.totp, + otp: '', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + test('test method updateMFAAuthenticator()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateMFAAuthenticator( + type: enums.AuthenticatorType.totp, + otp: '', + ); + expect(response, isA()); + }); + test('test method deleteMfaAuthenticator()', () async { + final data = ''; - final response = await account.updatePushTarget( - targetId: '', - identifier: '', - ); - expect(response, isA()); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await account.deleteMfaAuthenticator( + type: enums.AuthenticatorType.totp, + ); + }); - test('test method deletePushTarget()', () async { + test('test method deleteMFAAuthenticator()', () async { + final data = ''; - final data = ''; + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + final response = await account.deleteMFAAuthenticator( + type: enums.AuthenticatorType.totp, + ); + }); + test('test method createMfaChallenge()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'expire': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createMfaChallenge( + factor: enums.AuthenticationFactor.email, + ); + expect(response, isA()); + }); - final response = await account.deletePushTarget( - targetId: '', - ); - }); + test('test method createMFAChallenge()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'expire': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createMFAChallenge( + factor: enums.AuthenticationFactor.email, + ); + expect(response, isA()); + }); - test('test method createEmailToken()', () async { + test('test method updateMfaChallenge()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateMfaChallenge( + challengeId: '', + otp: '', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + test('test method updateMFAChallenge()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateMFAChallenge( + challengeId: '', + otp: '', + ); + expect(response, isA()); + }); + test('test method listMfaFactors()', () async { + final Map data = { + 'totp': true, + 'phone': true, + 'email': true, + 'recoveryCode': true, + }; - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await account.listMfaFactors(); + expect(response, isA()); + }); - final response = await account.createEmailToken( - userId: '', - email: 'email@example.com', - ); - expect(response, isA()); + test('test method listMFAFactors()', () async { + final Map data = { + 'totp': true, + 'phone': true, + 'email': true, + 'recoveryCode': true, + }; - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method createMagicURLToken()', () async { + final response = await account.listMFAFactors(); + expect(response, isA()); + }); - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + test('test method getMfaRecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [], + }; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + final response = await account.getMfaRecoveryCodes(); + expect(response, isA()); + }); + test('test method getMFARecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [], + }; - final response = await account.createMagicURLToken( - userId: '', - email: 'email@example.com', - ); - expect(response, isA()); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await account.getMFARecoveryCodes(); + expect(response, isA()); + }); - test('test method createOAuth2Token()', () async { + test('test method createMfaRecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [], + }; + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - when(client.webAuth( - argThat(isNotNull), - )).thenAnswer((_) async => 'done'); + final response = await account.createMfaRecoveryCodes(); + expect(response, isA()); + }); + test('test method createMFARecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [], + }; - final response = await account.createOAuth2Token( - provider: enums.OAuthProvider.amazon, - ); - expect(response, equals('done')); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await account.createMFARecoveryCodes(); + expect(response, isA()); + }); - test('test method createPhoneToken()', () async { + test('test method updateMfaRecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [], + }; - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + final response = await account.updateMfaRecoveryCodes(); + expect(response, isA()); + }); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + test('test method updateMFARecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [], + }; + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); - final response = await account.createPhoneToken( - userId: '', - phone: '+12065550100', - ); - expect(response, isA()); + final response = await account.updateMFARecoveryCodes(); + expect(response, isA()); + }); - }); + test('test method updateName()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateName( + name: '', + ); + expect(response, isA()); + }); - test('test method createEmailVerification()', () async { + test('test method updatePassword()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updatePassword( + password: 'password', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + test('test method updatePhone()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updatePhone( + phone: '+12065550100', + password: 'password', + ); + expect(response, isA()); + }); + test('test method getPrefs()', () async { + final Map data = {}; - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await account.getPrefs(); + expect(response, isA()); + }); - final response = await account.createEmailVerification( - url: 'https://example.com', - ); - expect(response, isA()); + test('test method updatePrefs()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updatePrefs( + prefs: {}, + ); + expect(response, isA()); + }); - }); + test('test method createRecovery()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createRecovery( + email: 'email@example.com', + url: 'https://example.com', + ); + expect(response, isA()); + }); - test('test method createVerification()', () async { + test('test method updateRecovery()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateRecovery( + userId: '', + secret: '', + password: 'password', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + test('test method listSessions()', () async { + final Map data = { + 'total': 5, + 'sessions': [], + }; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + final response = await account.listSessions(); + expect(response, isA()); + }); + test('test method deleteSessions()', () async { + final data = ''; - final response = await account.createVerification( - url: 'https://example.com', - ); - expect(response, isA()); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await account.deleteSessions(); + }); - test('test method updateEmailVerification()', () async { + test('test method createAnonymousSession()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createAnonymousSession(); + expect(response, isA()); + }); - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + test('test method createEmailPasswordSession()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createEmailPasswordSession( + email: 'email@example.com', + password: 'password', + ); + expect(response, isA()); + }); + test('test method updateMagicURLSession()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateMagicURLSession( + userId: '', + secret: '', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + test('test method createOAuth2Session()', () async { + when(client.webAuth( + argThat(isNotNull), + )).thenAnswer((_) async => 'done'); + final response = await account.createOAuth2Session( + provider: enums.OAuthProvider.amazon, + ); + expect(response, equals('done')); + }); - final response = await account.updateEmailVerification( - userId: '', - secret: '', - ); - expect(response, isA()); + test('test method updatePhoneSession()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updatePhoneSession( + userId: '', + secret: '', + ); + expect(response, isA()); + }); - }); + test('test method createSession()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createSession( + userId: '', + secret: '', + ); + expect(response, isA()); + }); - test('test method updateVerification()', () async { + test('test method getSession()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.getSession( + sessionId: '', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + test('test method updateSession()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateSession( + sessionId: '', + ); + expect(response, isA()); + }); + test('test method deleteSession()', () async { + final data = ''; - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + final response = await account.deleteSession( + sessionId: '', + ); + }); - final response = await account.updateVerification( - userId: '', - secret: '', - ); - expect(response, isA()); + test('test method updateStatus()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateStatus(); + expect(response, isA()); + }); - }); + test('test method createPushTarget()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Apple iPhone 12', + 'userId': '259125845563242502', + 'providerType': 'email', + 'identifier': 'token', + 'expired': true, + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createPushTarget( + targetId: '', + identifier: '', + ); + expect(response, isA()); + }); - test('test method createPhoneVerification()', () async { + test('test method updatePushTarget()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Apple iPhone 12', + 'userId': '259125845563242502', + 'providerType': 'email', + 'identifier': 'token', + 'expired': true, + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updatePushTarget( + targetId: '', + identifier: '', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + test('test method deletePushTarget()', () async { + final data = ''; + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + final response = await account.deletePushTarget( + targetId: '', + ); + }); + test('test method createEmailToken()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createEmailToken( + userId: '', + email: 'email@example.com', + ); + expect(response, isA()); + }); - final response = await account.createPhoneVerification( - ); - expect(response, isA()); + test('test method createMagicURLToken()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createMagicURLToken( + userId: '', + email: 'email@example.com', + ); + expect(response, isA()); + }); - }); + test('test method createOAuth2Token()', () async { + when(client.webAuth( + argThat(isNotNull), + )).thenAnswer((_) async => 'done'); - test('test method updatePhoneVerification()', () async { + final response = await account.createOAuth2Token( + provider: enums.OAuthProvider.amazon, + ); + expect(response, equals('done')); + }); - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + test('test method createPhoneToken()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createPhoneToken( + userId: '', + phone: '+12065550100', + ); + expect(response, isA()); + }); + test('test method createEmailVerification()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createEmailVerification( + url: 'https://example.com', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + test('test method createVerification()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createVerification( + url: 'https://example.com', + ); + expect(response, isA()); + }); + test('test method updateEmailVerification()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateEmailVerification( + userId: '', + secret: '', + ); + expect(response, isA()); + }); - final response = await account.updatePhoneVerification( - userId: '', - secret: '', - ); - expect(response, isA()); + test('test method updateVerification()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateVerification( + userId: '', + secret: '', + ); + expect(response, isA()); + }); - }); + test('test method createPhoneVerification()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createPhoneVerification(); + expect(response, isA()); + }); + test('test method updatePhoneVerification()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updatePhoneVerification( + userId: '', + secret: '', + ); + expect(response, isA()); }); + }); } diff --git a/test/services/avatars_test.dart b/test/services/avatars_test.dart index 4bdb434d..8d2c48fb 100644 --- a/test/services/avatars_test.dart +++ b/test/services/avatars_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,138 +40,123 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Avatars test', () { - late MockClient client; - late Avatars avatars; - - setUp(() { - client = MockClient(); - avatars = Avatars(client); - }); - - test('test method getBrowser()', () async { -final Uint8List data = Uint8List.fromList([]); - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await avatars.getBrowser( - code: enums.Browser.avantBrowser, - ); - expect(response, isA()); - - }); - - test('test method getCreditCard()', () async { -final Uint8List data = Uint8List.fromList([]); - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await avatars.getCreditCard( - code: enums.CreditCard.americanExpress, - ); - expect(response, isA()); - - }); - - test('test method getFavicon()', () async { -final Uint8List data = Uint8List.fromList([]); + group('Avatars test', () { + late MockClient client; + late Avatars avatars; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await avatars.getFavicon( - url: 'https://example.com', - ); - expect(response, isA()); - - }); - - test('test method getFlag()', () async { -final Uint8List data = Uint8List.fromList([]); - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + setUp(() { + client = MockClient(); + avatars = Avatars(client); + }); + test('test method getBrowser()', () async { + final Uint8List data = Uint8List.fromList([]); - final response = await avatars.getFlag( - code: enums.Flag.afghanistan, - ); - expect(response, isA()); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await avatars.getBrowser( + code: enums.Browser.avantBrowser, + ); + expect(response, isA()); + }); - test('test method getImage()', () async { -final Uint8List data = Uint8List.fromList([]); + test('test method getCreditCard()', () async { + final Uint8List data = Uint8List.fromList([]); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await avatars.getCreditCard( + code: enums.CreditCard.americanExpress, + ); + expect(response, isA()); + }); - final response = await avatars.getImage( - url: 'https://example.com', - ); - expect(response, isA()); + test('test method getFavicon()', () async { + final Uint8List data = Uint8List.fromList([]); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method getInitials()', () async { -final Uint8List data = Uint8List.fromList([]); + final response = await avatars.getFavicon( + url: 'https://example.com', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + test('test method getFlag()', () async { + final Uint8List data = Uint8List.fromList([]); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await avatars.getInitials( - ); - expect(response, isA()); + final response = await avatars.getFlag( + code: enums.Flag.afghanistan, + ); + expect(response, isA()); + }); - }); + test('test method getImage()', () async { + final Uint8List data = Uint8List.fromList([]); - test('test method getQR()', () async { -final Uint8List data = Uint8List.fromList([]); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final response = await avatars.getImage( + url: 'https://example.com', + ); + expect(response, isA()); + }); + test('test method getInitials()', () async { + final Uint8List data = Uint8List.fromList([]); - final response = await avatars.getQR( - text: '', - ); - expect(response, isA()); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await avatars.getInitials(); + expect(response, isA()); + }); - test('test method getScreenshot()', () async { -final Uint8List data = Uint8List.fromList([]); + test('test method getQR()', () async { + final Uint8List data = Uint8List.fromList([]); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await avatars.getQR( + text: '', + ); + expect(response, isA()); + }); - final response = await avatars.getScreenshot( - url: 'https://example.com', - ); - expect(response, isA()); + test('test method getScreenshot()', () async { + final Uint8List data = Uint8List.fromList([]); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await avatars.getScreenshot( + url: 'https://example.com', + ); + expect(response, isA()); }); + }); } diff --git a/test/services/databases_test.dart b/test/services/databases_test.dart index a4b0a6cc..a3807093 100644 --- a/test/services/databases_test.dart +++ b/test/services/databases_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,337 +40,297 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Databases test', () { - late MockClient client; - late Databases databases; - - setUp(() { - client = MockClient(); - databases = Databases(client); - }); - - test('test method listTransactions()', () async { - - final Map data = { - 'total': 5, - 'transactions': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.listTransactions( - ); - expect(response, isA()); - - }); - - test('test method createTransaction()', () async { - - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.createTransaction( - ); - expect(response, isA()); - - }); - - test('test method getTransaction()', () async { - - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.getTransaction( - transactionId: '', - ); - expect(response, isA()); - - }); - - test('test method updateTransaction()', () async { - - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.updateTransaction( - transactionId: '', - ); - expect(response, isA()); - - }); - - test('test method deleteTransaction()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.deleteTransaction( - transactionId: '', - ); - }); - - test('test method createOperations()', () async { - - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.createOperations( - transactionId: '', - ); - expect(response, isA()); - - }); - - test('test method listDocuments()', () async { - - final Map data = { - 'total': 5, - 'documents': [],}; - + group('Databases test', () { + late MockClient client; + late Databases databases; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.listDocuments( - databaseId: '', - collectionId: '', - ); - expect(response, isA()); - - }); - - test('test method createDocument()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.createDocument( - databaseId: '', - collectionId: '', - documentId: '', - data: {}, - ); - expect(response, isA()); - - }); - - test('test method getDocument()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.getDocument( - databaseId: '', - collectionId: '', - documentId: '', - ); - expect(response, isA()); - - }); - - test('test method upsertDocument()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.upsertDocument( - databaseId: '', - collectionId: '', - documentId: '', - ); - expect(response, isA()); - - }); - - test('test method updateDocument()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.updateDocument( - databaseId: '', - collectionId: '', - documentId: '', - ); - expect(response, isA()); - - }); + setUp(() { + client = MockClient(); + databases = Databases(client); + }); - test('test method deleteDocument()', () async { + test('test method listTransactions()', () async { + final Map data = { + 'total': 5, + 'transactions': [], + }; - final data = ''; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + final response = await databases.listTransactions(); + expect(response, isA()); + }); + test('test method createTransaction()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.createTransaction(); + expect(response, isA()); + }); - final response = await databases.deleteDocument( - databaseId: '', - collectionId: '', - documentId: '', - ); - }); + test('test method getTransaction()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.getTransaction( + transactionId: '', + ); + expect(response, isA()); + }); - test('test method decrementDocumentAttribute()', () async { + test('test method updateTransaction()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.updateTransaction( + transactionId: '', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; + test('test method deleteTransaction()', () async { + final data = ''; + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + final response = await databases.deleteTransaction( + transactionId: '', + ); + }); + test('test method createOperations()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.createOperations( + transactionId: '', + ); + expect(response, isA()); + }); - final response = await databases.decrementDocumentAttribute( - databaseId: '', - collectionId: '', - documentId: '', - attribute: '', - ); - expect(response, isA()); + test('test method listDocuments()', () async { + final Map data = { + 'total': 5, + 'documents': [], + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.listDocuments( + databaseId: '', + collectionId: '', + ); + expect(response, isA()); + }); - }); + test('test method createDocument()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.createDocument( + databaseId: '', + collectionId: '', + documentId: '', + data: {}, + ); + expect(response, isA()); + }); - test('test method incrementDocumentAttribute()', () async { + test('test method getDocument()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.getDocument( + databaseId: '', + collectionId: '', + documentId: '', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; + test('test method upsertDocument()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.upsertDocument( + databaseId: '', + collectionId: '', + documentId: '', + ); + expect(response, isA()); + }); + test('test method updateDocument()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.updateDocument( + databaseId: '', + collectionId: '', + documentId: '', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + test('test method deleteDocument()', () async { + final data = ''; + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - final response = await databases.incrementDocumentAttribute( - databaseId: '', - collectionId: '', - documentId: '', - attribute: '', - ); - expect(response, isA()); + final response = await databases.deleteDocument( + databaseId: '', + collectionId: '', + documentId: '', + ); + }); - }); + test('test method decrementDocumentAttribute()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.decrementDocumentAttribute( + databaseId: '', + collectionId: '', + documentId: '', + attribute: '', + ); + expect(response, isA()); + }); + test('test method incrementDocumentAttribute()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.incrementDocumentAttribute( + databaseId: '', + collectionId: '', + documentId: '', + attribute: '', + ); + expect(response, isA()); }); + }); } diff --git a/test/services/functions_test.dart b/test/services/functions_test.dart index 9b0d046f..c6e50a50 100644 --- a/test/services/functions_test.dart +++ b/test/services/functions_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,107 +40,100 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Functions test', () { - late MockClient client; - late Functions functions; - - setUp(() { - client = MockClient(); - functions = Functions(client); - }); - - test('test method listExecutions()', () async { - - final Map data = { - 'total': 5, - 'executions': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await functions.listExecutions( - functionId: '', - ); - expect(response, isA()); - - }); - - test('test method createExecution()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'functionId': '5e5ea6g16897e', - 'deploymentId': '5e5ea5c16897e', - 'trigger': 'http', - 'status': 'processing', - 'requestMethod': 'GET', - 'requestPath': '/articles?id=5', - 'requestHeaders': [], - 'responseStatusCode': 200, - 'responseBody': '', - 'responseHeaders': [], - 'logs': '', - 'errors': '', - 'duration': 0.4,}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await functions.createExecution( - functionId: '', - ); - expect(response, isA()); - - }); - - test('test method getExecution()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'functionId': '5e5ea6g16897e', - 'deploymentId': '5e5ea5c16897e', - 'trigger': 'http', - 'status': 'processing', - 'requestMethod': 'GET', - 'requestPath': '/articles?id=5', - 'requestHeaders': [], - 'responseStatusCode': 200, - 'responseBody': '', - 'responseHeaders': [], - 'logs': '', - 'errors': '', - 'duration': 0.4,}; + group('Functions test', () { + late MockClient client; + late Functions functions; + setUp(() { + client = MockClient(); + functions = Functions(client); + }); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + test('test method listExecutions()', () async { + final Map data = { + 'total': 5, + 'executions': [], + }; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await functions.getExecution( - functionId: '', - executionId: '', - ); - expect(response, isA()); + final response = await functions.listExecutions( + functionId: '', + ); + expect(response, isA()); + }); - }); + test('test method createExecution()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'functionId': '5e5ea6g16897e', + 'deploymentId': '5e5ea5c16897e', + 'trigger': 'http', + 'status': 'processing', + 'requestMethod': 'GET', + 'requestPath': '/articles?id=5', + 'requestHeaders': [], + 'responseStatusCode': 200, + 'responseBody': '', + 'responseHeaders': [], + 'logs': '', + 'errors': '', + 'duration': 0.4, + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await functions.createExecution( + functionId: '', + ); + expect(response, isA()); + }); + test('test method getExecution()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'functionId': '5e5ea6g16897e', + 'deploymentId': '5e5ea5c16897e', + 'trigger': 'http', + 'status': 'processing', + 'requestMethod': 'GET', + 'requestPath': '/articles?id=5', + 'requestHeaders': [], + 'responseStatusCode': 200, + 'responseBody': '', + 'responseHeaders': [], + 'logs': '', + 'errors': '', + 'duration': 0.4, + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await functions.getExecution( + functionId: '', + executionId: '', + ); + expect(response, isA()); }); + }); } diff --git a/test/services/graphql_test.dart b/test/services/graphql_test.dart index c548e414..84b7de1c 100644 --- a/test/services/graphql_test.dart +++ b/test/services/graphql_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,47 +40,45 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Graphql test', () { - late MockClient client; - late Graphql graphql; - - setUp(() { - client = MockClient(); - graphql = Graphql(client); - }); - - test('test method query()', () async { - - final data = ''; + group('Graphql test', () { + late MockClient client; + late Graphql graphql; - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await graphql.query( - query: {}, - ); - }); + setUp(() { + client = MockClient(); + graphql = Graphql(client); + }); - test('test method mutation()', () async { + test('test method query()', () async { + final data = ''; - final data = ''; + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + final response = await graphql.query( + query: {}, + ); + }); + test('test method mutation()', () async { + final data = ''; - final response = await graphql.mutation( - query: {}, - ); - }); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + final response = await graphql.mutation( + query: {}, + ); }); + }); } diff --git a/test/services/locale_test.dart b/test/services/locale_test.dart index 42faaf72..f9f6489d 100644 --- a/test/services/locale_test.dart +++ b/test/services/locale_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,168 +40,138 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Locale test', () { - late MockClient client; - late Locale locale; - - setUp(() { - client = MockClient(); - locale = Locale(client); - }); - - test('test method get()', () async { - - final Map data = { - 'ip': '127.0.0.1', - 'countryCode': 'US', - 'country': 'United States', - 'continentCode': 'NA', - 'continent': 'North America', - 'eu': true, - 'currency': 'USD',}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await locale.get( - ); - expect(response, isA()); - - }); - - test('test method listCodes()', () async { - - final Map data = { - 'total': 5, - 'localeCodes': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await locale.listCodes( - ); - expect(response, isA()); - - }); - - test('test method listContinents()', () async { - - final Map data = { - 'total': 5, - 'continents': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await locale.listContinents( - ); - expect(response, isA()); + group('Locale test', () { + late MockClient client; + late Locale locale; - }); - - test('test method listCountries()', () async { - - final Map data = { - 'total': 5, - 'countries': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await locale.listCountries( - ); - expect(response, isA()); - - }); - - test('test method listCountriesEU()', () async { - - final Map data = { - 'total': 5, - 'countries': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await locale.listCountriesEU( - ); - expect(response, isA()); - - }); + setUp(() { + client = MockClient(); + locale = Locale(client); + }); - test('test method listCountriesPhones()', () async { + test('test method get()', () async { + final Map data = { + 'ip': '127.0.0.1', + 'countryCode': 'US', + 'country': 'United States', + 'continentCode': 'NA', + 'continent': 'North America', + 'eu': true, + 'currency': 'USD', + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await locale.get(); + expect(response, isA()); + }); - final Map data = { - 'total': 5, - 'phones': [],}; + test('test method listCodes()', () async { + final Map data = { + 'total': 5, + 'localeCodes': [], + }; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final response = await locale.listCodes(); + expect(response, isA()); + }); + test('test method listContinents()', () async { + final Map data = { + 'total': 5, + 'continents': [], + }; - final response = await locale.listCountriesPhones( - ); - expect(response, isA()); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await locale.listContinents(); + expect(response, isA()); + }); - test('test method listCurrencies()', () async { + test('test method listCountries()', () async { + final Map data = { + 'total': 5, + 'countries': [], + }; - final Map data = { - 'total': 5, - 'currencies': [],}; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await locale.listCountries(); + expect(response, isA()); + }); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + test('test method listCountriesEU()', () async { + final Map data = { + 'total': 5, + 'countries': [], + }; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await locale.listCurrencies( - ); - expect(response, isA()); + final response = await locale.listCountriesEU(); + expect(response, isA()); + }); - }); + test('test method listCountriesPhones()', () async { + final Map data = { + 'total': 5, + 'phones': [], + }; - test('test method listLanguages()', () async { + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final Map data = { - 'total': 5, - 'languages': [],}; + final response = await locale.listCountriesPhones(); + expect(response, isA()); + }); + test('test method listCurrencies()', () async { + final Map data = { + 'total': 5, + 'currencies': [], + }; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await locale.listCurrencies(); + expect(response, isA()); + }); - final response = await locale.listLanguages( - ); - expect(response, isA()); + test('test method listLanguages()', () async { + final Map data = { + 'total': 5, + 'languages': [], + }; - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await locale.listLanguages(); + expect(response, isA()); }); + }); } diff --git a/test/services/messaging_test.dart b/test/services/messaging_test.dart index 5899ace3..0c938eff 100644 --- a/test/services/messaging_test.dart +++ b/test/services/messaging_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,71 +40,68 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Messaging test', () { - late MockClient client; - late Messaging messaging; - - setUp(() { - client = MockClient(); - messaging = Messaging(client); - }); - - test('test method createSubscriber()', () async { - - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'targetId': '259125845563242502', - 'target': { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'Apple iPhone 12', - 'userId': '259125845563242502', - 'providerType': 'email', - 'identifier': 'token', - 'expired': true, - }, - 'userId': '5e5ea5c16897e', - 'userName': 'Aegon Targaryen', - 'topicId': '259125845563242502', - 'providerType': 'email',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + group('Messaging test', () { + late MockClient client; + late Messaging messaging; + setUp(() { + client = MockClient(); + messaging = Messaging(client); + }); - final response = await messaging.createSubscriber( - topicId: '', - subscriberId: '', - targetId: '', - ); - expect(response, isA()); - - }); - - test('test method deleteSubscriber()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + test('test method createSubscriber()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'targetId': '259125845563242502', + 'target': { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Apple iPhone 12', + 'userId': '259125845563242502', + 'providerType': 'email', + 'identifier': 'token', + 'expired': true, + }, + 'userId': '5e5ea5c16897e', + 'userName': 'Aegon Targaryen', + 'topicId': '259125845563242502', + 'providerType': 'email', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await messaging.createSubscriber( + topicId: '', + subscriberId: '', + targetId: '', + ); + expect(response, isA()); + }); + test('test method deleteSubscriber()', () async { + final data = ''; - final response = await messaging.deleteSubscriber( - topicId: '', - subscriberId: '', - ); - }); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + final response = await messaging.deleteSubscriber( + topicId: '', + subscriberId: '', + ); }); + }); } diff --git a/test/services/presences_test.dart b/test/services/presences_test.dart index 7b99675f..7fed0439 100644 --- a/test/services/presences_test.dart +++ b/test/services/presences_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,121 +40,108 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Presences test', () { - late MockClient client; - late Presences presences; - - setUp(() { - client = MockClient(); - presences = Presences(client); - }); - - test('test method list()', () async { - - final Map data = { - 'total': 5, - 'presences': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await presences.list( - ); - expect(response, isA()); - - }); - - test('test method get()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'userId': '674af8f3e12a5f9ac0be', - 'source': 'HTTP',}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await presences.get( - presenceId: '', - ); - expect(response, isA()); - - }); + group('Presences test', () { + late MockClient client; + late Presences presences; - test('test method upsert()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'userId': '674af8f3e12a5f9ac0be', - 'source': 'HTTP',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await presences.upsert( - presenceId: '', - status: '', - ); - expect(response, isA()); - - }); - - test('test method update()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'userId': '674af8f3e12a5f9ac0be', - 'source': 'HTTP',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + setUp(() { + client = MockClient(); + presences = Presences(client); + }); + test('test method list()', () async { + final Map data = { + 'total': 5, + 'presences': [], + }; - final response = await presences.update( - presenceId: '', - ); - expect(response, isA()); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await presences.list(); + expect(response, isA()); + }); - test('test method delete()', () async { + test('test method get()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'userId': '674af8f3e12a5f9ac0be', + 'source': 'HTTP', + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await presences.get( + presenceId: '', + ); + expect(response, isA()); + }); - final data = ''; + test('test method upsert()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'userId': '674af8f3e12a5f9ac0be', + 'source': 'HTTP', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await presences.upsert( + presenceId: '', + status: '', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + test('test method update()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'userId': '674af8f3e12a5f9ac0be', + 'source': 'HTTP', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await presences.update( + presenceId: '', + ); + expect(response, isA()); + }); + test('test method delete()', () async { + final data = ''; - final response = await presences.delete( - presenceId: '', - ); - }); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + final response = await presences.delete( + presenceId: '', + ); }); + }); } diff --git a/test/services/storage_test.dart b/test/services/storage_test.dart index 2390bfdd..55a42f94 100644 --- a/test/services/storage_test.dart +++ b/test/services/storage_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,202 +40,184 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Storage test', () { - late MockClient client; - late Storage storage; - - setUp(() { - client = MockClient(); - storage = Storage(client); - }); - - test('test method listFiles()', () async { - - final Map data = { - 'total': 5, - 'files': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await storage.listFiles( - bucketId: '', - ); - expect(response, isA()); - - }); - - test('test method createFile()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - 'bucketId': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'name': 'Pink.png', - 'signature': '5d529fd02b544198ae075bd57c1762bb', - 'mimeType': 'image/png', - 'sizeOriginal': 17890, - 'sizeActual': 12345, - 'chunksTotal': 17890, - 'chunksUploaded': 17890, - 'encryption': true, - 'compression': 'gzip',}; - - - when(client.chunkedUpload( - path: argThat(isNotNull), - params: argThat(isNotNull), - paramName: argThat(isNotNull), - idParamName: argThat(isNotNull), - headers: argThat(isNotNull), - )).thenAnswer((_) async => Response(data: data)); - - - final response = await storage.createFile( - bucketId: '', - fileId: '', - file: InputFile.fromPath(path: './image.png'), - ); - expect(response, isA()); - - }); - - test('test method getFile()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - 'bucketId': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'name': 'Pink.png', - 'signature': '5d529fd02b544198ae075bd57c1762bb', - 'mimeType': 'image/png', - 'sizeOriginal': 17890, - 'sizeActual': 12345, - 'chunksTotal': 17890, - 'chunksUploaded': 17890, - 'encryption': true, - 'compression': 'gzip',}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await storage.getFile( - bucketId: '', - fileId: '', - ); - expect(response, isA()); - - }); - - test('test method updateFile()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - 'bucketId': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'name': 'Pink.png', - 'signature': '5d529fd02b544198ae075bd57c1762bb', - 'mimeType': 'image/png', - 'sizeOriginal': 17890, - 'sizeActual': 12345, - 'chunksTotal': 17890, - 'chunksUploaded': 17890, - 'encryption': true, - 'compression': 'gzip',}; - + group('Storage test', () { + late MockClient client; + late Storage storage; - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await storage.updateFile( - bucketId: '', - fileId: '', - ); - expect(response, isA()); - - }); - - test('test method deleteFile()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + setUp(() { + client = MockClient(); + storage = Storage(client); + }); + test('test method listFiles()', () async { + final Map data = { + 'total': 5, + 'files': [], + }; - final response = await storage.deleteFile( - bucketId: '', - fileId: '', - ); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method getFileDownload()', () async { -final Uint8List data = Uint8List.fromList([]); + final response = await storage.listFiles( + bucketId: '', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + test('test method createFile()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + 'bucketId': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'name': 'Pink.png', + 'signature': '5d529fd02b544198ae075bd57c1762bb', + 'mimeType': 'image/png', + 'sizeOriginal': 17890, + 'sizeActual': 12345, + 'chunksTotal': 17890, + 'chunksUploaded': 17890, + 'encryption': true, + 'compression': 'gzip', + }; + + when(client.chunkedUpload( + path: argThat(isNotNull), + params: argThat(isNotNull), + paramName: argThat(isNotNull), + idParamName: argThat(isNotNull), + headers: argThat(isNotNull), + )).thenAnswer((_) async => Response(data: data)); + + final response = await storage.createFile( + bucketId: '', + fileId: '', + file: InputFile.fromPath(path: './image.png'), + ); + expect(response, isA()); + }); + test('test method getFile()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + 'bucketId': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'name': 'Pink.png', + 'signature': '5d529fd02b544198ae075bd57c1762bb', + 'mimeType': 'image/png', + 'sizeOriginal': 17890, + 'sizeActual': 12345, + 'chunksTotal': 17890, + 'chunksUploaded': 17890, + 'encryption': true, + 'compression': 'gzip', + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await storage.getFile( + bucketId: '', + fileId: '', + ); + expect(response, isA()); + }); - final response = await storage.getFileDownload( - bucketId: '', - fileId: '', - ); - expect(response, isA()); + test('test method updateFile()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + 'bucketId': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'name': 'Pink.png', + 'signature': '5d529fd02b544198ae075bd57c1762bb', + 'mimeType': 'image/png', + 'sizeOriginal': 17890, + 'sizeActual': 12345, + 'chunksTotal': 17890, + 'chunksUploaded': 17890, + 'encryption': true, + 'compression': 'gzip', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await storage.updateFile( + bucketId: '', + fileId: '', + ); + expect(response, isA()); + }); - }); + test('test method deleteFile()', () async { + final data = ''; - test('test method getFilePreview()', () async { -final Uint8List data = Uint8List.fromList([]); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final response = await storage.deleteFile( + bucketId: '', + fileId: '', + ); + }); + test('test method getFileDownload()', () async { + final Uint8List data = Uint8List.fromList([]); - final response = await storage.getFilePreview( - bucketId: '', - fileId: '', - ); - expect(response, isA()); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await storage.getFileDownload( + bucketId: '', + fileId: '', + ); + expect(response, isA()); + }); - test('test method getFileView()', () async { -final Uint8List data = Uint8List.fromList([]); + test('test method getFilePreview()', () async { + final Uint8List data = Uint8List.fromList([]); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await storage.getFilePreview( + bucketId: '', + fileId: '', + ); + expect(response, isA()); + }); - final response = await storage.getFileView( - bucketId: '', - fileId: '', - ); - expect(response, isA()); + test('test method getFileView()', () async { + final Uint8List data = Uint8List.fromList([]); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await storage.getFileView( + bucketId: '', + fileId: '', + ); + expect(response, isA()); }); + }); } diff --git a/test/services/tables_db_test.dart b/test/services/tables_db_test.dart index 5219d2bf..f318cad2 100644 --- a/test/services/tables_db_test.dart +++ b/test/services/tables_db_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,337 +40,297 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('TablesDB test', () { - late MockClient client; - late TablesDB tablesDB; - - setUp(() { - client = MockClient(); - tablesDB = TablesDB(client); - }); - - test('test method listTransactions()', () async { - - final Map data = { - 'total': 5, - 'transactions': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.listTransactions( - ); - expect(response, isA()); - - }); - - test('test method createTransaction()', () async { - - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.createTransaction( - ); - expect(response, isA()); - - }); - - test('test method getTransaction()', () async { - - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.getTransaction( - transactionId: '', - ); - expect(response, isA()); - - }); - - test('test method updateTransaction()', () async { - - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.updateTransaction( - transactionId: '', - ); - expect(response, isA()); - - }); - - test('test method deleteTransaction()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.deleteTransaction( - transactionId: '', - ); - }); - - test('test method createOperations()', () async { - - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.createOperations( - transactionId: '', - ); - expect(response, isA()); - - }); - - test('test method listRows()', () async { - - final Map data = { - 'total': 5, - 'rows': [],}; - + group('TablesDB test', () { + late MockClient client; + late TablesDB tablesDB; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.listRows( - databaseId: '', - tableId: '', - ); - expect(response, isA()); - - }); - - test('test method createRow()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.createRow( - databaseId: '', - tableId: '', - rowId: '', - data: {}, - ); - expect(response, isA()); - - }); - - test('test method getRow()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.getRow( - databaseId: '', - tableId: '', - rowId: '', - ); - expect(response, isA()); - - }); - - test('test method upsertRow()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.upsertRow( - databaseId: '', - tableId: '', - rowId: '', - ); - expect(response, isA()); - - }); - - test('test method updateRow()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.updateRow( - databaseId: '', - tableId: '', - rowId: '', - ); - expect(response, isA()); - - }); + setUp(() { + client = MockClient(); + tablesDB = TablesDB(client); + }); - test('test method deleteRow()', () async { + test('test method listTransactions()', () async { + final Map data = { + 'total': 5, + 'transactions': [], + }; - final data = ''; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + final response = await tablesDB.listTransactions(); + expect(response, isA()); + }); + test('test method createTransaction()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.createTransaction(); + expect(response, isA()); + }); - final response = await tablesDB.deleteRow( - databaseId: '', - tableId: '', - rowId: '', - ); - }); + test('test method getTransaction()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.getTransaction( + transactionId: '', + ); + expect(response, isA()); + }); - test('test method decrementRowColumn()', () async { + test('test method updateTransaction()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.updateTransaction( + transactionId: '', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; + test('test method deleteTransaction()', () async { + final data = ''; + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + final response = await tablesDB.deleteTransaction( + transactionId: '', + ); + }); + test('test method createOperations()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.createOperations( + transactionId: '', + ); + expect(response, isA()); + }); - final response = await tablesDB.decrementRowColumn( - databaseId: '', - tableId: '', - rowId: '', - column: '', - ); - expect(response, isA()); + test('test method listRows()', () async { + final Map data = { + 'total': 5, + 'rows': [], + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.listRows( + databaseId: '', + tableId: '', + ); + expect(response, isA()); + }); - }); + test('test method createRow()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.createRow( + databaseId: '', + tableId: '', + rowId: '', + data: {}, + ); + expect(response, isA()); + }); - test('test method incrementRowColumn()', () async { + test('test method getRow()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.getRow( + databaseId: '', + tableId: '', + rowId: '', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; + test('test method upsertRow()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.upsertRow( + databaseId: '', + tableId: '', + rowId: '', + ); + expect(response, isA()); + }); + test('test method updateRow()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.updateRow( + databaseId: '', + tableId: '', + rowId: '', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + test('test method deleteRow()', () async { + final data = ''; + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - final response = await tablesDB.incrementRowColumn( - databaseId: '', - tableId: '', - rowId: '', - column: '', - ); - expect(response, isA()); + final response = await tablesDB.deleteRow( + databaseId: '', + tableId: '', + rowId: '', + ); + }); - }); + test('test method decrementRowColumn()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.decrementRowColumn( + databaseId: '', + tableId: '', + rowId: '', + column: '', + ); + expect(response, isA()); + }); + test('test method incrementRowColumn()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.incrementRowColumn( + databaseId: '', + tableId: '', + rowId: '', + column: '', + ); + expect(response, isA()); }); + }); } diff --git a/test/services/teams_test.dart b/test/services/teams_test.dart index ea72a432..83f2667b 100644 --- a/test/services/teams_test.dart +++ b/test/services/teams_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,326 +40,288 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Teams test', () { - late MockClient client; - late Teams teams; - - setUp(() { - client = MockClient(); - teams = Teams(client); - }); - - test('test method list()', () async { - - final Map data = { - 'total': 5, - 'teams': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.list( - ); - expect(response, isA()); - - }); - - test('test method create()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'VIP', - 'total': 7, - 'prefs': {},}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.create( - teamId: '', - name: '', - ); - expect(response, isA()); - - }); - - test('test method get()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'VIP', - 'total': 7, - 'prefs': {},}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.get( - teamId: '', - ); - expect(response, isA()); - - }); - - test('test method updateName()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'VIP', - 'total': 7, - 'prefs': {},}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.updateName( - teamId: '', - name: '', - ); - expect(response, isA()); - - }); - - test('test method delete()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.delete( - teamId: '', - ); - }); - - test('test method listMemberships()', () async { - - final Map data = { - 'total': 5, - 'memberships': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + group('Teams test', () { + late MockClient client; + late Teams teams; + setUp(() { + client = MockClient(); + teams = Teams(client); + }); - final response = await teams.listMemberships( - teamId: '', - ); - expect(response, isA()); - - }); - - test('test method createMembership()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [],}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.createMembership( - teamId: '', - roles: [], - ); - expect(response, isA()); - - }); - - test('test method getMembership()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.getMembership( - teamId: '', - membershipId: '', - ); - expect(response, isA()); - - }); - - test('test method updateMembership()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [],}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.updateMembership( - teamId: '', - membershipId: '', - roles: [], - ); - expect(response, isA()); - - }); - - test('test method deleteMembership()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + test('test method list()', () async { + final Map data = { + 'total': 5, + 'teams': [], + }; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await teams.deleteMembership( - teamId: '', - membershipId: '', - ); - }); + final response = await teams.list(); + expect(response, isA()); + }); - test('test method updateMembershipStatus()', () async { + test('test method create()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'VIP', + 'total': 7, + 'prefs': {}, + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await teams.create( + teamId: '', + name: '', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [],}; + test('test method get()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'VIP', + 'total': 7, + 'prefs': {}, + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await teams.get( + teamId: '', + ); + expect(response, isA()); + }); + test('test method updateName()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'VIP', + 'total': 7, + 'prefs': {}, + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await teams.updateName( + teamId: '', + name: '', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + test('test method delete()', () async { + final data = ''; + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - final response = await teams.updateMembershipStatus( - teamId: '', - membershipId: '', - userId: '', - secret: '', - ); - expect(response, isA()); + final response = await teams.delete( + teamId: '', + ); + }); - }); + test('test method listMemberships()', () async { + final Map data = { + 'total': 5, + 'memberships': [], + }; - test('test method getPrefs()', () async { + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final Map data = {}; + final response = await teams.listMemberships( + teamId: '', + ); + expect(response, isA()); + }); + test('test method createMembership()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'userPhone': '+1 555 555 5555', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'roles': [], + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await teams.createMembership( + teamId: '', + roles: [], + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + test('test method getMembership()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'userPhone': '+1 555 555 5555', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'roles': [], + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await teams.getMembership( + teamId: '', + membershipId: '', + ); + expect(response, isA()); + }); + test('test method updateMembership()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'userPhone': '+1 555 555 5555', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'roles': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await teams.updateMembership( + teamId: '', + membershipId: '', + roles: [], + ); + expect(response, isA()); + }); - final response = await teams.getPrefs( - teamId: '', - ); - expect(response, isA()); + test('test method deleteMembership()', () async { + final data = ''; - }); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - test('test method updatePrefs()', () async { + final response = await teams.deleteMembership( + teamId: '', + membershipId: '', + ); + }); - final Map data = {}; + test('test method updateMembershipStatus()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'userPhone': '+1 555 555 5555', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'roles': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await teams.updateMembershipStatus( + teamId: '', + membershipId: '', + userId: '', + secret: '', + ); + expect(response, isA()); + }); + test('test method getPrefs()', () async { + final Map data = {}; - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await teams.getPrefs( + teamId: '', + ); + expect(response, isA()); + }); - final response = await teams.updatePrefs( - teamId: '', - prefs: {}, - ); - expect(response, isA()); + test('test method updatePrefs()', () async { + final Map data = {}; - }); + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + final response = await teams.updatePrefs( + teamId: '', + prefs: {}, + ); + expect(response, isA()); }); + }); } diff --git a/test/src/models/algo_argon2_test.dart b/test/src/models/algo_argon2_test.dart index 15e85f5a..261daa46 100644 --- a/test/src/models/algo_argon2_test.dart +++ b/test/src/models/algo_argon2_test.dart @@ -14,10 +14,10 @@ void main() { final map = model.toMap(); final result = AlgoArgon2.fromMap(map); - expect(result.type, 'argon2'); - expect(result.memoryCost, 65536); - expect(result.timeCost, 4); - expect(result.threads, 3); - }); + expect(result.type, 'argon2'); + expect(result.memoryCost, 65536); + expect(result.timeCost, 4); + expect(result.threads, 3); + }); }); } diff --git a/test/src/models/algo_bcrypt_test.dart b/test/src/models/algo_bcrypt_test.dart index 87a3ca3c..3da36624 100644 --- a/test/src/models/algo_bcrypt_test.dart +++ b/test/src/models/algo_bcrypt_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = AlgoBcrypt.fromMap(map); - expect(result.type, 'bcrypt'); - }); + expect(result.type, 'bcrypt'); + }); }); } diff --git a/test/src/models/algo_md5_test.dart b/test/src/models/algo_md5_test.dart index 3b842e6c..e58fa5b5 100644 --- a/test/src/models/algo_md5_test.dart +++ b/test/src/models/algo_md5_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = AlgoMd5.fromMap(map); - expect(result.type, 'md5'); - }); + expect(result.type, 'md5'); + }); }); } diff --git a/test/src/models/algo_phpass_test.dart b/test/src/models/algo_phpass_test.dart index 49b1e22c..3bcbb488 100644 --- a/test/src/models/algo_phpass_test.dart +++ b/test/src/models/algo_phpass_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = AlgoPhpass.fromMap(map); - expect(result.type, 'phpass'); - }); + expect(result.type, 'phpass'); + }); }); } diff --git a/test/src/models/algo_scrypt_modified_test.dart b/test/src/models/algo_scrypt_modified_test.dart index dd7fa8c3..b2084927 100644 --- a/test/src/models/algo_scrypt_modified_test.dart +++ b/test/src/models/algo_scrypt_modified_test.dart @@ -8,16 +8,18 @@ void main() { type: 'scryptMod', salt: 'UxLMreBr6tYyjQ==', saltSeparator: 'Bw==', - signerKey: 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ==', + signerKey: + 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ==', ); final map = model.toMap(); final result = AlgoScryptModified.fromMap(map); - expect(result.type, 'scryptMod'); - expect(result.salt, 'UxLMreBr6tYyjQ=='); - expect(result.saltSeparator, 'Bw=='); - expect(result.signerKey, 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ=='); - }); + expect(result.type, 'scryptMod'); + expect(result.salt, 'UxLMreBr6tYyjQ=='); + expect(result.saltSeparator, 'Bw=='); + expect(result.signerKey, + 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ=='); + }); }); } diff --git a/test/src/models/algo_scrypt_test.dart b/test/src/models/algo_scrypt_test.dart index c7d9cdbf..8c131568 100644 --- a/test/src/models/algo_scrypt_test.dart +++ b/test/src/models/algo_scrypt_test.dart @@ -15,11 +15,11 @@ void main() { final map = model.toMap(); final result = AlgoScrypt.fromMap(map); - expect(result.type, 'scrypt'); - expect(result.costCpu, 8); - expect(result.costMemory, 14); - expect(result.costParallel, 1); - expect(result.length, 64); - }); + expect(result.type, 'scrypt'); + expect(result.costCpu, 8); + expect(result.costMemory, 14); + expect(result.costParallel, 1); + expect(result.length, 64); + }); }); } diff --git a/test/src/models/algo_sha_test.dart b/test/src/models/algo_sha_test.dart index ae58b57e..d080569c 100644 --- a/test/src/models/algo_sha_test.dart +++ b/test/src/models/algo_sha_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = AlgoSha.fromMap(map); - expect(result.type, 'sha'); - }); + expect(result.type, 'sha'); + }); }); } diff --git a/test/src/models/continent_list_test.dart b/test/src/models/continent_list_test.dart index 8de695b0..e71dcae1 100644 --- a/test/src/models/continent_list_test.dart +++ b/test/src/models/continent_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = ContinentList.fromMap(map); - expect(result.total, 5); - expect(result.continents, []); - }); + expect(result.total, 5); + expect(result.continents, []); + }); }); } diff --git a/test/src/models/continent_test.dart b/test/src/models/continent_test.dart index d5242a4e..85e559f5 100644 --- a/test/src/models/continent_test.dart +++ b/test/src/models/continent_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = Continent.fromMap(map); - expect(result.name, 'Europe'); - expect(result.code, 'EU'); - }); + expect(result.name, 'Europe'); + expect(result.code, 'EU'); + }); }); } diff --git a/test/src/models/country_list_test.dart b/test/src/models/country_list_test.dart index 869f5db6..6df5c584 100644 --- a/test/src/models/country_list_test.dart +++ b/test/src/models/country_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = CountryList.fromMap(map); - expect(result.total, 5); - expect(result.countries, []); - }); + expect(result.total, 5); + expect(result.countries, []); + }); }); } diff --git a/test/src/models/country_test.dart b/test/src/models/country_test.dart index bc66ab7b..d5404a7f 100644 --- a/test/src/models/country_test.dart +++ b/test/src/models/country_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = Country.fromMap(map); - expect(result.name, 'United States'); - expect(result.code, 'US'); - }); + expect(result.name, 'United States'); + expect(result.code, 'US'); + }); }); } diff --git a/test/src/models/currency_list_test.dart b/test/src/models/currency_list_test.dart index 09da675c..d7410db8 100644 --- a/test/src/models/currency_list_test.dart +++ b/test/src/models/currency_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = CurrencyList.fromMap(map); - expect(result.total, 5); - expect(result.currencies, []); - }); + expect(result.total, 5); + expect(result.currencies, []); + }); }); } diff --git a/test/src/models/currency_test.dart b/test/src/models/currency_test.dart index 29890008..00e046c7 100644 --- a/test/src/models/currency_test.dart +++ b/test/src/models/currency_test.dart @@ -17,13 +17,13 @@ void main() { final map = model.toMap(); final result = Currency.fromMap(map); - expect(result.symbol, '\$'); - expect(result.name, 'US dollar'); - expect(result.symbolNative, '\$'); - expect(result.decimalDigits, 2); - expect(result.rounding, 0); - expect(result.code, 'USD'); - expect(result.namePlural, 'US dollars'); - }); + expect(result.symbol, '\$'); + expect(result.name, 'US dollar'); + expect(result.symbolNative, '\$'); + expect(result.decimalDigits, 2); + expect(result.rounding, 0); + expect(result.code, 'USD'); + expect(result.namePlural, 'US dollars'); + }); }); } diff --git a/test/src/models/document_list_test.dart b/test/src/models/document_list_test.dart index f1a5b3cc..217d37e8 100644 --- a/test/src/models/document_list_test.dart +++ b/test/src/models/document_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = DocumentList.fromMap(map); - expect(result.total, 5); - expect(result.documents, []); - }); + expect(result.total, 5); + expect(result.documents, []); + }); }); } diff --git a/test/src/models/document_test.dart b/test/src/models/document_test.dart index 6c1fbb77..397b5fab 100644 --- a/test/src/models/document_test.dart +++ b/test/src/models/document_test.dart @@ -18,13 +18,13 @@ void main() { final map = model.toMap(); final result = Document.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$sequence, '1'); - expect(result.$collectionId, '5e5ea5c15117e'); - expect(result.$databaseId, '5e5ea5c15117e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$sequence, '1'); + expect(result.$collectionId, '5e5ea5c15117e'); + expect(result.$databaseId, '5e5ea5c15117e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + }); }); } diff --git a/test/src/models/execution_list_test.dart b/test/src/models/execution_list_test.dart index fe74af58..a3305e55 100644 --- a/test/src/models/execution_list_test.dart +++ b/test/src/models/execution_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = ExecutionList.fromMap(map); - expect(result.total, 5); - expect(result.executions, []); - }); + expect(result.total, 5); + expect(result.executions, []); + }); }); } diff --git a/test/src/models/execution_test.dart b/test/src/models/execution_test.dart index 6d9bf33c..80ef508a 100644 --- a/test/src/models/execution_test.dart +++ b/test/src/models/execution_test.dart @@ -28,23 +28,23 @@ void main() { final map = model.toMap(); final result = Execution.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - expect(result.functionId, '5e5ea6g16897e'); - expect(result.deploymentId, '5e5ea5c16897e'); - expect(result.trigger, ExecutionTrigger.http); - expect(result.status, ExecutionStatus.waiting); - expect(result.requestMethod, 'GET'); - expect(result.requestPath, '/articles?id=5'); - expect(result.requestHeaders, []); - expect(result.responseStatusCode, 200); - expect(result.responseBody, ''); - expect(result.responseHeaders, []); - expect(result.logs, ''); - expect(result.errors, ''); - expect(result.duration, 0.4); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + expect(result.functionId, '5e5ea6g16897e'); + expect(result.deploymentId, '5e5ea5c16897e'); + expect(result.trigger, ExecutionTrigger.http); + expect(result.status, ExecutionStatus.waiting); + expect(result.requestMethod, 'GET'); + expect(result.requestPath, '/articles?id=5'); + expect(result.requestHeaders, []); + expect(result.responseStatusCode, 200); + expect(result.responseBody, ''); + expect(result.responseHeaders, []); + expect(result.logs, ''); + expect(result.errors, ''); + expect(result.duration, 0.4); + }); }); } diff --git a/test/src/models/file_list_test.dart b/test/src/models/file_list_test.dart index d8e6c95c..8e02f65e 100644 --- a/test/src/models/file_list_test.dart +++ b/test/src/models/file_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = FileList.fromMap(map); - expect(result.total, 5); - expect(result.files, []); - }); + expect(result.total, 5); + expect(result.files, []); + }); }); } diff --git a/test/src/models/file_test.dart b/test/src/models/file_test.dart index 8a734a08..7f132646 100644 --- a/test/src/models/file_test.dart +++ b/test/src/models/file_test.dart @@ -24,20 +24,20 @@ void main() { final map = model.toMap(); final result = File.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.bucketId, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - expect(result.name, 'Pink.png'); - expect(result.signature, '5d529fd02b544198ae075bd57c1762bb'); - expect(result.mimeType, 'image/png'); - expect(result.sizeOriginal, 17890); - expect(result.sizeActual, 12345); - expect(result.chunksTotal, 17890); - expect(result.chunksUploaded, 17890); - expect(result.encryption, true); - expect(result.compression, 'gzip'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.bucketId, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + expect(result.name, 'Pink.png'); + expect(result.signature, '5d529fd02b544198ae075bd57c1762bb'); + expect(result.mimeType, 'image/png'); + expect(result.sizeOriginal, 17890); + expect(result.sizeActual, 12345); + expect(result.chunksTotal, 17890); + expect(result.chunksUploaded, 17890); + expect(result.encryption, true); + expect(result.compression, 'gzip'); + }); }); } diff --git a/test/src/models/headers_test.dart b/test/src/models/headers_test.dart index 489891d4..9252b469 100644 --- a/test/src/models/headers_test.dart +++ b/test/src/models/headers_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = Headers.fromMap(map); - expect(result.name, 'Content-Type'); - expect(result.value, 'application/json'); - }); + expect(result.name, 'Content-Type'); + expect(result.value, 'application/json'); + }); }); } diff --git a/test/src/models/identity_list_test.dart b/test/src/models/identity_list_test.dart index 65f562a7..8c35afec 100644 --- a/test/src/models/identity_list_test.dart +++ b/test/src/models/identity_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = IdentityList.fromMap(map); - expect(result.total, 5); - expect(result.identities, []); - }); + expect(result.total, 5); + expect(result.identities, []); + }); }); } diff --git a/test/src/models/identity_test.dart b/test/src/models/identity_test.dart index 708c8c60..525af4ea 100644 --- a/test/src/models/identity_test.dart +++ b/test/src/models/identity_test.dart @@ -20,16 +20,16 @@ void main() { final map = model.toMap(); final result = Identity.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5bb8c16897e'); - expect(result.provider, 'email'); - expect(result.providerUid, '5e5bb8c16897e'); - expect(result.providerEmail, 'user@example.com'); - expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); - expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5bb8c16897e'); + expect(result.provider, 'email'); + expect(result.providerUid, '5e5bb8c16897e'); + expect(result.providerEmail, 'user@example.com'); + expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); + expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + }); }); } diff --git a/test/src/models/jwt_test.dart b/test/src/models/jwt_test.dart index e616a956..93376af1 100644 --- a/test/src/models/jwt_test.dart +++ b/test/src/models/jwt_test.dart @@ -5,13 +5,15 @@ void main() { group('Jwt', () { test('model', () { final model = Jwt( - jwt: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', + jwt: + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', ); final map = model.toMap(); final result = Jwt.fromMap(map); - expect(result.jwt, 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'); - }); + expect(result.jwt, + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'); + }); }); } diff --git a/test/src/models/language_list_test.dart b/test/src/models/language_list_test.dart index 94c1e33f..a07c0b5f 100644 --- a/test/src/models/language_list_test.dart +++ b/test/src/models/language_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = LanguageList.fromMap(map); - expect(result.total, 5); - expect(result.languages, []); - }); + expect(result.total, 5); + expect(result.languages, []); + }); }); } diff --git a/test/src/models/language_test.dart b/test/src/models/language_test.dart index d4087d5e..4a6c96c1 100644 --- a/test/src/models/language_test.dart +++ b/test/src/models/language_test.dart @@ -13,9 +13,9 @@ void main() { final map = model.toMap(); final result = Language.fromMap(map); - expect(result.name, 'Italian'); - expect(result.code, 'it'); - expect(result.nativeName, 'Italiano'); - }); + expect(result.name, 'Italian'); + expect(result.code, 'it'); + expect(result.nativeName, 'Italiano'); + }); }); } diff --git a/test/src/models/locale_code_list_test.dart b/test/src/models/locale_code_list_test.dart index b6de5137..65b44ad1 100644 --- a/test/src/models/locale_code_list_test.dart +++ b/test/src/models/locale_code_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = LocaleCodeList.fromMap(map); - expect(result.total, 5); - expect(result.localeCodes, []); - }); + expect(result.total, 5); + expect(result.localeCodes, []); + }); }); } diff --git a/test/src/models/locale_code_test.dart b/test/src/models/locale_code_test.dart index f0fcdbce..88cf157b 100644 --- a/test/src/models/locale_code_test.dart +++ b/test/src/models/locale_code_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = LocaleCode.fromMap(map); - expect(result.code, 'en-us'); - expect(result.name, 'US'); - }); + expect(result.code, 'en-us'); + expect(result.name, 'US'); + }); }); } diff --git a/test/src/models/locale_test.dart b/test/src/models/locale_test.dart index 72102045..49cb1fc9 100644 --- a/test/src/models/locale_test.dart +++ b/test/src/models/locale_test.dart @@ -17,13 +17,13 @@ void main() { final map = model.toMap(); final result = Locale.fromMap(map); - expect(result.ip, '127.0.0.1'); - expect(result.countryCode, 'US'); - expect(result.country, 'United States'); - expect(result.continentCode, 'NA'); - expect(result.continent, 'North America'); - expect(result.eu, true); - expect(result.currency, 'USD'); - }); + expect(result.ip, '127.0.0.1'); + expect(result.countryCode, 'US'); + expect(result.country, 'United States'); + expect(result.continentCode, 'NA'); + expect(result.continent, 'North America'); + expect(result.eu, true); + expect(result.currency, 'USD'); + }); }); } diff --git a/test/src/models/log_list_test.dart b/test/src/models/log_list_test.dart index 84c560c8..b07ca8ee 100644 --- a/test/src/models/log_list_test.dart +++ b/test/src/models/log_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = LogList.fromMap(map); - expect(result.total, 5); - expect(result.logs, []); - }); + expect(result.total, 5); + expect(result.logs, []); + }); }); } diff --git a/test/src/models/log_test.dart b/test/src/models/log_test.dart index 1b463633..c8211d3b 100644 --- a/test/src/models/log_test.dart +++ b/test/src/models/log_test.dart @@ -32,28 +32,28 @@ void main() { final map = model.toMap(); final result = Log.fromMap(map); - expect(result.event, 'account.sessions.create'); - expect(result.userId, '610fc2f985ee0'); - expect(result.userEmail, 'john@appwrite.io'); - expect(result.userName, 'John Doe'); - expect(result.mode, 'admin'); - expect(result.userType, 'user'); - expect(result.ip, '127.0.0.1'); - expect(result.time, '2020-10-15T06:38:00.000+00:00'); - expect(result.osCode, 'Mac'); - expect(result.osName, 'Mac'); - expect(result.osVersion, 'Mac'); - expect(result.clientType, 'browser'); - expect(result.clientCode, 'CM'); - expect(result.clientName, 'Chrome Mobile iOS'); - expect(result.clientVersion, '84.0'); - expect(result.clientEngine, 'WebKit'); - expect(result.clientEngineVersion, '605.1.15'); - expect(result.deviceName, 'smartphone'); - expect(result.deviceBrand, 'Google'); - expect(result.deviceModel, 'Nexus 5'); - expect(result.countryCode, 'US'); - expect(result.countryName, 'United States'); - }); + expect(result.event, 'account.sessions.create'); + expect(result.userId, '610fc2f985ee0'); + expect(result.userEmail, 'john@appwrite.io'); + expect(result.userName, 'John Doe'); + expect(result.mode, 'admin'); + expect(result.userType, 'user'); + expect(result.ip, '127.0.0.1'); + expect(result.time, '2020-10-15T06:38:00.000+00:00'); + expect(result.osCode, 'Mac'); + expect(result.osName, 'Mac'); + expect(result.osVersion, 'Mac'); + expect(result.clientType, 'browser'); + expect(result.clientCode, 'CM'); + expect(result.clientName, 'Chrome Mobile iOS'); + expect(result.clientVersion, '84.0'); + expect(result.clientEngine, 'WebKit'); + expect(result.clientEngineVersion, '605.1.15'); + expect(result.deviceName, 'smartphone'); + expect(result.deviceBrand, 'Google'); + expect(result.deviceModel, 'Nexus 5'); + expect(result.countryCode, 'US'); + expect(result.countryName, 'United States'); + }); }); } diff --git a/test/src/models/membership_list_test.dart b/test/src/models/membership_list_test.dart index bb1f0946..4f30c48e 100644 --- a/test/src/models/membership_list_test.dart +++ b/test/src/models/membership_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = MembershipList.fromMap(map); - expect(result.total, 5); - expect(result.memberships, []); - }); + expect(result.total, 5); + expect(result.memberships, []); + }); }); } diff --git a/test/src/models/membership_test.dart b/test/src/models/membership_test.dart index ab136c24..b2b8bd3d 100644 --- a/test/src/models/membership_test.dart +++ b/test/src/models/membership_test.dart @@ -25,21 +25,21 @@ void main() { final map = model.toMap(); final result = Membership.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5ea5c16897e'); - expect(result.userName, 'John Doe'); - expect(result.userEmail, 'john@appwrite.io'); - expect(result.userPhone, '+1 555 555 5555'); - expect(result.teamId, '5e5ea5c16897e'); - expect(result.teamName, 'VIP'); - expect(result.invited, '2020-10-15T06:38:00.000+00:00'); - expect(result.joined, '2020-10-15T06:38:00.000+00:00'); - expect(result.confirm, true); - expect(result.mfa, true); - expect(result.userAccessedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.roles, []); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5ea5c16897e'); + expect(result.userName, 'John Doe'); + expect(result.userEmail, 'john@appwrite.io'); + expect(result.userPhone, '+1 555 555 5555'); + expect(result.teamId, '5e5ea5c16897e'); + expect(result.teamName, 'VIP'); + expect(result.invited, '2020-10-15T06:38:00.000+00:00'); + expect(result.joined, '2020-10-15T06:38:00.000+00:00'); + expect(result.confirm, true); + expect(result.mfa, true); + expect(result.userAccessedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.roles, []); + }); }); } diff --git a/test/src/models/mfa_challenge_test.dart b/test/src/models/mfa_challenge_test.dart index 9410baa3..5d3febca 100644 --- a/test/src/models/mfa_challenge_test.dart +++ b/test/src/models/mfa_challenge_test.dart @@ -14,10 +14,10 @@ void main() { final map = model.toMap(); final result = MfaChallenge.fromMap(map); - expect(result.$id, 'bb8ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5ea5c168bb8'); - expect(result.expire, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, 'bb8ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5ea5c168bb8'); + expect(result.expire, '2020-10-15T06:38:00.000+00:00'); + }); }); } diff --git a/test/src/models/mfa_factors_test.dart b/test/src/models/mfa_factors_test.dart index ed6467d3..64cc55e4 100644 --- a/test/src/models/mfa_factors_test.dart +++ b/test/src/models/mfa_factors_test.dart @@ -14,10 +14,10 @@ void main() { final map = model.toMap(); final result = MfaFactors.fromMap(map); - expect(result.totp, true); - expect(result.phone, true); - expect(result.email, true); - expect(result.recoveryCode, true); - }); + expect(result.totp, true); + expect(result.phone, true); + expect(result.email, true); + expect(result.recoveryCode, true); + }); }); } diff --git a/test/src/models/mfa_recovery_codes_test.dart b/test/src/models/mfa_recovery_codes_test.dart index fa097a49..500913c8 100644 --- a/test/src/models/mfa_recovery_codes_test.dart +++ b/test/src/models/mfa_recovery_codes_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = MfaRecoveryCodes.fromMap(map); - expect(result.recoveryCodes, []); - }); + expect(result.recoveryCodes, []); + }); }); } diff --git a/test/src/models/mfa_type_test.dart b/test/src/models/mfa_type_test.dart index 3f45d288..81657394 100644 --- a/test/src/models/mfa_type_test.dart +++ b/test/src/models/mfa_type_test.dart @@ -6,14 +6,16 @@ void main() { test('model', () { final model = MfaType( secret: '[SHARED_SECRET]', - uri: 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', + uri: + 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', ); final map = model.toMap(); final result = MfaType.fromMap(map); - expect(result.secret, '[SHARED_SECRET]'); - expect(result.uri, 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite'); - }); + expect(result.secret, '[SHARED_SECRET]'); + expect(result.uri, + 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite'); + }); }); } diff --git a/test/src/models/phone_list_test.dart b/test/src/models/phone_list_test.dart index 6ca46a63..bf22a5c7 100644 --- a/test/src/models/phone_list_test.dart +++ b/test/src/models/phone_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = PhoneList.fromMap(map); - expect(result.total, 5); - expect(result.phones, []); - }); + expect(result.total, 5); + expect(result.phones, []); + }); }); } diff --git a/test/src/models/phone_test.dart b/test/src/models/phone_test.dart index d0e5333b..f70db0e3 100644 --- a/test/src/models/phone_test.dart +++ b/test/src/models/phone_test.dart @@ -13,9 +13,9 @@ void main() { final map = model.toMap(); final result = Phone.fromMap(map); - expect(result.code, '+1'); - expect(result.countryCode, 'US'); - expect(result.countryName, 'United States'); - }); + expect(result.code, '+1'); + expect(result.countryCode, 'US'); + expect(result.countryName, 'United States'); + }); }); } diff --git a/test/src/models/preferences_test.dart b/test/src/models/preferences_test.dart index acde349c..9db30b03 100644 --- a/test/src/models/preferences_test.dart +++ b/test/src/models/preferences_test.dart @@ -10,7 +10,6 @@ void main() { final map = model.toMap(); final result = Preferences.fromMap(map); - }); }); } diff --git a/test/src/models/presence_list_test.dart b/test/src/models/presence_list_test.dart index 57a86348..46f69af6 100644 --- a/test/src/models/presence_list_test.dart +++ b/test/src/models/presence_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = PresenceList.fromMap(map); - expect(result.total, 5); - expect(result.presences, []); - }); + expect(result.total, 5); + expect(result.presences, []); + }); }); } diff --git a/test/src/models/presence_test.dart b/test/src/models/presence_test.dart index edcfe5f5..ef2ebe31 100644 --- a/test/src/models/presence_test.dart +++ b/test/src/models/presence_test.dart @@ -16,12 +16,12 @@ void main() { final map = model.toMap(); final result = Presence.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - expect(result.userId, '674af8f3e12a5f9ac0be'); - expect(result.source, 'HTTP'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + expect(result.userId, '674af8f3e12a5f9ac0be'); + expect(result.source, 'HTTP'); + }); }); } diff --git a/test/src/models/row_list_test.dart b/test/src/models/row_list_test.dart index d4900dd4..12693926 100644 --- a/test/src/models/row_list_test.dart +++ b/test/src/models/row_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = RowList.fromMap(map); - expect(result.total, 5); - expect(result.rows, []); - }); + expect(result.total, 5); + expect(result.rows, []); + }); }); } diff --git a/test/src/models/row_test.dart b/test/src/models/row_test.dart index 4e72a449..564bf303 100644 --- a/test/src/models/row_test.dart +++ b/test/src/models/row_test.dart @@ -18,13 +18,13 @@ void main() { final map = model.toMap(); final result = Row.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$sequence, '1'); - expect(result.$tableId, '5e5ea5c15117e'); - expect(result.$databaseId, '5e5ea5c15117e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$sequence, '1'); + expect(result.$tableId, '5e5ea5c15117e'); + expect(result.$databaseId, '5e5ea5c15117e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + }); }); } diff --git a/test/src/models/session_list_test.dart b/test/src/models/session_list_test.dart index eaab249e..708e0583 100644 --- a/test/src/models/session_list_test.dart +++ b/test/src/models/session_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = SessionList.fromMap(map); - expect(result.total, 5); - expect(result.sessions, []); - }); + expect(result.total, 5); + expect(result.sessions, []); + }); }); } diff --git a/test/src/models/session_test.dart b/test/src/models/session_test.dart index 0177e477..689e6048 100644 --- a/test/src/models/session_test.dart +++ b/test/src/models/session_test.dart @@ -39,35 +39,35 @@ void main() { final map = model.toMap(); final result = Session.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5bb8c16897e'); - expect(result.expire, '2020-10-15T06:38:00.000+00:00'); - expect(result.provider, 'email'); - expect(result.providerUid, 'user@example.com'); - expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); - expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - expect(result.ip, '127.0.0.1'); - expect(result.osCode, 'Mac'); - expect(result.osName, 'Mac'); - expect(result.osVersion, 'Mac'); - expect(result.clientType, 'browser'); - expect(result.clientCode, 'CM'); - expect(result.clientName, 'Chrome Mobile iOS'); - expect(result.clientVersion, '84.0'); - expect(result.clientEngine, 'WebKit'); - expect(result.clientEngineVersion, '605.1.15'); - expect(result.deviceName, 'smartphone'); - expect(result.deviceBrand, 'Google'); - expect(result.deviceModel, 'Nexus 5'); - expect(result.countryCode, 'US'); - expect(result.countryName, 'United States'); - expect(result.current, true); - expect(result.factors, []); - expect(result.secret, '5e5bb8c16897e'); - expect(result.mfaUpdatedAt, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5bb8c16897e'); + expect(result.expire, '2020-10-15T06:38:00.000+00:00'); + expect(result.provider, 'email'); + expect(result.providerUid, 'user@example.com'); + expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); + expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + expect(result.ip, '127.0.0.1'); + expect(result.osCode, 'Mac'); + expect(result.osName, 'Mac'); + expect(result.osVersion, 'Mac'); + expect(result.clientType, 'browser'); + expect(result.clientCode, 'CM'); + expect(result.clientName, 'Chrome Mobile iOS'); + expect(result.clientVersion, '84.0'); + expect(result.clientEngine, 'WebKit'); + expect(result.clientEngineVersion, '605.1.15'); + expect(result.deviceName, 'smartphone'); + expect(result.deviceBrand, 'Google'); + expect(result.deviceModel, 'Nexus 5'); + expect(result.countryCode, 'US'); + expect(result.countryName, 'United States'); + expect(result.current, true); + expect(result.factors, []); + expect(result.secret, '5e5bb8c16897e'); + expect(result.mfaUpdatedAt, '2020-10-15T06:38:00.000+00:00'); + }); }); } diff --git a/test/src/models/subscriber_test.dart b/test/src/models/subscriber_test.dart index 94c6a502..7445514c 100644 --- a/test/src/models/subscriber_test.dart +++ b/test/src/models/subscriber_test.dart @@ -10,15 +10,15 @@ void main() { $updatedAt: '2020-10-15T06:38:00.000+00:00', targetId: '259125845563242502', target: Target( - $id: '259125845563242502', - $createdAt: '2020-10-15T06:38:00.000+00:00', - $updatedAt: '2020-10-15T06:38:00.000+00:00', - name: 'Apple iPhone 12', - userId: '259125845563242502', - providerType: 'email', - identifier: 'token', - expired: true, - ), + $id: '259125845563242502', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Apple iPhone 12', + userId: '259125845563242502', + providerType: 'email', + identifier: 'token', + expired: true, + ), userId: '5e5ea5c16897e', userName: 'Aegon Targaryen', topicId: '259125845563242502', @@ -28,14 +28,14 @@ void main() { final map = model.toMap(); final result = Subscriber.fromMap(map); - expect(result.$id, '259125845563242502'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.targetId, '259125845563242502'); - expect(result.userId, '5e5ea5c16897e'); - expect(result.userName, 'Aegon Targaryen'); - expect(result.topicId, '259125845563242502'); - expect(result.providerType, 'email'); - }); + expect(result.$id, '259125845563242502'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.targetId, '259125845563242502'); + expect(result.userId, '5e5ea5c16897e'); + expect(result.userName, 'Aegon Targaryen'); + expect(result.topicId, '259125845563242502'); + expect(result.providerType, 'email'); + }); }); } diff --git a/test/src/models/target_test.dart b/test/src/models/target_test.dart index a49f3def..49f1e75e 100644 --- a/test/src/models/target_test.dart +++ b/test/src/models/target_test.dart @@ -18,14 +18,14 @@ void main() { final map = model.toMap(); final result = Target.fromMap(map); - expect(result.$id, '259125845563242502'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.name, 'Apple iPhone 12'); - expect(result.userId, '259125845563242502'); - expect(result.providerType, 'email'); - expect(result.identifier, 'token'); - expect(result.expired, true); - }); + expect(result.$id, '259125845563242502'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.name, 'Apple iPhone 12'); + expect(result.userId, '259125845563242502'); + expect(result.providerType, 'email'); + expect(result.identifier, 'token'); + expect(result.expired, true); + }); }); } diff --git a/test/src/models/team_list_test.dart b/test/src/models/team_list_test.dart index a19b667d..fe2f4a85 100644 --- a/test/src/models/team_list_test.dart +++ b/test/src/models/team_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = TeamList.fromMap(map); - expect(result.total, 5); - expect(result.teams, []); - }); + expect(result.total, 5); + expect(result.teams, []); + }); }); } diff --git a/test/src/models/team_test.dart b/test/src/models/team_test.dart index 43b2e45c..f652f2c1 100644 --- a/test/src/models/team_test.dart +++ b/test/src/models/team_test.dart @@ -16,11 +16,11 @@ void main() { final map = model.toMap(); final result = Team.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.name, 'VIP'); - expect(result.total, 7); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.name, 'VIP'); + expect(result.total, 7); + }); }); } diff --git a/test/src/models/token_test.dart b/test/src/models/token_test.dart index 7ee4b268..8f0957c9 100644 --- a/test/src/models/token_test.dart +++ b/test/src/models/token_test.dart @@ -16,12 +16,12 @@ void main() { final map = model.toMap(); final result = Token.fromMap(map); - expect(result.$id, 'bb8ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5ea5c168bb8'); - expect(result.secret, ''); - expect(result.expire, '2020-10-15T06:38:00.000+00:00'); - expect(result.phrase, 'Golden Fox'); - }); + expect(result.$id, 'bb8ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5ea5c168bb8'); + expect(result.secret, ''); + expect(result.expire, '2020-10-15T06:38:00.000+00:00'); + expect(result.phrase, 'Golden Fox'); + }); }); } diff --git a/test/src/models/transaction_list_test.dart b/test/src/models/transaction_list_test.dart index 68023e18..a524ef71 100644 --- a/test/src/models/transaction_list_test.dart +++ b/test/src/models/transaction_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = TransactionList.fromMap(map); - expect(result.total, 5); - expect(result.transactions, []); - }); + expect(result.total, 5); + expect(result.transactions, []); + }); }); } diff --git a/test/src/models/transaction_test.dart b/test/src/models/transaction_test.dart index 723ebac2..0169427f 100644 --- a/test/src/models/transaction_test.dart +++ b/test/src/models/transaction_test.dart @@ -16,12 +16,12 @@ void main() { final map = model.toMap(); final result = Transaction.fromMap(map); - expect(result.$id, '259125845563242502'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.status, 'pending'); - expect(result.operations, 5); - expect(result.expiresAt, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, '259125845563242502'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.status, 'pending'); + expect(result.operations, 5); + expect(result.expiresAt, '2020-10-15T06:38:00.000+00:00'); + }); }); } diff --git a/test/src/models/user_test.dart b/test/src/models/user_test.dart index c058ea26..77c7dd97 100644 --- a/test/src/models/user_test.dart +++ b/test/src/models/user_test.dart @@ -26,21 +26,21 @@ void main() { final map = model.toMap(); final result = User.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.name, 'John Doe'); - expect(result.registration, '2020-10-15T06:38:00.000+00:00'); - expect(result.status, true); - expect(result.labels, []); - expect(result.passwordUpdate, '2020-10-15T06:38:00.000+00:00'); - expect(result.email, 'john@appwrite.io'); - expect(result.phone, '+4930901820'); - expect(result.emailVerification, true); - expect(result.phoneVerification, true); - expect(result.mfa, true); - expect(result.targets, []); - expect(result.accessedAt, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.name, 'John Doe'); + expect(result.registration, '2020-10-15T06:38:00.000+00:00'); + expect(result.status, true); + expect(result.labels, []); + expect(result.passwordUpdate, '2020-10-15T06:38:00.000+00:00'); + expect(result.email, 'john@appwrite.io'); + expect(result.phone, '+4930901820'); + expect(result.emailVerification, true); + expect(result.phoneVerification, true); + expect(result.mfa, true); + expect(result.targets, []); + expect(result.accessedAt, '2020-10-15T06:38:00.000+00:00'); + }); }); } From 31822f89fb9c991b1a585e0da813908c06043a2e Mon Sep 17 00:00:00 2001 From: root Date: Thu, 25 Jun 2026 04:46:45 +0000 Subject: [PATCH 3/8] chore: update Flutter SDK to 25.2.0 --- CHANGELOG.md | 3 +- lib/appwrite.dart | 2 +- lib/channel.dart | 20 +- lib/client_browser.dart | 2 +- lib/client_io.dart | 2 +- lib/operator.dart | 11 +- lib/query.dart | 91 +- lib/realtime_browser.dart | 2 +- lib/realtime_io.dart | 2 +- lib/role.dart | 2 +- lib/services/account.dart | 1560 +++++----- lib/services/avatars.dart | 351 +-- lib/services/databases.dart | 603 ++-- lib/services/functions.dart | 115 +- lib/services/graphql.dart | 50 +- lib/services/locale.dart | 142 +- lib/services/messaging.dart | 70 +- lib/services/presences.dart | 182 +- lib/services/storage.dart | 342 +-- lib/services/tables_db.dart | 547 ++-- lib/services/teams.dart | 421 ++- lib/src/client.dart | 4 +- lib/src/client_base.dart | 7 - lib/src/client_browser.dart | 15 +- lib/src/client_io.dart | 15 +- lib/src/client_mixin.dart | 9 +- lib/src/enums/authentication_factor.dart | 18 +- lib/src/enums/authenticator_type.dart | 12 +- lib/src/enums/browser.dart | 38 +- lib/src/enums/browser_permission.dart | 50 +- lib/src/enums/browser_theme.dart | 14 +- lib/src/enums/credit_card.dart | 44 +- lib/src/enums/execution_method.dart | 24 +- lib/src/enums/execution_status.dart | 20 +- lib/src/enums/execution_trigger.dart | 16 +- 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 | 96 +- lib/src/enums/timezone.dart | 848 +++--- lib/src/exception.dart | 2 +- lib/src/models/algo_argon2.dart | 62 +- lib/src/models/algo_bcrypt.dart | 32 +- lib/src/models/algo_md5.dart | 32 +- lib/src/models/algo_phpass.dart | 32 +- lib/src/models/algo_scrypt.dart | 86 +- lib/src/models/algo_scrypt_modified.dart | 62 +- lib/src/models/algo_sha.dart | 32 +- lib/src/models/continent.dart | 42 +- lib/src/models/continent_list.dart | 43 +- lib/src/models/country.dart | 42 +- lib/src/models/country_list.dart | 43 +- lib/src/models/currency.dart | 110 +- lib/src/models/currency_list.dart | 43 +- lib/src/models/document.dart | 102 +- lib/src/models/document_list.dart | 47 +- lib/src/models/execution.dart | 246 +- lib/src/models/execution_list.dart | 43 +- lib/src/models/file.dart | 194 +- lib/src/models/file_list.dart | 42 +- lib/src/models/headers.dart | 42 +- lib/src/models/identity.dart | 122 +- lib/src/models/identity_list.dart | 43 +- lib/src/models/jwt.dart | 32 +- lib/src/models/language.dart | 52 +- lib/src/models/language_list.dart | 43 +- lib/src/models/locale.dart | 110 +- lib/src/models/locale_code.dart | 42 +- lib/src/models/locale_code_list.dart | 43 +- lib/src/models/log.dart | 290 +- lib/src/models/log_list.dart | 42 +- lib/src/models/membership.dart | 206 +- lib/src/models/membership_list.dart | 43 +- lib/src/models/mfa_challenge.dart | 62 +- lib/src/models/mfa_factors.dart | 62 +- lib/src/models/mfa_recovery_codes.dart | 32 +- lib/src/models/mfa_type.dart | 42 +- lib/src/models/model.dart | 2 +- lib/src/models/phone.dart | 52 +- lib/src/models/phone_list.dart | 42 +- lib/src/models/preferences.dart | 32 +- lib/src/models/presence.dart | 112 +- lib/src/models/presence_list.dart | 43 +- lib/src/models/row.dart | 102 +- lib/src/models/row_list.dart | 46 +- lib/src/models/session.dart | 360 +-- lib/src/models/session_list.dart | 43 +- lib/src/models/subscriber.dart | 112 +- lib/src/models/target.dart | 112 +- lib/src/models/team.dart | 98 +- lib/src/models/team_list.dart | 42 +- lib/src/models/token.dart | 98 +- lib/src/models/transaction.dart | 98 +- lib/src/models/transaction_list.dart | 43 +- lib/src/models/user.dart | 332 +- lib/src/realtime.dart | 6 +- lib/src/realtime_io.dart | 4 +- lib/src/realtime_message.dart | 2 +- lib/src/realtime_mixin.dart | 31 +- lib/src/realtime_response.dart | 10 +- lib/src/realtime_stub.dart | 4 +- test/channel_test.dart | 42 +- test/query_test.dart | 1 + test/services/account_test.dart | 2691 +++++++++-------- test/services/avatars_test.dart | 204 +- test/services/databases_test.dart | 585 ++-- test/services/functions_test.dart | 188 +- test/services/graphql_test.dart | 71 +- test/services/locale_test.dart | 253 +- test/services/messaging_test.dart | 122 +- test/services/presences_test.dart | 202 +- test/services/storage_test.dart | 341 ++- test/services/tables_db_test.dart | 585 ++-- test/services/teams_test.dart | 555 ++-- test/src/models/algo_argon2_test.dart | 10 +- test/src/models/algo_bcrypt_test.dart | 4 +- test/src/models/algo_md5_test.dart | 4 +- test/src/models/algo_phpass_test.dart | 4 +- .../src/models/algo_scrypt_modified_test.dart | 14 +- test/src/models/algo_scrypt_test.dart | 12 +- test/src/models/algo_sha_test.dart | 4 +- test/src/models/continent_list_test.dart | 6 +- test/src/models/continent_test.dart | 6 +- test/src/models/country_list_test.dart | 6 +- test/src/models/country_test.dart | 6 +- test/src/models/currency_list_test.dart | 6 +- test/src/models/currency_test.dart | 16 +- test/src/models/document_list_test.dart | 6 +- test/src/models/document_test.dart | 16 +- test/src/models/execution_list_test.dart | 6 +- test/src/models/execution_test.dart | 36 +- test/src/models/file_list_test.dart | 6 +- test/src/models/file_test.dart | 30 +- test/src/models/headers_test.dart | 6 +- test/src/models/identity_list_test.dart | 6 +- test/src/models/identity_test.dart | 22 +- test/src/models/jwt_test.dart | 8 +- test/src/models/language_list_test.dart | 6 +- test/src/models/language_test.dart | 8 +- test/src/models/locale_code_list_test.dart | 6 +- test/src/models/locale_code_test.dart | 6 +- test/src/models/locale_test.dart | 16 +- test/src/models/log_list_test.dart | 6 +- test/src/models/log_test.dart | 46 +- test/src/models/membership_list_test.dart | 6 +- test/src/models/membership_test.dart | 32 +- test/src/models/mfa_challenge_test.dart | 10 +- test/src/models/mfa_factors_test.dart | 10 +- test/src/models/mfa_recovery_codes_test.dart | 4 +- test/src/models/mfa_type_test.dart | 10 +- test/src/models/phone_list_test.dart | 6 +- test/src/models/phone_test.dart | 8 +- test/src/models/preferences_test.dart | 1 + test/src/models/presence_list_test.dart | 6 +- test/src/models/presence_test.dart | 14 +- test/src/models/row_list_test.dart | 6 +- test/src/models/row_test.dart | 16 +- test/src/models/session_list_test.dart | 6 +- test/src/models/session_test.dart | 60 +- test/src/models/subscriber_test.dart | 36 +- test/src/models/target_test.dart | 18 +- test/src/models/team_list_test.dart | 6 +- test/src/models/team_test.dart | 12 +- test/src/models/token_test.dart | 14 +- test/src/models/transaction_list_test.dart | 6 +- test/src/models/transaction_test.dart | 14 +- test/src/models/user_test.dart | 32 +- 167 files changed, 8662 insertions(+), 8518 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9413e707..d611a0a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,8 @@ ## 25.2.0 -* Added: Realtime connections now authenticate with the configured JWT. * Added: Forwarded `impersonateUserId` on `avatars` and `storage` file requests. -* Fixed: URL-encode path parameters across all services. +* Deprecated: `databases` transaction and document methods in favor of `TablesDB`. ## 25.1.0 diff --git a/lib/appwrite.dart b/lib/appwrite.dart index ae51be5e..6615de8a 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.9.x. +/// This SDK is compatible with Appwrite server version 1.9.x. /// For older versions, please check /// [previous releases](https://github.com/appwrite/sdk-for-flutter/releases). library appwrite; diff --git a/lib/channel.dart b/lib/channel.dart index afc68efa..d511f5a4 100644 --- a/lib/channel.dart +++ b/lib/channel.dart @@ -2,33 +2,19 @@ part of appwrite; // Marker classes for type safety class _Root {} - class _Database {} - class _Collection {} - class _Document {} - class _TablesDB {} - class _Table {} - class _Row {} - class _Bucket {} - class _File {} - class _Func {} - class _Execution {} - class _Team {} - class _Membership {} - class _Presence {} - class _Resolved {} // Helper function for normalizing ID @@ -113,15 +99,15 @@ extension DatabaseChannel on Channel<_Database> { /// Only available on Channel<_Collection> extension CollectionChannel on Channel<_Collection> { - Channel<_Document> document([String? id]) => - _next<_Document>('documents', id); + Channel<_Document> document([String? id]) => _next<_Document>('documents', id); } // --- TABLESDB ROUTE --- /// Only available on Channel<_TablesDB> extension TablesDBChannel on Channel<_TablesDB> { - Channel<_Table> table(String id) => _next<_Table>('tables', id); + Channel<_Table> table(String id) => + _next<_Table>('tables', id); } /// Only available on Channel<_Table> 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/operator.dart b/lib/operator.dart index 337dda30..9dd7f4c7 100644 --- a/lib/operator.dart +++ b/lib/operator.dart @@ -31,7 +31,7 @@ class Operator { result['method'] = method; - if (values != null) { + if(values != null) { result['values'] = values is List ? values : [values]; } @@ -147,7 +147,8 @@ class Operator { Operator._('arrayRemove', [value]).toString(); /// Remove duplicate values from an array attribute. - static String arrayUnique() => Operator._('arrayUnique', []).toString(); + static String arrayUnique() => + Operator._('arrayUnique', []).toString(); /// Keep only values that exist in both the current array and the provided array. static String arrayIntersect(List values) => @@ -172,7 +173,8 @@ class Operator { Operator._('stringReplace', [search, replace]).toString(); /// Toggle a boolean attribute. - static String toggle() => Operator._('toggle', []).toString(); + static String toggle() => + Operator._('toggle', []).toString(); /// Add days to a date attribute. static String dateAddDays(int days) => @@ -183,5 +185,6 @@ class Operator { Operator._('dateSubDays', [days]).toString(); /// Set a date attribute to the current date and time. - static String dateSetNow() => Operator._('dateSetNow', []).toString(); + static String dateSetNow() => + Operator._('dateSetNow', []).toString(); } diff --git a/lib/query.dart b/lib/query.dart index 3693dce6..95365bf7 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. @@ -140,46 +140,50 @@ class Query { Query._('notEndsWith', attribute, value).toString(); /// Filter resources where document was created before [value]. - static String createdBefore(String value) => lessThan('\$createdAt', value); + static String createdBefore(String value) => + lessThan('\$createdAt', value); /// Filter resources where document was created after [value]. - static String createdAfter(String value) => greaterThan('\$createdAt', value); + static String createdAfter(String value) => + greaterThan('\$createdAt', value); /// Filter resources where document was created between [start] and [end] (inclusive). static String createdBetween(String start, String end) => between('\$createdAt', start, end); /// Filter resources where document was updated before [value]. - static String updatedBefore(String value) => lessThan('\$updatedAt', value); + static String updatedBefore(String value) => + lessThan('\$updatedAt', value); /// Filter resources where document was updated after [value]. - static String updatedAfter(String value) => greaterThan('\$updatedAt', value); + static String updatedAfter(String value) => + greaterThan('\$updatedAt', value); /// Filter resources where document was updated between [start] and [end] (inclusive). static String updatedBetween(String start, String end) => between('\$updatedAt', start, end); static String or(List queries) => Query._( - 'or', - null, - queries.map((query) => jsonDecode(query)).toList(), - ).toString(); + 'or', + null, + queries.map((query) => jsonDecode(query)).toList(), + ).toString(); static String and(List queries) => Query._( - 'and', - null, - queries.map((query) => jsonDecode(query)).toList(), - ).toString(); + 'and', + null, + queries.map((query) => jsonDecode(query)).toList(), + ).toString(); /// Filter array elements where at least one element matches all the specified queries. /// /// [attribute] The attribute containing the array to filter on. /// [queries] The list of query strings to match against array elements. static String elemMatch(String attribute, List queries) => Query._( - 'elemMatch', - attribute, - queries.map((query) => jsonDecode(query)).toList(), - ).toString(); + 'elemMatch', + attribute, + queries.map((query) => jsonDecode(query)).toList(), + ).toString(); /// Specify which attributes should be returned by the API call. static String select(List attributes) => @@ -194,17 +198,18 @@ class Query { Query._('orderDesc', attribute).toString(); /// Sort results randomly. - static String orderRandom() => Query._('orderRandom').toString(); + static String orderRandom() => + Query._('orderRandom').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) => @@ -214,43 +219,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, 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) => @@ -283,4 +272,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 48b60041..9c021e93 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 { final String apiPath = '/account'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -29,30 +30,29 @@ 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 { final String apiPath = '/account'; - final Map apiParams = { - 'userId': userId, - 'email': email, - 'password': password, - if (name != null) 'name': name, - }; + final Map apiParams = { + 'userId': userId, + + 'email': email, + + 'password': password, + + if (name != null) 'name': name, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 @@ -62,65 +62,66 @@ 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 { final String apiPath = '/account/email'; - final Map apiParams = { - 'email': email, - 'password': password, - }; + final Map apiParams = { + 'email': email, + + 'password': password, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, bool? total}) async { + Future listIdentities({List? queries, bool? total}) async { final String apiPath = '/account/identities'; - final Map apiParams = { - if (queries != null) 'queries': queries, - if (total != null) 'total': total, - }; + final Map apiParams = { + if (queries != null) 'queries': queries, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + if (total != null) 'total': total, - final res = await client.call(HttpMethod.get, - path: apiPath, params: apiParams, headers: apiHeaders); + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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 @@ -131,20 +132,20 @@ class Account extends Service { Future createJWT({int? duration}) async { final String apiPath = '/account/jwts'; - final Map apiParams = { - if (duration != null) 'duration': duration, - }; + final Map apiParams = { + if (duration != null) 'duration': duration, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + }; - final res = await client.call(HttpMethod.post, - path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 @@ -152,224 +153,212 @@ class Account extends Service { Future listLogs({List? queries, bool? total}) async { final String apiPath = '/account/logs'; - final Map apiParams = { - if (queries != null) 'queries': queries, - if (total != null) 'total': total, - }; + final Map apiParams = { + if (queries != null) 'queries': queries, + + if (total != null) 'total': total, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 { final String apiPath = '/account/mfa'; - final Map apiParams = { - 'mfa': mfa, - }; + final Map apiParams = { + 'mfa': mfa, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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); + @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 apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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.MfaType.fromMap(res.data); - 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); + Future createMFAAuthenticator({required enums.AuthenticatorType type}) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + + final Map apiParams = { + }; - final Map apiParams = {}; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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.MfaType.fromMap(res.data); - 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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); + 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 apiParams = { - 'otp': otp, - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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.User.fromMap(res.data); - 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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 { final String apiPath = '/account/mfa/challenges'; - final Map apiParams = { - 'factor': factor.value, - }; + final Map apiParams = { + 'factor': factor.value, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 { final String apiPath = '/account/mfa/challenges'; - final Map apiParams = { - 'factor': factor.value, - }; + final Map apiParams = { + 'factor': factor.value, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + }; - final res = await client.call(HttpMethod.post, - path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 @@ -377,27 +366,26 @@ 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 { final String apiPath = '/account/mfa/challenges'; - final Map apiParams = { - 'challengeId': challengeId, - 'otp': otp, - }; + final Map apiParams = { + 'challengeId': challengeId, + + 'otp': otp, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 @@ -405,83 +393,84 @@ 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 { final String apiPath = '/account/mfa/challenges'; - final Map apiParams = { - 'challengeId': challengeId, - 'otp': otp, - }; + final Map apiParams = { + 'challengeId': challengeId, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + 'otp': otp, - final res = await client.call(HttpMethod.put, - path: apiPath, params: apiParams, headers: apiHeaders); + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 { final String apiPath = '/account/mfa/factors'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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 { final String apiPath = '/account/mfa/factors'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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 @@ -491,17 +480,18 @@ class Account extends Service { Future getMFARecoveryCodes() async { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -509,23 +499,22 @@ 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 { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 @@ -536,41 +525,40 @@ class Account extends Service { Future createMFARecoveryCodes() async { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 @@ -580,62 +568,62 @@ class Account extends Service { Future updateMFARecoveryCodes() async { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 { final String apiPath = '/account/name'; - final Map apiParams = { - 'name': name, - }; + final Map apiParams = { + 'name': name, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 { final String apiPath = '/account/password'; - final Map apiParams = { - 'password': password, - if (oldPassword != null) 'oldPassword': oldPassword, - }; + final Map apiParams = { + 'password': password, + + if (oldPassword != null) 'oldPassword': oldPassword, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 @@ -643,42 +631,43 @@ 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 { final String apiPath = '/account/phone'; - final Map apiParams = { - 'phone': phone, - 'password': password, - }; + final Map apiParams = { + 'phone': phone, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + 'password': password, - final res = await client.call(HttpMethod.patch, - path: apiPath, params: apiParams, headers: apiHeaders); + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 { final String apiPath = '/account/prefs'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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 @@ -687,20 +676,20 @@ class Account extends Service { Future updatePrefs({required Map prefs}) async { final String apiPath = '/account/prefs'; - final Map apiParams = { - 'prefs': prefs, - }; + final Map apiParams = { + 'prefs': prefs, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + }; - final res = await client.call(HttpMethod.patch, - path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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. @@ -711,25 +700,25 @@ 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 { final String apiPath = '/account/recovery'; - final Map apiParams = { - 'email': email, - 'url': url, - }; + final Map apiParams = { + 'email': email, + + 'url': url, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 @@ -737,33 +726,32 @@ 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 { final 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 @@ -771,17 +759,18 @@ class Account extends Service { Future listSessions() async { final String apiPath = '/account/sessions'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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 @@ -789,17 +778,18 @@ class Account extends Service { Future deleteSessions() async { final String apiPath = '/account/sessions'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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 @@ -812,216 +802,213 @@ class Account extends Service { Future createAnonymousSession() async { final String apiPath = '/account/sessions/anonymous'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 { final String apiPath = '/account/sessions/email'; - final Map apiParams = { - 'email': email, - 'password': password, - }; + final Map apiParams = { + 'email': email, + + 'password': password, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + }; - final res = await client.call(HttpMethod.post, - path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 { final String apiPath = '/account/sessions/magic-url'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; + final Map apiParams = { + 'userId': userId, + + 'secret': secret, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 = { - if (success != null) 'success': success, - if (failure != null) 'failure': failure, - if (scopes != null) 'scopes': scopes, - 'project': client.config['project'], - }; - - final List query = []; - - params.forEach((key, value) { - if (value is List) { - for (var item in value) { - query.add( + /// + 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 = { + + if (success != null) 'success': success, + + if (failure != null) 'failure': failure, + + if (scopes != null) '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); + } + } 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 { final String apiPath = '/account/sessions/phone'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; + final Map apiParams = { + 'userId': userId, + + 'secret': secret, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + }; - final res = await client.call(HttpMethod.put, - path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 { final String apiPath = '/account/sessions/token'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; + final Map apiParams = { + 'userId': userId, + + 'secret': secret, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 apiParams = {}; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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, @@ -1030,20 +1017,20 @@ 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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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 @@ -1052,18 +1039,18 @@ class Account extends Service { Future updateStatus() async { final String apiPath = '/account/status'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 @@ -1071,28 +1058,27 @@ 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 { final String apiPath = '/account/targets/push'; - final Map apiParams = { - 'targetId': targetId, - 'identifier': identifier, - if (providerId != null) 'providerId': providerId, - }; + final Map apiParams = { + 'targetId': targetId, + + 'identifier': identifier, + + if (providerId != null) 'providerId': providerId, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 @@ -1100,45 +1086,43 @@ 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); + 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 apiParams = { - 'identifier': identifier, - }; + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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.Target.fromMap(res.data); - 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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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 @@ -1150,31 +1134,32 @@ 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 { final String apiPath = '/account/tokens/email'; - final Map apiParams = { - 'userId': userId, - 'email': email, - if (phrase != null) 'phrase': phrase, - }; + final Map apiParams = { + 'userId': userId, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + 'email': email, - final res = await client.call(HttpMethod.post, - path: apiPath, params: apiParams, headers: apiHeaders); + if (phrase != null) 'phrase': phrase, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 @@ -1186,88 +1171,87 @@ 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 { final String apiPath = '/account/tokens/magic-url'; - final Map apiParams = { - 'userId': userId, - 'email': email, - if (url != null) 'url': url, - if (phrase != null) 'phrase': phrase, - }; + final Map apiParams = { + 'userId': userId, + + 'email': email, + + if (url != null) 'url': url, + + if (phrase != null) 'phrase': phrase, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 = { - if (success != null) 'success': success, - if (failure != null) 'failure': failure, - if (scopes != null) 'scopes': scopes, - 'project': client.config['project'], - }; - - final List query = []; - - params.forEach((key, value) { - if (value is List) { - for (var item in value) { - query.add( + 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 = { + + if (success != null) 'success': success, + + if (failure != null) 'failure': failure, + + if (scopes != null) '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); + } + } 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 @@ -1276,29 +1260,29 @@ 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 { final String apiPath = '/account/tokens/phone'; - final Map apiParams = { - 'userId': userId, - 'phone': phone, - }; + final Map apiParams = { + 'userId': userId, + + 'phone': phone, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + }; - final res = await client.call(HttpMethod.post, - path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 @@ -1310,29 +1294,29 @@ 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 createEmailVerification({required String url}) async { final String apiPath = '/account/verifications/email'; - final Map apiParams = { - 'url': url, - }; + final Map apiParams = { + 'url': url, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 @@ -1344,83 +1328,81 @@ 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. - /// - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.createEmailVerification` instead.') + /// + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.createEmailVerification` instead.') Future createVerification({required String url}) async { final String apiPath = '/account/verifications/email'; - final Map apiParams = { - 'url': url, - }; + final Map apiParams = { + 'url': url, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + }; - final res = await client.call(HttpMethod.post, - path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 updateEmailVerification( - {required String userId, required String secret}) async { + Future updateEmailVerification({required String userId, required String secret}) async { final String apiPath = '/account/verifications/email'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; + final Map apiParams = { + 'userId': userId, + + 'secret': secret, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 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. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.updateEmailVerification` instead.') - Future updateVerification( - {required String userId, required String secret}) async { + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.updateEmailVerification` instead.') + Future updateVerification({required String userId, required String secret}) async { final String apiPath = '/account/verifications/email'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; + final Map apiParams = { + 'userId': userId, + + 'secret': secret, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 @@ -1434,42 +1416,42 @@ class Account extends Service { Future createPhoneVerification() async { final String apiPath = '/account/verifications/phone'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 { final String apiPath = '/account/verifications/phone'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; + final Map apiParams = { + 'userId': userId, + + 'secret': secret, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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); } } diff --git a/lib/services/avatars.dart b/lib/services/avatars.dart index cdd93e6e..4dca3b16 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,134 +11,139 @@ 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 = { - if (width != null) 'width': width, - if (height != null) 'height': height, - if (quality != null) 'quality': quality, - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + + if (width != null) 'width': width, + + if (height != null) 'height': height, + + if (quality != null) 'quality': quality, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 = { - if (width != null) 'width': width, - if (height != null) 'height': height, - if (quality != null) 'quality': quality, - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + + if (width != null) 'width': width, + + if (height != null) 'height': height, + + if (quality != null) 'quality': quality, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 { final String apiPath = '/avatars/favicon'; - final Map params = { - 'url': url, - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; + 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'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 = { - if (width != null) 'width': width, - if (height != null) 'height': height, - if (quality != null) 'quality': quality, - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + + if (width != null) 'width': width, + + if (height != null) 'height': height, + + if (quality != null) 'quality': quality, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 { final String apiPath = '/avatars/image'; - final Map params = { - 'url': url, - if (width != null) 'width': width, - if (height != null) 'height': height, - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - final res = await client.call(HttpMethod.get, - path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + + 'url': url, + + if (width != null) 'width': width, + + if (height != null) 'height': height, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 @@ -146,117 +151,125 @@ 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 { final String apiPath = '/avatars/initials'; - final Map params = { - if (name != null) 'name': name, - if (width != null) 'width': width, - if (height != null) 'height': height, - if (background != null) 'background': background, - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - final res = await client.call(HttpMethod.get, - path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + + if (name != null) 'name': name, + + if (width != null) 'width': width, + + if (height != null) 'height': height, + + if (background != null) 'background': background, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 { final String apiPath = '/avatars/qr'; - final Map params = { - 'text': text, - if (size != null) 'size': size, - if (margin != null) 'margin': margin, - if (download != null) 'download': download, - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - final res = await client.call(HttpMethod.get, - path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + + 'text': text, + + if (size != null) 'size': size, + + if (margin != null) 'margin': margin, + + if (download != null) 'download': download, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// Use this endpoint to capture a screenshot of any website URL. This endpoint /// uses a headless browser to render the webpage and capture it as an image. - /// + /// /// You can configure the browser viewport size, theme, user agent, /// geolocation, permissions, and more. Capture either just the viewport or the /// full page scroll. - /// + /// /// When width and height are specified, the image is resized accordingly. If /// both dimensions are 0, the API provides an image at original size. If /// dimensions are not specified, the default viewport size is 1280x720px. - Future getScreenshot( - {required String url, - Map? headers, - int? viewportWidth, - int? viewportHeight, - double? scale, - enums.BrowserTheme? theme, - String? userAgent, - bool? fullpage, - String? locale, - enums.Timezone? timezone, - double? latitude, - double? longitude, - double? accuracy, - bool? touch, - List? permissions, - int? sleep, - int? width, - int? height, - int? quality, - enums.ImageFormat? output}) async { + Future getScreenshot({required String url, Map? headers, int? viewportWidth, int? viewportHeight, double? scale, enums.BrowserTheme? theme, String? userAgent, bool? fullpage, String? locale, enums.Timezone? timezone, double? latitude, double? longitude, double? accuracy, bool? touch, List? permissions, int? sleep, int? width, int? height, int? quality, enums.ImageFormat? output}) async { final String apiPath = '/avatars/screenshots'; - final Map params = { - 'url': url, - if (headers != null) 'headers': headers, - if (viewportWidth != null) 'viewportWidth': viewportWidth, - if (viewportHeight != null) 'viewportHeight': viewportHeight, - if (scale != null) 'scale': scale, - if (theme != null) 'theme': theme.value, - if (userAgent != null) 'userAgent': userAgent, - if (fullpage != null) 'fullpage': fullpage, - if (locale != null) 'locale': locale, - if (timezone != null) 'timezone': timezone.value, - if (latitude != null) 'latitude': latitude, - if (longitude != null) 'longitude': longitude, - if (accuracy != null) 'accuracy': accuracy, - if (touch != null) 'touch': touch, - if (permissions != null) - 'permissions': permissions.map((e) => e.value).toList(), - if (sleep != null) 'sleep': sleep, - if (width != null) 'width': width, - if (height != null) 'height': height, - if (quality != null) 'quality': quality, - if (output != null) 'output': output.value, - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - final res = await client.call(HttpMethod.get, - path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + + 'url': url, + + if (headers != null) 'headers': headers, + + if (viewportWidth != null) 'viewportWidth': viewportWidth, + + if (viewportHeight != null) 'viewportHeight': viewportHeight, + + if (scale != null) 'scale': scale, + + if (theme != null) 'theme': theme.value, + + if (userAgent != null) 'userAgent': userAgent, + + if (fullpage != null) 'fullpage': fullpage, + + if (locale != null) 'locale': locale, + + if (timezone != null) 'timezone': timezone.value, + + if (latitude != null) 'latitude': latitude, + + if (longitude != null) 'longitude': longitude, + + if (accuracy != null) 'accuracy': accuracy, + + if (touch != null) 'touch': touch, + + if (permissions != null) 'permissions': permissions.map((e) => e.value).toList(), + + if (sleep != null) 'sleep': sleep, + + if (width != null) 'width': width, + + if (height != null) 'height': height, + + if (quality != null) 'quality': quality, + + if (output != null) 'output': output.value, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } } diff --git a/lib/services/databases.dart b/lib/services/databases.dart index 0ff3fb72..0bfd935a 100644 --- a/lib/services/databases.dart +++ b/lib/services/databases.dart @@ -1,418 +1,339 @@ 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); /// List transactions across all databases. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.listTransactions` instead.') - Future listTransactions( - {List? queries}) async { + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.listTransactions` instead.') + Future listTransactions({List? queries}) async { final String apiPath = '/databases/transactions'; - final Map apiParams = { - if (queries != null) 'queries': queries, - }; + final Map apiParams = { + if (queries != null) 'queries': queries, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + }; - final res = await client.call(HttpMethod.get, - path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.TransactionList.fromMap(res.data); - return models.TransactionList.fromMap(res.data); } /// Create a new transaction. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.createTransaction` instead.') + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.createTransaction` instead.') Future createTransaction({int? ttl}) async { final String apiPath = '/databases/transactions'; - final Map apiParams = { - if (ttl != null) 'ttl': ttl, - }; + final Map apiParams = { + if (ttl != null) 'ttl': ttl, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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.Transaction.fromMap(res.data); - return models.Transaction.fromMap(res.data); } /// Get a transaction by its unique ID. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.getTransaction` instead.') - Future getTransaction( - {required String transactionId}) async { - final String apiPath = '/databases/transactions/{transactionId}' - .replaceAll('{transactionId}', transactionId); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.getTransaction` instead.') + Future getTransaction({required String transactionId}) async { + final String apiPath = '/databases/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + }; - final Map apiParams = {}; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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.Transaction.fromMap(res.data); - return models.Transaction.fromMap(res.data); } /// Update a transaction, to either commit or roll back its operations. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.updateTransaction` instead.') - Future updateTransaction( - {required String transactionId, bool? commit, bool? rollback}) async { - final String apiPath = '/databases/transactions/{transactionId}' - .replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - if (commit != null) 'commit': commit, - if (rollback != null) 'rollback': rollback, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, - path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Transaction.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.updateTransaction` instead.') + Future updateTransaction({required String transactionId, bool? commit, bool? rollback}) async { + final String apiPath = '/databases/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + if (commit != null) 'commit': commit, + + if (rollback != null) 'rollback': rollback, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Transaction.fromMap(res.data); + } /// Delete a transaction by its unique ID. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.deleteTransaction` instead.') + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.deleteTransaction` instead.') Future deleteTransaction({required String transactionId}) async { - final String apiPath = '/databases/transactions/{transactionId}' - .replaceAll('{transactionId}', transactionId); + final String apiPath = '/databases/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + }; - final Map apiParams = {}; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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; } /// Create multiple operations in a single transaction. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.createOperations` instead.') - Future createOperations( - {required String transactionId, List? operations}) async { - final String apiPath = '/databases/transactions/{transactionId}/operations' - .replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - if (operations != null) 'operations': operations, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.post, - path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Transaction.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.createOperations` instead.') + Future createOperations({required String transactionId, List? operations}) async { + final String apiPath = '/databases/transactions/{transactionId}/operations'.replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + if (operations != null) 'operations': operations, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Transaction.fromMap(res.data); + } /// 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, - String? transactionId, - bool? total, - int? ttl}) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - if (transactionId != null) 'transactionId': transactionId, - if (total != null) 'total': total, - if (ttl != null) 'ttl': ttl, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, String? transactionId, bool? total, int? ttl}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + + if (transactionId != null) 'transactionId': transactionId, + + if (total != null) 'total': total, + + if (ttl != null) 'ttl': ttl, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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, - String? transactionId}) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId); - - final Map apiParams = { - 'documentId': documentId, - 'data': data, - 'permissions': permissions, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, String? transactionId}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); + + final Map apiParams = { + 'documentId': documentId, + + 'data': data, + + 'permissions': permissions, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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, - String? transactionId}) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - if (transactionId != null) 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, String? transactionId}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + + if (transactionId != null) 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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, - Map? data, - List? permissions, - String? transactionId}) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); - - final Map apiParams = { - if (data != null) 'data': data, - 'permissions': permissions, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, Map? data, List? permissions, String? transactionId}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + + final Map apiParams = { + if (data != null) 'data': data, + + 'permissions': permissions, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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, - String? transactionId}) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); - - final Map apiParams = { - if (data != null) 'data': data, - 'permissions': permissions, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, String? transactionId}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + + final Map apiParams = { + if (data != null) 'data': data, + + 'permissions': permissions, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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, - String? transactionId}) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); - - final Map apiParams = { - if (transactionId != null) 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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, String? transactionId}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + + final Map apiParams = { + if (transactionId != null) 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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, - String? transactionId}) 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 = { - if (value != null) 'value': value, - 'min': min, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, String? transactionId}) 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 = { + if (value != null) 'value': value, + + 'min': min, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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, - String? transactionId}) 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 = { - if (value != null) 'value': value, - 'max': max, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, String? transactionId}) 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 = { + if (value != null) 'value': value, + + 'max': max, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); + } } diff --git a/lib/services/functions.dart b/lib/services/functions.dart index ed97921b..0640f80f 100644 --- a/lib/services/functions.dart +++ b/lib/services/functions.dart @@ -1,87 +1,82 @@ 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, bool? total}) async { - final String apiPath = '/functions/{functionId}/executions' - .replaceAll('{functionId}', functionId); + Future listExecutions({required String functionId, List? queries, bool? total}) async { + final String apiPath = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); - final Map apiParams = { - if (queries != null) 'queries': queries, - if (total != null) 'total': total, - }; + final Map apiParams = { + if (queries != null) 'queries': queries, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + if (total != null) 'total': total, - final res = await client.call(HttpMethod.get, - path: apiPath, params: apiParams, headers: apiHeaders); + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.ExecutionList.fromMap(res.data); - 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 = { - if (body != null) 'body': body, - if (xasync != null) 'async': xasync, - if (path != null) 'path': path, - if (method != null) 'method': method.value, - if (headers != null) 'headers': headers, - 'scheduledAt': scheduledAt, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 = { + if (body != null) 'body': body, + + if (xasync != null) 'async': xasync, + + if (path != null) 'path': path, + + if (method != null) 'method': method.value, + + if (headers != null) 'headers': headers, + + 'scheduledAt': scheduledAt, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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); + 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 apiParams = {}; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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.Execution.fromMap(res.data); - return models.Execution.fromMap(res.data); } } diff --git a/lib/services/graphql.dart b/lib/services/graphql.dart index c86f3719..978331fa 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,39 @@ class Graphql extends Service { Future query({required Map query}) async { final String apiPath = '/graphql'; - final Map apiParams = { - 'query': query, - }; + final Map apiParams = { + 'query': query, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'x-sdk-graphql': 'true', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + }; - final res = await client.call(HttpMethod.post, - path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'x-sdk-graphql': 'true', 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 { final String apiPath = '/graphql/mutation'; - final Map apiParams = { - 'query': query, - }; + final Map apiParams = { + 'query': query, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'x-sdk-graphql': 'true', 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'x-sdk-graphql': 'true', - 'content-type': 'application/json', - 'accept': '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; } } diff --git a/lib/services/locale.dart b/lib/services/locale.dart index 87ea162e..c45a1269 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 { final String apiPath = '/locale'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -33,17 +34,18 @@ class Locale extends Service { Future listCodes() async { final String apiPath = '/locale/codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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 @@ -51,17 +53,18 @@ class Locale extends Service { Future listContinents() async { final String apiPath = '/locale/continents'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -69,17 +72,18 @@ class Locale extends Service { Future listCountries() async { final String apiPath = '/locale/countries'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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 @@ -87,17 +91,18 @@ class Locale extends Service { Future listCountriesEU() async { final String apiPath = '/locale/countries/eu'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -105,17 +110,18 @@ class Locale extends Service { Future listCountriesPhones() async { final String apiPath = '/locale/countries/phones'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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 @@ -124,17 +130,18 @@ class Locale extends Service { Future listCurrencies() async { final String apiPath = '/locale/currencies'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -142,16 +149,17 @@ class Locale extends Service { Future listLanguages() async { final String apiPath = '/locale/languages'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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); } } diff --git a/lib/services/messaging.dart b/lib/services/messaging.dart index 61ecefee..3dffe41b 100644 --- a/lib/services/messaging.dart +++ b/lib/services/messaging.dart @@ -1,54 +1,48 @@ 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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); + 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 apiParams = {}; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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; } } diff --git a/lib/services/presences.dart b/lib/services/presences.dart index 1c9b651b..088700cb 100644 --- a/lib/services/presences.dart +++ b/lib/services/presences.dart @@ -5,127 +5,123 @@ class Presences extends Service { Presences(super.client); /// List presence logs. Expired entries are filtered out automatically. - /// - Future list( - {List? queries, bool? total, int? ttl}) async { + /// + Future list({List? queries, bool? total, int? ttl}) async { final String apiPath = '/presences'; - final Map apiParams = { - if (queries != null) 'queries': queries, - if (total != null) 'total': total, - if (ttl != null) 'ttl': ttl, - }; + final Map apiParams = { + if (queries != null) 'queries': queries, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + if (total != null) 'total': total, - final res = await client.call(HttpMethod.get, - path: apiPath, params: apiParams, headers: apiHeaders); + if (ttl != null) 'ttl': ttl, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.PresenceList.fromMap(res.data); - return models.PresenceList.fromMap(res.data); } /// Get a presence log by its unique ID. Entries whose `expiresAt` is in the /// past are treated as not found. - /// + /// Future get({required String presenceId}) async { - final String apiPath = - '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); + final String apiPath = '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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.Presence.fromMap(res.data); - return models.Presence.fromMap(res.data); } /// Create or update a presence log by its user ID. - /// - Future upsert( - {required String presenceId, - required String status, - List? permissions, - String? expiresAt, - Map? metadata}) async { - final String apiPath = - '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); - - final Map apiParams = { - 'status': status, - if (permissions != null) 'permissions': permissions, - if (expiresAt != null) 'expiresAt': expiresAt, - if (metadata != null) 'metadata': metadata, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.put, - path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Presence.fromMap(res.data); + /// + Future upsert({required String presenceId, required String status, List? permissions, String? expiresAt, Map? metadata}) async { + final String apiPath = '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); + + final Map apiParams = { + 'status': status, + + if (permissions != null) 'permissions': permissions, + + if (expiresAt != null) 'expiresAt': expiresAt, + + if (metadata != null) 'metadata': metadata, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Presence.fromMap(res.data); + } /// Update a presence log by its unique ID. Using the patch method you can pass /// only specific fields that will get updated. - /// - Future update( - {required String presenceId, - String? status, - String? expiresAt, - Map? metadata, - List? permissions, - bool? purge}) async { - final String apiPath = - '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); - - final Map apiParams = { - if (status != null) 'status': status, - if (expiresAt != null) 'expiresAt': expiresAt, - if (metadata != null) 'metadata': metadata, - if (permissions != null) 'permissions': permissions, - if (purge != null) 'purge': purge, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, - path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Presence.fromMap(res.data); + /// + Future update({required String presenceId, String? status, String? expiresAt, Map? metadata, List? permissions, bool? purge}) async { + final String apiPath = '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); + + final Map apiParams = { + if (status != null) 'status': status, + + if (expiresAt != null) 'expiresAt': expiresAt, + + if (metadata != null) 'metadata': metadata, + + if (permissions != null) 'permissions': permissions, + + if (purge != null) 'purge': purge, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Presence.fromMap(res.data); + } /// Delete a presence log by its unique ID. - /// + /// Future delete({required String presenceId}) async { - final String apiPath = - '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); + final String apiPath = '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); + + final Map apiParams = { + }; - final Map apiParams = {}; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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; } } diff --git a/lib/services/storage.dart b/lib/services/storage.dart index cdb626de..c9499a99 100644 --- a/lib/services/storage.dart +++ b/lib/services/storage.dart @@ -1,178 +1,166 @@ 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, - bool? total}) async { - final String apiPath = - '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - if (search != null) 'search': search, - if (total != null) 'total': total, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, bool? total}) async { + final String apiPath = '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + + if (search != null) 'search': search, + + if (total != null) 'total': total, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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, - if (permissions != null) 'permissions': permissions, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'multipart/form-data', - 'accept': 'application/json', - }; - - 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, + + if (permissions != null) 'permissions': permissions, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'multipart/form-data', 'accept': 'application/json', + }; + + 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); + 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 apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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.File.fromMap(res.data); - 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 = { - if (name != null) 'name': name, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 = { + if (name != null) 'name': name, + + 'permissions': permissions, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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 = { - if (token != null) 'token': token, - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + + if (token != null) 'token': token, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 @@ -180,64 +168,60 @@ 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 = { - if (width != null) 'width': width, - if (height != null) 'height': height, - if (gravity != null) 'gravity': gravity.value, - if (quality != null) 'quality': quality, - if (borderWidth != null) 'borderWidth': borderWidth, - if (borderColor != null) 'borderColor': borderColor, - if (borderRadius != null) 'borderRadius': borderRadius, - if (opacity != null) 'opacity': opacity, - if (rotation != null) 'rotation': rotation, - if (background != null) 'background': background, - if (output != null) 'output': output.value, - if (token != null) 'token': token, - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + + if (width != null) 'width': width, + + if (height != null) 'height': height, + + if (gravity != null) 'gravity': gravity.value, + + if (quality != null) 'quality': quality, + + if (borderWidth != null) 'borderWidth': borderWidth, + + if (borderColor != null) 'borderColor': borderColor, + + if (borderRadius != null) 'borderRadius': borderRadius, + + if (opacity != null) 'opacity': opacity, + + if (rotation != null) 'rotation': rotation, + + if (background != null) 'background': background, + + if (output != null) 'output': output.value, + + if (token != null) 'token': token, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 = { - if (token != null) 'token': token, - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + + if (token != null) 'token': token, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } } diff --git a/lib/services/tables_db.dart b/lib/services/tables_db.dart index 8b6284b3..42572021 100644 --- a/lib/services/tables_db.dart +++ b/lib/services/tables_db.dart @@ -5,382 +5,319 @@ class TablesDB extends Service { TablesDB(super.client); /// List transactions across all databases. - Future listTransactions( - {List? queries}) async { + Future listTransactions({List? queries}) async { final String apiPath = '/tablesdb/transactions'; - final Map apiParams = { - if (queries != null) 'queries': queries, - }; + final Map apiParams = { + if (queries != null) 'queries': queries, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + }; - final res = await client.call(HttpMethod.get, - path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.TransactionList.fromMap(res.data); - return models.TransactionList.fromMap(res.data); } /// Create a new transaction. Future createTransaction({int? ttl}) async { final String apiPath = '/tablesdb/transactions'; - final Map apiParams = { - if (ttl != null) 'ttl': ttl, - }; + final Map apiParams = { + if (ttl != null) 'ttl': ttl, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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.Transaction.fromMap(res.data); - return models.Transaction.fromMap(res.data); } /// Get a transaction by its unique ID. - Future getTransaction( - {required String transactionId}) async { - final String apiPath = '/tablesdb/transactions/{transactionId}' - .replaceAll('{transactionId}', transactionId); + Future getTransaction({required String transactionId}) async { + final String apiPath = '/tablesdb/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + }; - final Map apiParams = {}; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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.Transaction.fromMap(res.data); - return models.Transaction.fromMap(res.data); } /// Update a transaction, to either commit or roll back its operations. - Future updateTransaction( - {required String transactionId, bool? commit, bool? rollback}) async { - final String apiPath = '/tablesdb/transactions/{transactionId}' - .replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - if (commit != null) 'commit': commit, - if (rollback != null) 'rollback': rollback, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, - path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Transaction.fromMap(res.data); + Future updateTransaction({required String transactionId, bool? commit, bool? rollback}) async { + final String apiPath = '/tablesdb/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + if (commit != null) 'commit': commit, + + if (rollback != null) 'rollback': rollback, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Transaction.fromMap(res.data); + } /// Delete a transaction by its unique ID. Future deleteTransaction({required String transactionId}) async { - final String apiPath = '/tablesdb/transactions/{transactionId}' - .replaceAll('{transactionId}', transactionId); + final String apiPath = '/tablesdb/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + }; - final Map apiParams = {}; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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; } /// Create multiple operations in a single transaction. - Future createOperations( - {required String transactionId, List? operations}) async { - final String apiPath = '/tablesdb/transactions/{transactionId}/operations' - .replaceAll('{transactionId}', transactionId); + Future createOperations({required String transactionId, List? operations}) async { + final String apiPath = '/tablesdb/transactions/{transactionId}/operations'.replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + if (operations != null) 'operations': operations, + + }; - final Map apiParams = { - if (operations != null) 'operations': operations, - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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.Transaction.fromMap(res.data); - return models.Transaction.fromMap(res.data); } /// 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, - String? transactionId, - bool? total, - int? ttl}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - if (transactionId != null) 'transactionId': transactionId, - if (total != null) 'total': total, - if (ttl != null) 'ttl': ttl, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, String? transactionId, bool? total, int? ttl}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + + if (transactionId != null) 'transactionId': transactionId, + + if (total != null) 'total': total, + + if (ttl != null) 'ttl': ttl, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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/references/cloud/server-dart/tablesDB#createTable) /// API or directly from your database console. - Future createRow( - {required String databaseId, - required String tableId, - required String rowId, - required Map data, - List? permissions, - String? transactionId}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId); - - final Map apiParams = { - 'rowId': rowId, - 'data': data, - 'permissions': permissions, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, String? transactionId}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); + + final Map apiParams = { + 'rowId': rowId, + + 'data': data, + + 'permissions': permissions, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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, - String? transactionId}) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - if (transactionId != null) 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, String? transactionId}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + + if (transactionId != null) 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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/references/cloud/server-dart/tablesDB#createTable) /// API or directly from your database console. - Future upsertRow( - {required String databaseId, - required String tableId, - required String rowId, - Map? data, - List? permissions, - String? transactionId}) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); - - final Map apiParams = { - if (data != null) 'data': data, - 'permissions': permissions, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, String? transactionId}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); + + final Map apiParams = { + if (data != null) 'data': data, + + 'permissions': permissions, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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, - String? transactionId}) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); - - final Map apiParams = { - if (data != null) 'data': data, - 'permissions': permissions, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, String? transactionId}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); + + final Map apiParams = { + if (data != null) 'data': data, + + 'permissions': permissions, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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, - String? transactionId}) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); - - final Map apiParams = { - if (transactionId != null) 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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, String? transactionId}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); + + final Map apiParams = { + if (transactionId != null) 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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, - String? transactionId}) 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 = { - if (value != null) 'value': value, - 'min': min, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, String? transactionId}) 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 = { + if (value != null) 'value': value, + + 'min': min, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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, - String? transactionId}) 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 = { - if (value != null) 'value': value, - 'max': max, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, String? transactionId}) 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 = { + if (value != null) 'value': value, + + 'max': max, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); + } } diff --git a/lib/services/teams.dart b/lib/services/teams.dart index 1f4022f6..27bc561e 100644 --- a/lib/services/teams.dart +++ b/lib/services/teams.dart @@ -1,97 +1,98 @@ 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); /// Get a list of all the teams in which the current user is a member. You can /// use the parameters to filter your results. - Future list( - {List? queries, String? search, bool? total}) async { + Future list({List? queries, String? search, bool? total}) async { final String apiPath = '/teams'; - final Map apiParams = { - if (queries != null) 'queries': queries, - if (search != null) 'search': search, - if (total != null) 'total': total, - }; + final Map apiParams = { + if (queries != null) 'queries': queries, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + if (search != null) 'search': search, - final res = await client.call(HttpMethod.get, - path: apiPath, params: apiParams, headers: apiHeaders); + if (total != null) 'total': total, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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 { final String apiPath = '/teams'; - final Map apiParams = { - 'teamId': teamId, - 'name': name, - if (roles != null) 'roles': roles, - }; + final Map apiParams = { + 'teamId': teamId, + + 'name': name, + + if (roles != null) 'roles': roles, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 @@ -99,45 +100,44 @@ 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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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, - bool? total}) async { - final String apiPath = - '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - if (search != null) 'search': search, - if (total != null) 'total': total, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, bool? total}) async { + final String apiPath = '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + + if (search != null) 'search': search, + + if (total != null) 'total': total, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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 @@ -146,199 +146,180 @@ 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 = { - if (email != null) 'email': email, - if (userId != null) 'userId': userId, - if (phone != null) 'phone': phone, - 'roles': roles, - if (url != null) 'url': url, - if (name != null) 'name': name, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 = { + if (email != null) 'email': email, + + if (userId != null) 'userId': userId, + + if (phone != null) 'phone': phone, + + 'roles': roles, + + if (url != null) 'url': url, + + if (name != null) 'name': name, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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); + 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 apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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.Membership.fromMap(res.data); - 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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); + 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 apiParams = { - 'prefs': prefs, - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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.Preferences.fromMap(res.data); - return models.Preferences.fromMap(res.data); } } diff --git a/lib/src/client.dart b/lib/src/client.dart index cc077e56..65b2f044 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -27,8 +27,7 @@ abstract class Client { factory Client({ String endPoint = 'https://cloud.appwrite.io/v1', bool selfSigned = false, - }) => - createClient(endPoint: endPoint, selfSigned: selfSigned); + }) => createClient(endPoint: endPoint, selfSigned: selfSigned); /// Handle OAuth2 session creation. Future webAuth(Uri url, {String? callbackUrlScheme}); @@ -108,6 +107,7 @@ abstract class Client { /// Send a ping to project as part of onboarding. Future ping(); + /// Send the API request. Future call( HttpMethod method, { diff --git a/lib/src/client_base.dart b/lib/src/client_base.dart index da1a5225..9e964a79 100644 --- a/lib/src/client_base.dart +++ b/lib/src/client_base.dart @@ -6,33 +6,26 @@ 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); - /// The user cookie to authenticate with. Used by SDKs that forward an incoming Cookie header in server-side runtimes. @override ClientBase setCookie(value); - /// Impersonate a user by ID @override ClientBase setImpersonateUserId(value); - /// Impersonate a user by email @override ClientBase setImpersonateUserEmail(value); - /// Impersonate a user by phone @override ClientBase setImpersonateUserPhone(value); diff --git a/lib/src/client_browser.dart b/lib/src/client_browser.dart index 32945efd..2f4c7b48 100644 --- a/lib/src/client_browser.dart +++ b/lib/src/client_browser.dart @@ -62,7 +62,6 @@ class ClientBrowser extends ClientBase with ClientMixin { config['project'] = value; return this; } - /// Your secret JSON Web Token @override ClientBrowser setJWT(value) { @@ -70,14 +69,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) { @@ -85,7 +82,6 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Session', value); return this; } - /// Your secret dev API key @override ClientBrowser setDevKey(value) { @@ -93,7 +89,6 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Dev-Key', value); return this; } - /// The user cookie to authenticate with. Used by SDKs that forward an incoming Cookie header in server-side runtimes. @override ClientBrowser setCookie(value) { @@ -101,7 +96,6 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('Cookie', value); return this; } - /// Impersonate a user by ID @override ClientBrowser setImpersonateUserId(value) { @@ -109,7 +103,6 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Impersonate-User-Id', value); return this; } - /// Impersonate a user by email @override ClientBrowser setImpersonateUserEmail(value) { @@ -117,7 +110,6 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Impersonate-User-Email', value); return this; } - /// Impersonate a user by phone @override ClientBrowser setImpersonateUserPhone(value) { @@ -227,8 +219,7 @@ class ClientBrowser extends ClientBase with ClientMixin { final totalChunks = (size / chunkSize).ceil(); - Future uploadChunk( - int index, int start, int end, String? id) async { + Future uploadChunk(int index, int start, int end, String? id) async { List chunk = []; chunk = file.bytes!.getRange(start, end).toList(); @@ -266,9 +257,7 @@ class ClientBrowser extends ClientBase with ClientMixin { bool isUploadComplete(Response response) { final chunksUploaded = response.data['chunksUploaded']; final chunksTotal = response.data['chunksTotal'] ?? totalChunks; - return chunksUploaded is num && - chunksTotal is num && - chunksUploaded >= chunksTotal; + return chunksUploaded is num && chunksTotal is num && chunksUploaded >= chunksTotal; } final progress = UploadProgress( diff --git a/lib/src/client_io.dart b/lib/src/client_io.dart index 78a368ae..6e6e2ee8 100644 --- a/lib/src/client_io.dart +++ b/lib/src/client_io.dart @@ -88,7 +88,6 @@ class ClientIO extends ClientBase with ClientMixin { config['project'] = value; return this; } - /// Your secret JSON Web Token @override ClientIO setJWT(value) { @@ -96,14 +95,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) { @@ -111,7 +108,6 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Session', value); return this; } - /// Your secret dev API key @override ClientIO setDevKey(value) { @@ -119,7 +115,6 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Dev-Key', value); return this; } - /// The user cookie to authenticate with. Used by SDKs that forward an incoming Cookie header in server-side runtimes. @override ClientIO setCookie(value) { @@ -127,7 +122,6 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('Cookie', value); return this; } - /// Impersonate a user by ID @override ClientIO setImpersonateUserId(value) { @@ -135,7 +129,6 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Impersonate-User-Id', value); return this; } - /// Impersonate a user by email @override ClientIO setImpersonateUserEmail(value) { @@ -143,7 +136,6 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Impersonate-User-Email', value); return this; } - /// Impersonate a user by phone @override ClientIO setImpersonateUserPhone(value) { @@ -402,9 +394,7 @@ class ClientIO extends ClientBase with ClientMixin { bool isUploadComplete(Response response) { final chunksUploaded = response.data['chunksUploaded']; final chunksTotal = response.data['chunksTotal'] ?? totalChunks; - return chunksUploaded is num && - chunksTotal is num && - chunksUploaded >= chunksTotal; + return chunksUploaded is num && chunksTotal is num && chunksUploaded >= chunksTotal; } final progress = UploadProgress( @@ -428,8 +418,7 @@ class ClientIO extends ClientBase with ClientMixin { var nextChunk = 0; Future uploadNext() async { - final raf = - file.bytes == null ? await iofile!.open(mode: FileMode.read) : null; + final raf = file.bytes == null ? await iofile!.open(mode: FileMode.read) : null; try { while (nextChunk < chunks.length) { final chunk = chunks[nextChunk++]; diff --git a/lib/src/client_mixin.dart b/lib/src/client_mixin.dart index 89aad359..40484946 100644 --- a/lib/src/client_mixin.dart +++ b/lib/src/client_mixin.dart @@ -12,6 +12,7 @@ mixin ClientMixin { required Map headers, required Map params, }) { + http.BaseRequest request = http.Request(method.name(), uri); if (headers['content-type'] == 'multipart/form-data') { request = http.MultipartRequest(method.name(), uri); @@ -127,13 +128,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/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/browser_permission.dart b/lib/src/enums/browser_permission.dart index fb4983db..765b3e0c 100644 --- a/lib/src/enums/browser_permission.dart +++ b/lib/src/enums/browser_permission.dart @@ -1,30 +1,32 @@ part of '../../enums.dart'; enum BrowserPermission { - geolocation(value: 'geolocation'), - camera(value: 'camera'), - microphone(value: 'microphone'), - notifications(value: 'notifications'), - midi(value: 'midi'), - push(value: 'push'), - clipboardRead(value: 'clipboard-read'), - clipboardWrite(value: 'clipboard-write'), - paymentHandler(value: 'payment-handler'), - usb(value: 'usb'), - bluetooth(value: 'bluetooth'), - accelerometer(value: 'accelerometer'), - gyroscope(value: 'gyroscope'), - magnetometer(value: 'magnetometer'), - ambientLightSensor(value: 'ambient-light-sensor'), - backgroundSync(value: 'background-sync'), - persistentStorage(value: 'persistent-storage'), - screenWakeLock(value: 'screen-wake-lock'), - webShare(value: 'web-share'), - xrSpatialTracking(value: 'xr-spatial-tracking'); + geolocation(value: 'geolocation'), + camera(value: 'camera'), + microphone(value: 'microphone'), + notifications(value: 'notifications'), + midi(value: 'midi'), + push(value: 'push'), + clipboardRead(value: 'clipboard-read'), + clipboardWrite(value: 'clipboard-write'), + paymentHandler(value: 'payment-handler'), + usb(value: 'usb'), + bluetooth(value: 'bluetooth'), + accelerometer(value: 'accelerometer'), + gyroscope(value: 'gyroscope'), + magnetometer(value: 'magnetometer'), + ambientLightSensor(value: 'ambient-light-sensor'), + backgroundSync(value: 'background-sync'), + persistentStorage(value: 'persistent-storage'), + screenWakeLock(value: 'screen-wake-lock'), + webShare(value: 'web-share'), + xrSpatialTracking(value: 'xr-spatial-tracking'); - const BrowserPermission({required this.value}); + const BrowserPermission({ + 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_theme.dart b/lib/src/enums/browser_theme.dart index 1e059c2c..e81a0f68 100644 --- a/lib/src/enums/browser_theme.dart +++ b/lib/src/enums/browser_theme.dart @@ -1,12 +1,14 @@ part of '../../enums.dart'; enum BrowserTheme { - light(value: 'light'), - dark(value: 'dark'); + light(value: 'light'), + dark(value: 'dark'); - const BrowserTheme({required this.value}); + const BrowserTheme({ + 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/execution_status.dart b/lib/src/enums/execution_status.dart index 7ea9865e..f54859c9 100644 --- a/lib/src/enums/execution_status.dart +++ b/lib/src/enums/execution_status.dart @@ -1,15 +1,17 @@ part of '../../enums.dart'; enum ExecutionStatus { - waiting(value: 'waiting'), - processing(value: 'processing'), - completed(value: 'completed'), - failed(value: 'failed'), - scheduled(value: 'scheduled'); + waiting(value: 'waiting'), + processing(value: 'processing'), + completed(value: 'completed'), + failed(value: 'failed'), + scheduled(value: 'scheduled'); - const ExecutionStatus({required this.value}); + const ExecutionStatus({ + 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_trigger.dart b/lib/src/enums/execution_trigger.dart index fb05eb7d..8a14ae60 100644 --- a/lib/src/enums/execution_trigger.dart +++ b/lib/src/enums/execution_trigger.dart @@ -1,13 +1,15 @@ part of '../../enums.dart'; enum ExecutionTrigger { - http(value: 'http'), - schedule(value: 'schedule'), - event(value: 'event'); + http(value: 'http'), + schedule(value: 'schedule'), + event(value: 'event'); - const ExecutionTrigger({required this.value}); + const ExecutionTrigger({ + 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 b88e0a55..8ed7ecff 100644 --- a/lib/src/enums/o_auth_provider.dart +++ b/lib/src/enums/o_auth_provider.dart @@ -1,53 +1,55 @@ 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'), - fusionauth(value: 'fusionauth'), - github(value: 'github'), - gitlab(value: 'gitlab'), - google(value: 'google'), - keycloak(value: 'keycloak'), - kick(value: 'kick'), - 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'), - x(value: 'x'), - yahoo(value: 'yahoo'), - yammer(value: 'yammer'), - yandex(value: 'yandex'), - zoho(value: 'zoho'), - zoom(value: 'zoom'); + 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'), + fusionauth(value: 'fusionauth'), + github(value: 'github'), + gitlab(value: 'gitlab'), + google(value: 'google'), + keycloak(value: 'keycloak'), + kick(value: 'kick'), + 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'), + x(value: 'x'), + yahoo(value: 'yahoo'), + yammer(value: 'yammer'), + yandex(value: 'yandex'), + zoho(value: 'zoho'), + zoom(value: 'zoom'); - 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/enums/timezone.dart b/lib/src/enums/timezone.dart index d5d8d94a..4a8de1ce 100644 --- a/lib/src/enums/timezone.dart +++ b/lib/src/enums/timezone.dart @@ -1,429 +1,431 @@ part of '../../enums.dart'; enum Timezone { - africaAbidjan(value: 'africa/abidjan'), - africaAccra(value: 'africa/accra'), - africaAddisAbaba(value: 'africa/addis_ababa'), - africaAlgiers(value: 'africa/algiers'), - africaAsmara(value: 'africa/asmara'), - africaBamako(value: 'africa/bamako'), - africaBangui(value: 'africa/bangui'), - africaBanjul(value: 'africa/banjul'), - africaBissau(value: 'africa/bissau'), - africaBlantyre(value: 'africa/blantyre'), - africaBrazzaville(value: 'africa/brazzaville'), - africaBujumbura(value: 'africa/bujumbura'), - africaCairo(value: 'africa/cairo'), - africaCasablanca(value: 'africa/casablanca'), - africaCeuta(value: 'africa/ceuta'), - africaConakry(value: 'africa/conakry'), - africaDakar(value: 'africa/dakar'), - africaDarEsSalaam(value: 'africa/dar_es_salaam'), - africaDjibouti(value: 'africa/djibouti'), - africaDouala(value: 'africa/douala'), - africaElAaiun(value: 'africa/el_aaiun'), - africaFreetown(value: 'africa/freetown'), - africaGaborone(value: 'africa/gaborone'), - africaHarare(value: 'africa/harare'), - africaJohannesburg(value: 'africa/johannesburg'), - africaJuba(value: 'africa/juba'), - africaKampala(value: 'africa/kampala'), - africaKhartoum(value: 'africa/khartoum'), - africaKigali(value: 'africa/kigali'), - africaKinshasa(value: 'africa/kinshasa'), - africaLagos(value: 'africa/lagos'), - africaLibreville(value: 'africa/libreville'), - africaLome(value: 'africa/lome'), - africaLuanda(value: 'africa/luanda'), - africaLubumbashi(value: 'africa/lubumbashi'), - africaLusaka(value: 'africa/lusaka'), - africaMalabo(value: 'africa/malabo'), - africaMaputo(value: 'africa/maputo'), - africaMaseru(value: 'africa/maseru'), - africaMbabane(value: 'africa/mbabane'), - africaMogadishu(value: 'africa/mogadishu'), - africaMonrovia(value: 'africa/monrovia'), - africaNairobi(value: 'africa/nairobi'), - africaNdjamena(value: 'africa/ndjamena'), - africaNiamey(value: 'africa/niamey'), - africaNouakchott(value: 'africa/nouakchott'), - africaOuagadougou(value: 'africa/ouagadougou'), - africaPortoNovo(value: 'africa/porto-novo'), - africaSaoTome(value: 'africa/sao_tome'), - africaTripoli(value: 'africa/tripoli'), - africaTunis(value: 'africa/tunis'), - africaWindhoek(value: 'africa/windhoek'), - americaAdak(value: 'america/adak'), - americaAnchorage(value: 'america/anchorage'), - americaAnguilla(value: 'america/anguilla'), - americaAntigua(value: 'america/antigua'), - americaAraguaina(value: 'america/araguaina'), - americaArgentinaBuenosAires(value: 'america/argentina/buenos_aires'), - americaArgentinaCatamarca(value: 'america/argentina/catamarca'), - americaArgentinaCordoba(value: 'america/argentina/cordoba'), - americaArgentinaJujuy(value: 'america/argentina/jujuy'), - americaArgentinaLaRioja(value: 'america/argentina/la_rioja'), - americaArgentinaMendoza(value: 'america/argentina/mendoza'), - americaArgentinaRioGallegos(value: 'america/argentina/rio_gallegos'), - americaArgentinaSalta(value: 'america/argentina/salta'), - americaArgentinaSanJuan(value: 'america/argentina/san_juan'), - americaArgentinaSanLuis(value: 'america/argentina/san_luis'), - americaArgentinaTucuman(value: 'america/argentina/tucuman'), - americaArgentinaUshuaia(value: 'america/argentina/ushuaia'), - americaAruba(value: 'america/aruba'), - americaAsuncion(value: 'america/asuncion'), - americaAtikokan(value: 'america/atikokan'), - americaBahia(value: 'america/bahia'), - americaBahiaBanderas(value: 'america/bahia_banderas'), - americaBarbados(value: 'america/barbados'), - americaBelem(value: 'america/belem'), - americaBelize(value: 'america/belize'), - americaBlancSablon(value: 'america/blanc-sablon'), - americaBoaVista(value: 'america/boa_vista'), - americaBogota(value: 'america/bogota'), - americaBoise(value: 'america/boise'), - americaCambridgeBay(value: 'america/cambridge_bay'), - americaCampoGrande(value: 'america/campo_grande'), - americaCancun(value: 'america/cancun'), - americaCaracas(value: 'america/caracas'), - americaCayenne(value: 'america/cayenne'), - americaCayman(value: 'america/cayman'), - americaChicago(value: 'america/chicago'), - americaChihuahua(value: 'america/chihuahua'), - americaCiudadJuarez(value: 'america/ciudad_juarez'), - americaCostaRica(value: 'america/costa_rica'), - americaCoyhaique(value: 'america/coyhaique'), - americaCreston(value: 'america/creston'), - americaCuiaba(value: 'america/cuiaba'), - americaCuracao(value: 'america/curacao'), - americaDanmarkshavn(value: 'america/danmarkshavn'), - americaDawson(value: 'america/dawson'), - americaDawsonCreek(value: 'america/dawson_creek'), - americaDenver(value: 'america/denver'), - americaDetroit(value: 'america/detroit'), - americaDominica(value: 'america/dominica'), - americaEdmonton(value: 'america/edmonton'), - americaEirunepe(value: 'america/eirunepe'), - americaElSalvador(value: 'america/el_salvador'), - americaFortNelson(value: 'america/fort_nelson'), - americaFortaleza(value: 'america/fortaleza'), - americaGlaceBay(value: 'america/glace_bay'), - americaGooseBay(value: 'america/goose_bay'), - americaGrandTurk(value: 'america/grand_turk'), - americaGrenada(value: 'america/grenada'), - americaGuadeloupe(value: 'america/guadeloupe'), - americaGuatemala(value: 'america/guatemala'), - americaGuayaquil(value: 'america/guayaquil'), - americaGuyana(value: 'america/guyana'), - americaHalifax(value: 'america/halifax'), - americaHavana(value: 'america/havana'), - americaHermosillo(value: 'america/hermosillo'), - americaIndianaIndianapolis(value: 'america/indiana/indianapolis'), - americaIndianaKnox(value: 'america/indiana/knox'), - americaIndianaMarengo(value: 'america/indiana/marengo'), - americaIndianaPetersburg(value: 'america/indiana/petersburg'), - americaIndianaTellCity(value: 'america/indiana/tell_city'), - americaIndianaVevay(value: 'america/indiana/vevay'), - americaIndianaVincennes(value: 'america/indiana/vincennes'), - americaIndianaWinamac(value: 'america/indiana/winamac'), - americaInuvik(value: 'america/inuvik'), - americaIqaluit(value: 'america/iqaluit'), - americaJamaica(value: 'america/jamaica'), - americaJuneau(value: 'america/juneau'), - americaKentuckyLouisville(value: 'america/kentucky/louisville'), - americaKentuckyMonticello(value: 'america/kentucky/monticello'), - americaKralendijk(value: 'america/kralendijk'), - americaLaPaz(value: 'america/la_paz'), - americaLima(value: 'america/lima'), - americaLosAngeles(value: 'america/los_angeles'), - americaLowerPrinces(value: 'america/lower_princes'), - americaMaceio(value: 'america/maceio'), - americaManagua(value: 'america/managua'), - americaManaus(value: 'america/manaus'), - americaMarigot(value: 'america/marigot'), - americaMartinique(value: 'america/martinique'), - americaMatamoros(value: 'america/matamoros'), - americaMazatlan(value: 'america/mazatlan'), - americaMenominee(value: 'america/menominee'), - americaMerida(value: 'america/merida'), - americaMetlakatla(value: 'america/metlakatla'), - americaMexicoCity(value: 'america/mexico_city'), - americaMiquelon(value: 'america/miquelon'), - americaMoncton(value: 'america/moncton'), - americaMonterrey(value: 'america/monterrey'), - americaMontevideo(value: 'america/montevideo'), - americaMontserrat(value: 'america/montserrat'), - americaNassau(value: 'america/nassau'), - americaNewYork(value: 'america/new_york'), - americaNome(value: 'america/nome'), - americaNoronha(value: 'america/noronha'), - americaNorthDakotaBeulah(value: 'america/north_dakota/beulah'), - americaNorthDakotaCenter(value: 'america/north_dakota/center'), - americaNorthDakotaNewSalem(value: 'america/north_dakota/new_salem'), - americaNuuk(value: 'america/nuuk'), - americaOjinaga(value: 'america/ojinaga'), - americaPanama(value: 'america/panama'), - americaParamaribo(value: 'america/paramaribo'), - americaPhoenix(value: 'america/phoenix'), - americaPortAuPrince(value: 'america/port-au-prince'), - americaPortOfSpain(value: 'america/port_of_spain'), - americaPortoVelho(value: 'america/porto_velho'), - americaPuertoRico(value: 'america/puerto_rico'), - americaPuntaArenas(value: 'america/punta_arenas'), - americaRankinInlet(value: 'america/rankin_inlet'), - americaRecife(value: 'america/recife'), - americaRegina(value: 'america/regina'), - americaResolute(value: 'america/resolute'), - americaRioBranco(value: 'america/rio_branco'), - americaSantarem(value: 'america/santarem'), - americaSantiago(value: 'america/santiago'), - americaSantoDomingo(value: 'america/santo_domingo'), - americaSaoPaulo(value: 'america/sao_paulo'), - americaScoresbysund(value: 'america/scoresbysund'), - americaSitka(value: 'america/sitka'), - americaStBarthelemy(value: 'america/st_barthelemy'), - americaStJohns(value: 'america/st_johns'), - americaStKitts(value: 'america/st_kitts'), - americaStLucia(value: 'america/st_lucia'), - americaStThomas(value: 'america/st_thomas'), - americaStVincent(value: 'america/st_vincent'), - americaSwiftCurrent(value: 'america/swift_current'), - americaTegucigalpa(value: 'america/tegucigalpa'), - americaThule(value: 'america/thule'), - americaTijuana(value: 'america/tijuana'), - americaToronto(value: 'america/toronto'), - americaTortola(value: 'america/tortola'), - americaVancouver(value: 'america/vancouver'), - americaWhitehorse(value: 'america/whitehorse'), - americaWinnipeg(value: 'america/winnipeg'), - americaYakutat(value: 'america/yakutat'), - antarcticaCasey(value: 'antarctica/casey'), - antarcticaDavis(value: 'antarctica/davis'), - antarcticaDumontdurville(value: 'antarctica/dumontdurville'), - antarcticaMacquarie(value: 'antarctica/macquarie'), - antarcticaMawson(value: 'antarctica/mawson'), - antarcticaMcmurdo(value: 'antarctica/mcmurdo'), - antarcticaPalmer(value: 'antarctica/palmer'), - antarcticaRothera(value: 'antarctica/rothera'), - antarcticaSyowa(value: 'antarctica/syowa'), - antarcticaTroll(value: 'antarctica/troll'), - antarcticaVostok(value: 'antarctica/vostok'), - arcticLongyearbyen(value: 'arctic/longyearbyen'), - asiaAden(value: 'asia/aden'), - asiaAlmaty(value: 'asia/almaty'), - asiaAmman(value: 'asia/amman'), - asiaAnadyr(value: 'asia/anadyr'), - asiaAqtau(value: 'asia/aqtau'), - asiaAqtobe(value: 'asia/aqtobe'), - asiaAshgabat(value: 'asia/ashgabat'), - asiaAtyrau(value: 'asia/atyrau'), - asiaBaghdad(value: 'asia/baghdad'), - asiaBahrain(value: 'asia/bahrain'), - asiaBaku(value: 'asia/baku'), - asiaBangkok(value: 'asia/bangkok'), - asiaBarnaul(value: 'asia/barnaul'), - asiaBeirut(value: 'asia/beirut'), - asiaBishkek(value: 'asia/bishkek'), - asiaBrunei(value: 'asia/brunei'), - asiaChita(value: 'asia/chita'), - asiaColombo(value: 'asia/colombo'), - asiaDamascus(value: 'asia/damascus'), - asiaDhaka(value: 'asia/dhaka'), - asiaDili(value: 'asia/dili'), - asiaDubai(value: 'asia/dubai'), - asiaDushanbe(value: 'asia/dushanbe'), - asiaFamagusta(value: 'asia/famagusta'), - asiaGaza(value: 'asia/gaza'), - asiaHebron(value: 'asia/hebron'), - asiaHoChiMinh(value: 'asia/ho_chi_minh'), - asiaHongKong(value: 'asia/hong_kong'), - asiaHovd(value: 'asia/hovd'), - asiaIrkutsk(value: 'asia/irkutsk'), - asiaJakarta(value: 'asia/jakarta'), - asiaJayapura(value: 'asia/jayapura'), - asiaJerusalem(value: 'asia/jerusalem'), - asiaKabul(value: 'asia/kabul'), - asiaKamchatka(value: 'asia/kamchatka'), - asiaKarachi(value: 'asia/karachi'), - asiaKathmandu(value: 'asia/kathmandu'), - asiaKhandyga(value: 'asia/khandyga'), - asiaKolkata(value: 'asia/kolkata'), - asiaKrasnoyarsk(value: 'asia/krasnoyarsk'), - asiaKualaLumpur(value: 'asia/kuala_lumpur'), - asiaKuching(value: 'asia/kuching'), - asiaKuwait(value: 'asia/kuwait'), - asiaMacau(value: 'asia/macau'), - asiaMagadan(value: 'asia/magadan'), - asiaMakassar(value: 'asia/makassar'), - asiaManila(value: 'asia/manila'), - asiaMuscat(value: 'asia/muscat'), - asiaNicosia(value: 'asia/nicosia'), - asiaNovokuznetsk(value: 'asia/novokuznetsk'), - asiaNovosibirsk(value: 'asia/novosibirsk'), - asiaOmsk(value: 'asia/omsk'), - asiaOral(value: 'asia/oral'), - asiaPhnomPenh(value: 'asia/phnom_penh'), - asiaPontianak(value: 'asia/pontianak'), - asiaPyongyang(value: 'asia/pyongyang'), - asiaQatar(value: 'asia/qatar'), - asiaQostanay(value: 'asia/qostanay'), - asiaQyzylorda(value: 'asia/qyzylorda'), - asiaRiyadh(value: 'asia/riyadh'), - asiaSakhalin(value: 'asia/sakhalin'), - asiaSamarkand(value: 'asia/samarkand'), - asiaSeoul(value: 'asia/seoul'), - asiaShanghai(value: 'asia/shanghai'), - asiaSingapore(value: 'asia/singapore'), - asiaSrednekolymsk(value: 'asia/srednekolymsk'), - asiaTaipei(value: 'asia/taipei'), - asiaTashkent(value: 'asia/tashkent'), - asiaTbilisi(value: 'asia/tbilisi'), - asiaTehran(value: 'asia/tehran'), - asiaThimphu(value: 'asia/thimphu'), - asiaTokyo(value: 'asia/tokyo'), - asiaTomsk(value: 'asia/tomsk'), - asiaUlaanbaatar(value: 'asia/ulaanbaatar'), - asiaUrumqi(value: 'asia/urumqi'), - asiaUstNera(value: 'asia/ust-nera'), - asiaVientiane(value: 'asia/vientiane'), - asiaVladivostok(value: 'asia/vladivostok'), - asiaYakutsk(value: 'asia/yakutsk'), - asiaYangon(value: 'asia/yangon'), - asiaYekaterinburg(value: 'asia/yekaterinburg'), - asiaYerevan(value: 'asia/yerevan'), - atlanticAzores(value: 'atlantic/azores'), - atlanticBermuda(value: 'atlantic/bermuda'), - atlanticCanary(value: 'atlantic/canary'), - atlanticCapeVerde(value: 'atlantic/cape_verde'), - atlanticFaroe(value: 'atlantic/faroe'), - atlanticMadeira(value: 'atlantic/madeira'), - atlanticReykjavik(value: 'atlantic/reykjavik'), - atlanticSouthGeorgia(value: 'atlantic/south_georgia'), - atlanticStHelena(value: 'atlantic/st_helena'), - atlanticStanley(value: 'atlantic/stanley'), - australiaAdelaide(value: 'australia/adelaide'), - australiaBrisbane(value: 'australia/brisbane'), - australiaBrokenHill(value: 'australia/broken_hill'), - australiaDarwin(value: 'australia/darwin'), - australiaEucla(value: 'australia/eucla'), - australiaHobart(value: 'australia/hobart'), - australiaLindeman(value: 'australia/lindeman'), - australiaLordHowe(value: 'australia/lord_howe'), - australiaMelbourne(value: 'australia/melbourne'), - australiaPerth(value: 'australia/perth'), - australiaSydney(value: 'australia/sydney'), - europeAmsterdam(value: 'europe/amsterdam'), - europeAndorra(value: 'europe/andorra'), - europeAstrakhan(value: 'europe/astrakhan'), - europeAthens(value: 'europe/athens'), - europeBelgrade(value: 'europe/belgrade'), - europeBerlin(value: 'europe/berlin'), - europeBratislava(value: 'europe/bratislava'), - europeBrussels(value: 'europe/brussels'), - europeBucharest(value: 'europe/bucharest'), - europeBudapest(value: 'europe/budapest'), - europeBusingen(value: 'europe/busingen'), - europeChisinau(value: 'europe/chisinau'), - europeCopenhagen(value: 'europe/copenhagen'), - europeDublin(value: 'europe/dublin'), - europeGibraltar(value: 'europe/gibraltar'), - europeGuernsey(value: 'europe/guernsey'), - europeHelsinki(value: 'europe/helsinki'), - europeIsleOfMan(value: 'europe/isle_of_man'), - europeIstanbul(value: 'europe/istanbul'), - europeJersey(value: 'europe/jersey'), - europeKaliningrad(value: 'europe/kaliningrad'), - europeKirov(value: 'europe/kirov'), - europeKyiv(value: 'europe/kyiv'), - europeLisbon(value: 'europe/lisbon'), - europeLjubljana(value: 'europe/ljubljana'), - europeLondon(value: 'europe/london'), - europeLuxembourg(value: 'europe/luxembourg'), - europeMadrid(value: 'europe/madrid'), - europeMalta(value: 'europe/malta'), - europeMariehamn(value: 'europe/mariehamn'), - europeMinsk(value: 'europe/minsk'), - europeMonaco(value: 'europe/monaco'), - europeMoscow(value: 'europe/moscow'), - europeOslo(value: 'europe/oslo'), - europeParis(value: 'europe/paris'), - europePodgorica(value: 'europe/podgorica'), - europePrague(value: 'europe/prague'), - europeRiga(value: 'europe/riga'), - europeRome(value: 'europe/rome'), - europeSamara(value: 'europe/samara'), - europeSanMarino(value: 'europe/san_marino'), - europeSarajevo(value: 'europe/sarajevo'), - europeSaratov(value: 'europe/saratov'), - europeSimferopol(value: 'europe/simferopol'), - europeSkopje(value: 'europe/skopje'), - europeSofia(value: 'europe/sofia'), - europeStockholm(value: 'europe/stockholm'), - europeTallinn(value: 'europe/tallinn'), - europeTirane(value: 'europe/tirane'), - europeUlyanovsk(value: 'europe/ulyanovsk'), - europeVaduz(value: 'europe/vaduz'), - europeVatican(value: 'europe/vatican'), - europeVienna(value: 'europe/vienna'), - europeVilnius(value: 'europe/vilnius'), - europeVolgograd(value: 'europe/volgograd'), - europeWarsaw(value: 'europe/warsaw'), - europeZagreb(value: 'europe/zagreb'), - europeZurich(value: 'europe/zurich'), - indianAntananarivo(value: 'indian/antananarivo'), - indianChagos(value: 'indian/chagos'), - indianChristmas(value: 'indian/christmas'), - indianCocos(value: 'indian/cocos'), - indianComoro(value: 'indian/comoro'), - indianKerguelen(value: 'indian/kerguelen'), - indianMahe(value: 'indian/mahe'), - indianMaldives(value: 'indian/maldives'), - indianMauritius(value: 'indian/mauritius'), - indianMayotte(value: 'indian/mayotte'), - indianReunion(value: 'indian/reunion'), - pacificApia(value: 'pacific/apia'), - pacificAuckland(value: 'pacific/auckland'), - pacificBougainville(value: 'pacific/bougainville'), - pacificChatham(value: 'pacific/chatham'), - pacificChuuk(value: 'pacific/chuuk'), - pacificEaster(value: 'pacific/easter'), - pacificEfate(value: 'pacific/efate'), - pacificFakaofo(value: 'pacific/fakaofo'), - pacificFiji(value: 'pacific/fiji'), - pacificFunafuti(value: 'pacific/funafuti'), - pacificGalapagos(value: 'pacific/galapagos'), - pacificGambier(value: 'pacific/gambier'), - pacificGuadalcanal(value: 'pacific/guadalcanal'), - pacificGuam(value: 'pacific/guam'), - pacificHonolulu(value: 'pacific/honolulu'), - pacificKanton(value: 'pacific/kanton'), - pacificKiritimati(value: 'pacific/kiritimati'), - pacificKosrae(value: 'pacific/kosrae'), - pacificKwajalein(value: 'pacific/kwajalein'), - pacificMajuro(value: 'pacific/majuro'), - pacificMarquesas(value: 'pacific/marquesas'), - pacificMidway(value: 'pacific/midway'), - pacificNauru(value: 'pacific/nauru'), - pacificNiue(value: 'pacific/niue'), - pacificNorfolk(value: 'pacific/norfolk'), - pacificNoumea(value: 'pacific/noumea'), - pacificPagoPago(value: 'pacific/pago_pago'), - pacificPalau(value: 'pacific/palau'), - pacificPitcairn(value: 'pacific/pitcairn'), - pacificPohnpei(value: 'pacific/pohnpei'), - pacificPortMoresby(value: 'pacific/port_moresby'), - pacificRarotonga(value: 'pacific/rarotonga'), - pacificSaipan(value: 'pacific/saipan'), - pacificTahiti(value: 'pacific/tahiti'), - pacificTarawa(value: 'pacific/tarawa'), - pacificTongatapu(value: 'pacific/tongatapu'), - pacificWake(value: 'pacific/wake'), - pacificWallis(value: 'pacific/wallis'), - utc(value: 'utc'); + africaAbidjan(value: 'africa/abidjan'), + africaAccra(value: 'africa/accra'), + africaAddisAbaba(value: 'africa/addis_ababa'), + africaAlgiers(value: 'africa/algiers'), + africaAsmara(value: 'africa/asmara'), + africaBamako(value: 'africa/bamako'), + africaBangui(value: 'africa/bangui'), + africaBanjul(value: 'africa/banjul'), + africaBissau(value: 'africa/bissau'), + africaBlantyre(value: 'africa/blantyre'), + africaBrazzaville(value: 'africa/brazzaville'), + africaBujumbura(value: 'africa/bujumbura'), + africaCairo(value: 'africa/cairo'), + africaCasablanca(value: 'africa/casablanca'), + africaCeuta(value: 'africa/ceuta'), + africaConakry(value: 'africa/conakry'), + africaDakar(value: 'africa/dakar'), + africaDarEsSalaam(value: 'africa/dar_es_salaam'), + africaDjibouti(value: 'africa/djibouti'), + africaDouala(value: 'africa/douala'), + africaElAaiun(value: 'africa/el_aaiun'), + africaFreetown(value: 'africa/freetown'), + africaGaborone(value: 'africa/gaborone'), + africaHarare(value: 'africa/harare'), + africaJohannesburg(value: 'africa/johannesburg'), + africaJuba(value: 'africa/juba'), + africaKampala(value: 'africa/kampala'), + africaKhartoum(value: 'africa/khartoum'), + africaKigali(value: 'africa/kigali'), + africaKinshasa(value: 'africa/kinshasa'), + africaLagos(value: 'africa/lagos'), + africaLibreville(value: 'africa/libreville'), + africaLome(value: 'africa/lome'), + africaLuanda(value: 'africa/luanda'), + africaLubumbashi(value: 'africa/lubumbashi'), + africaLusaka(value: 'africa/lusaka'), + africaMalabo(value: 'africa/malabo'), + africaMaputo(value: 'africa/maputo'), + africaMaseru(value: 'africa/maseru'), + africaMbabane(value: 'africa/mbabane'), + africaMogadishu(value: 'africa/mogadishu'), + africaMonrovia(value: 'africa/monrovia'), + africaNairobi(value: 'africa/nairobi'), + africaNdjamena(value: 'africa/ndjamena'), + africaNiamey(value: 'africa/niamey'), + africaNouakchott(value: 'africa/nouakchott'), + africaOuagadougou(value: 'africa/ouagadougou'), + africaPortoNovo(value: 'africa/porto-novo'), + africaSaoTome(value: 'africa/sao_tome'), + africaTripoli(value: 'africa/tripoli'), + africaTunis(value: 'africa/tunis'), + africaWindhoek(value: 'africa/windhoek'), + americaAdak(value: 'america/adak'), + americaAnchorage(value: 'america/anchorage'), + americaAnguilla(value: 'america/anguilla'), + americaAntigua(value: 'america/antigua'), + americaAraguaina(value: 'america/araguaina'), + americaArgentinaBuenosAires(value: 'america/argentina/buenos_aires'), + americaArgentinaCatamarca(value: 'america/argentina/catamarca'), + americaArgentinaCordoba(value: 'america/argentina/cordoba'), + americaArgentinaJujuy(value: 'america/argentina/jujuy'), + americaArgentinaLaRioja(value: 'america/argentina/la_rioja'), + americaArgentinaMendoza(value: 'america/argentina/mendoza'), + americaArgentinaRioGallegos(value: 'america/argentina/rio_gallegos'), + americaArgentinaSalta(value: 'america/argentina/salta'), + americaArgentinaSanJuan(value: 'america/argentina/san_juan'), + americaArgentinaSanLuis(value: 'america/argentina/san_luis'), + americaArgentinaTucuman(value: 'america/argentina/tucuman'), + americaArgentinaUshuaia(value: 'america/argentina/ushuaia'), + americaAruba(value: 'america/aruba'), + americaAsuncion(value: 'america/asuncion'), + americaAtikokan(value: 'america/atikokan'), + americaBahia(value: 'america/bahia'), + americaBahiaBanderas(value: 'america/bahia_banderas'), + americaBarbados(value: 'america/barbados'), + americaBelem(value: 'america/belem'), + americaBelize(value: 'america/belize'), + americaBlancSablon(value: 'america/blanc-sablon'), + americaBoaVista(value: 'america/boa_vista'), + americaBogota(value: 'america/bogota'), + americaBoise(value: 'america/boise'), + americaCambridgeBay(value: 'america/cambridge_bay'), + americaCampoGrande(value: 'america/campo_grande'), + americaCancun(value: 'america/cancun'), + americaCaracas(value: 'america/caracas'), + americaCayenne(value: 'america/cayenne'), + americaCayman(value: 'america/cayman'), + americaChicago(value: 'america/chicago'), + americaChihuahua(value: 'america/chihuahua'), + americaCiudadJuarez(value: 'america/ciudad_juarez'), + americaCostaRica(value: 'america/costa_rica'), + americaCoyhaique(value: 'america/coyhaique'), + americaCreston(value: 'america/creston'), + americaCuiaba(value: 'america/cuiaba'), + americaCuracao(value: 'america/curacao'), + americaDanmarkshavn(value: 'america/danmarkshavn'), + americaDawson(value: 'america/dawson'), + americaDawsonCreek(value: 'america/dawson_creek'), + americaDenver(value: 'america/denver'), + americaDetroit(value: 'america/detroit'), + americaDominica(value: 'america/dominica'), + americaEdmonton(value: 'america/edmonton'), + americaEirunepe(value: 'america/eirunepe'), + americaElSalvador(value: 'america/el_salvador'), + americaFortNelson(value: 'america/fort_nelson'), + americaFortaleza(value: 'america/fortaleza'), + americaGlaceBay(value: 'america/glace_bay'), + americaGooseBay(value: 'america/goose_bay'), + americaGrandTurk(value: 'america/grand_turk'), + americaGrenada(value: 'america/grenada'), + americaGuadeloupe(value: 'america/guadeloupe'), + americaGuatemala(value: 'america/guatemala'), + americaGuayaquil(value: 'america/guayaquil'), + americaGuyana(value: 'america/guyana'), + americaHalifax(value: 'america/halifax'), + americaHavana(value: 'america/havana'), + americaHermosillo(value: 'america/hermosillo'), + americaIndianaIndianapolis(value: 'america/indiana/indianapolis'), + americaIndianaKnox(value: 'america/indiana/knox'), + americaIndianaMarengo(value: 'america/indiana/marengo'), + americaIndianaPetersburg(value: 'america/indiana/petersburg'), + americaIndianaTellCity(value: 'america/indiana/tell_city'), + americaIndianaVevay(value: 'america/indiana/vevay'), + americaIndianaVincennes(value: 'america/indiana/vincennes'), + americaIndianaWinamac(value: 'america/indiana/winamac'), + americaInuvik(value: 'america/inuvik'), + americaIqaluit(value: 'america/iqaluit'), + americaJamaica(value: 'america/jamaica'), + americaJuneau(value: 'america/juneau'), + americaKentuckyLouisville(value: 'america/kentucky/louisville'), + americaKentuckyMonticello(value: 'america/kentucky/monticello'), + americaKralendijk(value: 'america/kralendijk'), + americaLaPaz(value: 'america/la_paz'), + americaLima(value: 'america/lima'), + americaLosAngeles(value: 'america/los_angeles'), + americaLowerPrinces(value: 'america/lower_princes'), + americaMaceio(value: 'america/maceio'), + americaManagua(value: 'america/managua'), + americaManaus(value: 'america/manaus'), + americaMarigot(value: 'america/marigot'), + americaMartinique(value: 'america/martinique'), + americaMatamoros(value: 'america/matamoros'), + americaMazatlan(value: 'america/mazatlan'), + americaMenominee(value: 'america/menominee'), + americaMerida(value: 'america/merida'), + americaMetlakatla(value: 'america/metlakatla'), + americaMexicoCity(value: 'america/mexico_city'), + americaMiquelon(value: 'america/miquelon'), + americaMoncton(value: 'america/moncton'), + americaMonterrey(value: 'america/monterrey'), + americaMontevideo(value: 'america/montevideo'), + americaMontserrat(value: 'america/montserrat'), + americaNassau(value: 'america/nassau'), + americaNewYork(value: 'america/new_york'), + americaNome(value: 'america/nome'), + americaNoronha(value: 'america/noronha'), + americaNorthDakotaBeulah(value: 'america/north_dakota/beulah'), + americaNorthDakotaCenter(value: 'america/north_dakota/center'), + americaNorthDakotaNewSalem(value: 'america/north_dakota/new_salem'), + americaNuuk(value: 'america/nuuk'), + americaOjinaga(value: 'america/ojinaga'), + americaPanama(value: 'america/panama'), + americaParamaribo(value: 'america/paramaribo'), + americaPhoenix(value: 'america/phoenix'), + americaPortAuPrince(value: 'america/port-au-prince'), + americaPortOfSpain(value: 'america/port_of_spain'), + americaPortoVelho(value: 'america/porto_velho'), + americaPuertoRico(value: 'america/puerto_rico'), + americaPuntaArenas(value: 'america/punta_arenas'), + americaRankinInlet(value: 'america/rankin_inlet'), + americaRecife(value: 'america/recife'), + americaRegina(value: 'america/regina'), + americaResolute(value: 'america/resolute'), + americaRioBranco(value: 'america/rio_branco'), + americaSantarem(value: 'america/santarem'), + americaSantiago(value: 'america/santiago'), + americaSantoDomingo(value: 'america/santo_domingo'), + americaSaoPaulo(value: 'america/sao_paulo'), + americaScoresbysund(value: 'america/scoresbysund'), + americaSitka(value: 'america/sitka'), + americaStBarthelemy(value: 'america/st_barthelemy'), + americaStJohns(value: 'america/st_johns'), + americaStKitts(value: 'america/st_kitts'), + americaStLucia(value: 'america/st_lucia'), + americaStThomas(value: 'america/st_thomas'), + americaStVincent(value: 'america/st_vincent'), + americaSwiftCurrent(value: 'america/swift_current'), + americaTegucigalpa(value: 'america/tegucigalpa'), + americaThule(value: 'america/thule'), + americaTijuana(value: 'america/tijuana'), + americaToronto(value: 'america/toronto'), + americaTortola(value: 'america/tortola'), + americaVancouver(value: 'america/vancouver'), + americaWhitehorse(value: 'america/whitehorse'), + americaWinnipeg(value: 'america/winnipeg'), + americaYakutat(value: 'america/yakutat'), + antarcticaCasey(value: 'antarctica/casey'), + antarcticaDavis(value: 'antarctica/davis'), + antarcticaDumontdurville(value: 'antarctica/dumontdurville'), + antarcticaMacquarie(value: 'antarctica/macquarie'), + antarcticaMawson(value: 'antarctica/mawson'), + antarcticaMcmurdo(value: 'antarctica/mcmurdo'), + antarcticaPalmer(value: 'antarctica/palmer'), + antarcticaRothera(value: 'antarctica/rothera'), + antarcticaSyowa(value: 'antarctica/syowa'), + antarcticaTroll(value: 'antarctica/troll'), + antarcticaVostok(value: 'antarctica/vostok'), + arcticLongyearbyen(value: 'arctic/longyearbyen'), + asiaAden(value: 'asia/aden'), + asiaAlmaty(value: 'asia/almaty'), + asiaAmman(value: 'asia/amman'), + asiaAnadyr(value: 'asia/anadyr'), + asiaAqtau(value: 'asia/aqtau'), + asiaAqtobe(value: 'asia/aqtobe'), + asiaAshgabat(value: 'asia/ashgabat'), + asiaAtyrau(value: 'asia/atyrau'), + asiaBaghdad(value: 'asia/baghdad'), + asiaBahrain(value: 'asia/bahrain'), + asiaBaku(value: 'asia/baku'), + asiaBangkok(value: 'asia/bangkok'), + asiaBarnaul(value: 'asia/barnaul'), + asiaBeirut(value: 'asia/beirut'), + asiaBishkek(value: 'asia/bishkek'), + asiaBrunei(value: 'asia/brunei'), + asiaChita(value: 'asia/chita'), + asiaColombo(value: 'asia/colombo'), + asiaDamascus(value: 'asia/damascus'), + asiaDhaka(value: 'asia/dhaka'), + asiaDili(value: 'asia/dili'), + asiaDubai(value: 'asia/dubai'), + asiaDushanbe(value: 'asia/dushanbe'), + asiaFamagusta(value: 'asia/famagusta'), + asiaGaza(value: 'asia/gaza'), + asiaHebron(value: 'asia/hebron'), + asiaHoChiMinh(value: 'asia/ho_chi_minh'), + asiaHongKong(value: 'asia/hong_kong'), + asiaHovd(value: 'asia/hovd'), + asiaIrkutsk(value: 'asia/irkutsk'), + asiaJakarta(value: 'asia/jakarta'), + asiaJayapura(value: 'asia/jayapura'), + asiaJerusalem(value: 'asia/jerusalem'), + asiaKabul(value: 'asia/kabul'), + asiaKamchatka(value: 'asia/kamchatka'), + asiaKarachi(value: 'asia/karachi'), + asiaKathmandu(value: 'asia/kathmandu'), + asiaKhandyga(value: 'asia/khandyga'), + asiaKolkata(value: 'asia/kolkata'), + asiaKrasnoyarsk(value: 'asia/krasnoyarsk'), + asiaKualaLumpur(value: 'asia/kuala_lumpur'), + asiaKuching(value: 'asia/kuching'), + asiaKuwait(value: 'asia/kuwait'), + asiaMacau(value: 'asia/macau'), + asiaMagadan(value: 'asia/magadan'), + asiaMakassar(value: 'asia/makassar'), + asiaManila(value: 'asia/manila'), + asiaMuscat(value: 'asia/muscat'), + asiaNicosia(value: 'asia/nicosia'), + asiaNovokuznetsk(value: 'asia/novokuznetsk'), + asiaNovosibirsk(value: 'asia/novosibirsk'), + asiaOmsk(value: 'asia/omsk'), + asiaOral(value: 'asia/oral'), + asiaPhnomPenh(value: 'asia/phnom_penh'), + asiaPontianak(value: 'asia/pontianak'), + asiaPyongyang(value: 'asia/pyongyang'), + asiaQatar(value: 'asia/qatar'), + asiaQostanay(value: 'asia/qostanay'), + asiaQyzylorda(value: 'asia/qyzylorda'), + asiaRiyadh(value: 'asia/riyadh'), + asiaSakhalin(value: 'asia/sakhalin'), + asiaSamarkand(value: 'asia/samarkand'), + asiaSeoul(value: 'asia/seoul'), + asiaShanghai(value: 'asia/shanghai'), + asiaSingapore(value: 'asia/singapore'), + asiaSrednekolymsk(value: 'asia/srednekolymsk'), + asiaTaipei(value: 'asia/taipei'), + asiaTashkent(value: 'asia/tashkent'), + asiaTbilisi(value: 'asia/tbilisi'), + asiaTehran(value: 'asia/tehran'), + asiaThimphu(value: 'asia/thimphu'), + asiaTokyo(value: 'asia/tokyo'), + asiaTomsk(value: 'asia/tomsk'), + asiaUlaanbaatar(value: 'asia/ulaanbaatar'), + asiaUrumqi(value: 'asia/urumqi'), + asiaUstNera(value: 'asia/ust-nera'), + asiaVientiane(value: 'asia/vientiane'), + asiaVladivostok(value: 'asia/vladivostok'), + asiaYakutsk(value: 'asia/yakutsk'), + asiaYangon(value: 'asia/yangon'), + asiaYekaterinburg(value: 'asia/yekaterinburg'), + asiaYerevan(value: 'asia/yerevan'), + atlanticAzores(value: 'atlantic/azores'), + atlanticBermuda(value: 'atlantic/bermuda'), + atlanticCanary(value: 'atlantic/canary'), + atlanticCapeVerde(value: 'atlantic/cape_verde'), + atlanticFaroe(value: 'atlantic/faroe'), + atlanticMadeira(value: 'atlantic/madeira'), + atlanticReykjavik(value: 'atlantic/reykjavik'), + atlanticSouthGeorgia(value: 'atlantic/south_georgia'), + atlanticStHelena(value: 'atlantic/st_helena'), + atlanticStanley(value: 'atlantic/stanley'), + australiaAdelaide(value: 'australia/adelaide'), + australiaBrisbane(value: 'australia/brisbane'), + australiaBrokenHill(value: 'australia/broken_hill'), + australiaDarwin(value: 'australia/darwin'), + australiaEucla(value: 'australia/eucla'), + australiaHobart(value: 'australia/hobart'), + australiaLindeman(value: 'australia/lindeman'), + australiaLordHowe(value: 'australia/lord_howe'), + australiaMelbourne(value: 'australia/melbourne'), + australiaPerth(value: 'australia/perth'), + australiaSydney(value: 'australia/sydney'), + europeAmsterdam(value: 'europe/amsterdam'), + europeAndorra(value: 'europe/andorra'), + europeAstrakhan(value: 'europe/astrakhan'), + europeAthens(value: 'europe/athens'), + europeBelgrade(value: 'europe/belgrade'), + europeBerlin(value: 'europe/berlin'), + europeBratislava(value: 'europe/bratislava'), + europeBrussels(value: 'europe/brussels'), + europeBucharest(value: 'europe/bucharest'), + europeBudapest(value: 'europe/budapest'), + europeBusingen(value: 'europe/busingen'), + europeChisinau(value: 'europe/chisinau'), + europeCopenhagen(value: 'europe/copenhagen'), + europeDublin(value: 'europe/dublin'), + europeGibraltar(value: 'europe/gibraltar'), + europeGuernsey(value: 'europe/guernsey'), + europeHelsinki(value: 'europe/helsinki'), + europeIsleOfMan(value: 'europe/isle_of_man'), + europeIstanbul(value: 'europe/istanbul'), + europeJersey(value: 'europe/jersey'), + europeKaliningrad(value: 'europe/kaliningrad'), + europeKirov(value: 'europe/kirov'), + europeKyiv(value: 'europe/kyiv'), + europeLisbon(value: 'europe/lisbon'), + europeLjubljana(value: 'europe/ljubljana'), + europeLondon(value: 'europe/london'), + europeLuxembourg(value: 'europe/luxembourg'), + europeMadrid(value: 'europe/madrid'), + europeMalta(value: 'europe/malta'), + europeMariehamn(value: 'europe/mariehamn'), + europeMinsk(value: 'europe/minsk'), + europeMonaco(value: 'europe/monaco'), + europeMoscow(value: 'europe/moscow'), + europeOslo(value: 'europe/oslo'), + europeParis(value: 'europe/paris'), + europePodgorica(value: 'europe/podgorica'), + europePrague(value: 'europe/prague'), + europeRiga(value: 'europe/riga'), + europeRome(value: 'europe/rome'), + europeSamara(value: 'europe/samara'), + europeSanMarino(value: 'europe/san_marino'), + europeSarajevo(value: 'europe/sarajevo'), + europeSaratov(value: 'europe/saratov'), + europeSimferopol(value: 'europe/simferopol'), + europeSkopje(value: 'europe/skopje'), + europeSofia(value: 'europe/sofia'), + europeStockholm(value: 'europe/stockholm'), + europeTallinn(value: 'europe/tallinn'), + europeTirane(value: 'europe/tirane'), + europeUlyanovsk(value: 'europe/ulyanovsk'), + europeVaduz(value: 'europe/vaduz'), + europeVatican(value: 'europe/vatican'), + europeVienna(value: 'europe/vienna'), + europeVilnius(value: 'europe/vilnius'), + europeVolgograd(value: 'europe/volgograd'), + europeWarsaw(value: 'europe/warsaw'), + europeZagreb(value: 'europe/zagreb'), + europeZurich(value: 'europe/zurich'), + indianAntananarivo(value: 'indian/antananarivo'), + indianChagos(value: 'indian/chagos'), + indianChristmas(value: 'indian/christmas'), + indianCocos(value: 'indian/cocos'), + indianComoro(value: 'indian/comoro'), + indianKerguelen(value: 'indian/kerguelen'), + indianMahe(value: 'indian/mahe'), + indianMaldives(value: 'indian/maldives'), + indianMauritius(value: 'indian/mauritius'), + indianMayotte(value: 'indian/mayotte'), + indianReunion(value: 'indian/reunion'), + pacificApia(value: 'pacific/apia'), + pacificAuckland(value: 'pacific/auckland'), + pacificBougainville(value: 'pacific/bougainville'), + pacificChatham(value: 'pacific/chatham'), + pacificChuuk(value: 'pacific/chuuk'), + pacificEaster(value: 'pacific/easter'), + pacificEfate(value: 'pacific/efate'), + pacificFakaofo(value: 'pacific/fakaofo'), + pacificFiji(value: 'pacific/fiji'), + pacificFunafuti(value: 'pacific/funafuti'), + pacificGalapagos(value: 'pacific/galapagos'), + pacificGambier(value: 'pacific/gambier'), + pacificGuadalcanal(value: 'pacific/guadalcanal'), + pacificGuam(value: 'pacific/guam'), + pacificHonolulu(value: 'pacific/honolulu'), + pacificKanton(value: 'pacific/kanton'), + pacificKiritimati(value: 'pacific/kiritimati'), + pacificKosrae(value: 'pacific/kosrae'), + pacificKwajalein(value: 'pacific/kwajalein'), + pacificMajuro(value: 'pacific/majuro'), + pacificMarquesas(value: 'pacific/marquesas'), + pacificMidway(value: 'pacific/midway'), + pacificNauru(value: 'pacific/nauru'), + pacificNiue(value: 'pacific/niue'), + pacificNorfolk(value: 'pacific/norfolk'), + pacificNoumea(value: 'pacific/noumea'), + pacificPagoPago(value: 'pacific/pago_pago'), + pacificPalau(value: 'pacific/palau'), + pacificPitcairn(value: 'pacific/pitcairn'), + pacificPohnpei(value: 'pacific/pohnpei'), + pacificPortMoresby(value: 'pacific/port_moresby'), + pacificRarotonga(value: 'pacific/rarotonga'), + pacificSaipan(value: 'pacific/saipan'), + pacificTahiti(value: 'pacific/tahiti'), + pacificTarawa(value: 'pacific/tarawa'), + pacificTongatapu(value: 'pacific/tongatapu'), + pacificWake(value: 'pacific/wake'), + pacificWallis(value: 'pacific/wallis'), + utc(value: 'utc'); - const Timezone({required this.value}); + const Timezone({ + 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 344a8770..f80fa854 100644 --- a/lib/src/models/algo_argon2.dart +++ b/lib/src/models/algo_argon2.dart @@ -2,41 +2,41 @@ 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'], + ); + } - @override - Map toMap() { - return { - "type": type, - "memoryCost": memoryCost, - "timeCost": timeCost, - "threads": threads, - }; - } + @override + 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 9909265e..c51da4bb 100644 --- a/lib/src/models/algo_bcrypt.dart +++ b/lib/src/models/algo_bcrypt.dart @@ -2,23 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return { - "type": type, - }; - } + @override + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_md5.dart b/lib/src/models/algo_md5.dart index 746fbd52..43523ab1 100644 --- a/lib/src/models/algo_md5.dart +++ b/lib/src/models/algo_md5.dart @@ -2,23 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return { - "type": type, - }; - } + @override + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_phpass.dart b/lib/src/models/algo_phpass.dart index cab45e49..8562c4e3 100644 --- a/lib/src/models/algo_phpass.dart +++ b/lib/src/models/algo_phpass.dart @@ -2,23 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return { - "type": type, - }; - } + @override + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_scrypt.dart b/lib/src/models/algo_scrypt.dart index a1648843..8e844839 100644 --- a/lib/src/models/algo_scrypt.dart +++ b/lib/src/models/algo_scrypt.dart @@ -2,47 +2,47 @@ 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'], - ); - } - - @override - 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'], + ); + } + + @override + 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 33ef4a6f..5202db05 100644 --- a/lib/src/models/algo_scrypt_modified.dart +++ b/lib/src/models/algo_scrypt_modified.dart @@ -2,41 +2,41 @@ 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(), + ); + } - @override - Map toMap() { - return { - "type": type, - "salt": salt, - "saltSeparator": saltSeparator, - "signerKey": signerKey, - }; - } + @override + 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 4984df75..3d08af9f 100644 --- a/lib/src/models/algo_sha.dart +++ b/lib/src/models/algo_sha.dart @@ -2,23 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return { - "type": type, - }; - } + @override + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/continent.dart b/lib/src/models/continent.dart index ec3c41be..930900bf 100644 --- a/lib/src/models/continent.dart +++ b/lib/src/models/continent.dart @@ -2,29 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return { - "name": name, - "code": code, - }; - } + @override + Map toMap() { + return { + "name": name, + "code": code, + }; + } } diff --git a/lib/src/models/continent_list.dart b/lib/src/models/continent_list.dart index df28f04b..753bcacc 100644 --- a/lib/src/models/continent_list.dart +++ b/lib/src/models/continent_list.dart @@ -2,30 +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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "continents": continents.map((p) => p.toMap()).toList(), - }; - } + @override + 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 3bcbb76d..c4838ba3 100644 --- a/lib/src/models/country.dart +++ b/lib/src/models/country.dart @@ -2,29 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return { - "name": name, - "code": code, - }; - } + @override + Map toMap() { + return { + "name": name, + "code": code, + }; + } } diff --git a/lib/src/models/country_list.dart b/lib/src/models/country_list.dart index 79cb1256..f363a54b 100644 --- a/lib/src/models/country_list.dart +++ b/lib/src/models/country_list.dart @@ -2,30 +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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "countries": countries.map((p) => p.toMap()).toList(), - }; - } + @override + 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 f2b18093..b6bb455f 100644 --- a/lib/src/models/currency.dart +++ b/lib/src/models/currency.dart @@ -2,59 +2,59 @@ 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(), - ); - } - - @override - 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(), + ); + } + + @override + 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 6c39ae2e..eb2bad19 100644 --- a/lib/src/models/currency_list.dart +++ b/lib/src/models/currency_list.dart @@ -2,30 +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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "currencies": currencies.map((p) => p.toMap()).toList(), - }; - } + @override + 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 be08d599..0d1fdeb0 100644 --- a/lib/src/models/document.dart +++ b/lib/src/models/document.dart @@ -2,66 +2,66 @@ part of '../../models.dart'; /// Document class Document implements Model { - /// Document ID. - final String $id; + /// Document ID. + final String $id; - /// Document sequence ID. - final String $sequence; + /// Document sequence ID. + final String $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'].toString(), - $collectionId: map['\$collectionId'].toString(), - $databaseId: map['\$databaseId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - data: map["data"] ?? map, - ); - } + factory Document.fromMap(Map map) { + return Document( + $id: map['\$id'].toString(), + $sequence: map['\$sequence'].toString(), + $collectionId: map['\$collectionId'].toString(), + $databaseId: map['\$databaseId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + data: map["data"] ?? map, + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$sequence": $sequence, - "\$collectionId": $collectionId, - "\$databaseId": $databaseId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "data": data, - }; - } + @override + 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 76a07309..0e30844a 100644 --- a/lib/src/models/document_list.dart +++ b/lib/src/models/document_list.dart @@ -2,33 +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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "documents": documents.map((p) => p.toMap()).toList(), - }; - } + @override + 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 3629e1d6..3e767ca3 100644 --- a/lib/src/models/execution.dart +++ b/lib/src/models/execution.dart @@ -2,129 +2,125 @@ 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 enums.ExecutionTrigger trigger; - - /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, `failed`, or `scheduled`. - final enums.ExecutionStatus status; - - /// HTTP request method type. - final String requestMethod; - - /// HTTP request path and query. - final String requestPath; - - /// HTTP request 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: enums.ExecutionTrigger.values - .firstWhere((e) => e.value == map['trigger']), - status: enums.ExecutionStatus.values - .firstWhere((e) => e.value == map['status']), - 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(), - ); - } - - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "functionId": functionId, - "deploymentId": deploymentId, - "trigger": trigger.value, - "status": status.value, - "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 enums.ExecutionTrigger trigger; + + /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, `failed`, or `scheduled`. + final enums.ExecutionStatus status; + + /// HTTP request method type. + final String requestMethod; + + /// HTTP request path and query. + final String requestPath; + + /// HTTP request 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: enums.ExecutionTrigger.values.firstWhere((e) => e.value == map['trigger']), + status: enums.ExecutionStatus.values.firstWhere((e) => e.value == map['status']), + 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(), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "functionId": functionId, + "deploymentId": deploymentId, + "trigger": trigger.value, + "status": status.value, + "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 63c2ad7e..45b60682 100644 --- a/lib/src/models/execution_list.dart +++ b/lib/src/models/execution_list.dart @@ -2,30 +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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "executions": executions.map((p) => p.toMap()).toList(), - }; - } + @override + 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 01cdcb3a..9e5f9eb1 100644 --- a/lib/src/models/file.dart +++ b/lib/src/models/file.dart @@ -2,101 +2,101 @@ part of '../../models.dart'; /// File class File implements Model { - /// File ID. - final String $id; - - /// Bucket ID. - final String bucketId; - - /// File creation date in ISO 8601 format. - final String $createdAt; - - /// 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 name. - final String name; - - /// File MD5 signature. - final String signature; - - /// File mime type. - final String mimeType; - - /// File original size in bytes. - final int sizeOriginal; - - /// File actual stored size in bytes after compression and/or encryption. - final int sizeActual; - - /// Total number of chunks available - final int chunksTotal; - - /// Total number of chunks uploaded - final int chunksUploaded; - - /// Whether file contents are encrypted at rest. - final bool encryption; - - /// Compression algorithm used for the file. Will be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd). - final String compression; - - 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.sizeActual, - required this.chunksTotal, - required this.chunksUploaded, - required this.encryption, - required this.compression, - }); - - 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'], - sizeActual: map['sizeActual'], - chunksTotal: map['chunksTotal'], - chunksUploaded: map['chunksUploaded'], - encryption: map['encryption'], - compression: map['compression'].toString(), - ); - } - - @override - Map toMap() { - return { - "\$id": $id, - "bucketId": bucketId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "name": name, - "signature": signature, - "mimeType": mimeType, - "sizeOriginal": sizeOriginal, - "sizeActual": sizeActual, - "chunksTotal": chunksTotal, - "chunksUploaded": chunksUploaded, - "encryption": encryption, - "compression": compression, - }; - } + /// File ID. + final String $id; + + /// Bucket ID. + final String bucketId; + + /// File creation date in ISO 8601 format. + final String $createdAt; + + /// 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 name. + final String name; + + /// File MD5 signature. + final String signature; + + /// File mime type. + final String mimeType; + + /// File original size in bytes. + final int sizeOriginal; + + /// File actual stored size in bytes after compression and/or encryption. + final int sizeActual; + + /// Total number of chunks available + final int chunksTotal; + + /// Total number of chunks uploaded + final int chunksUploaded; + + /// Whether file contents are encrypted at rest. + final bool encryption; + + /// Compression algorithm used for the file. Will be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd). + final String compression; + + 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.sizeActual, + required this.chunksTotal, + required this.chunksUploaded, + required this.encryption, + required this.compression, + }); + + 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'], + sizeActual: map['sizeActual'], + chunksTotal: map['chunksTotal'], + chunksUploaded: map['chunksUploaded'], + encryption: map['encryption'], + compression: map['compression'].toString(), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "bucketId": bucketId, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "name": name, + "signature": signature, + "mimeType": mimeType, + "sizeOriginal": sizeOriginal, + "sizeActual": sizeActual, + "chunksTotal": chunksTotal, + "chunksUploaded": chunksUploaded, + "encryption": encryption, + "compression": compression, + }; + } } diff --git a/lib/src/models/file_list.dart b/lib/src/models/file_list.dart index 1157554a..84c54b2e 100644 --- a/lib/src/models/file_list.dart +++ b/lib/src/models/file_list.dart @@ -2,29 +2,29 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "files": files.map((p) => p.toMap()).toList(), - }; - } + @override + 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 fa054420..bbccf88a 100644 --- a/lib/src/models/headers.dart +++ b/lib/src/models/headers.dart @@ -2,29 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return { - "name": name, - "value": value, - }; - } + @override + Map toMap() { + return { + "name": name, + "value": value, + }; + } } diff --git a/lib/src/models/identity.dart b/lib/src/models/identity.dart index cc659043..7e90020c 100644 --- a/lib/src/models/identity.dart +++ b/lib/src/models/identity.dart @@ -2,77 +2,77 @@ 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(), + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "userId": userId, - "provider": provider, - "providerUid": providerUid, - "providerEmail": providerEmail, - "providerAccessToken": providerAccessToken, - "providerAccessTokenExpiry": providerAccessTokenExpiry, - "providerRefreshToken": providerRefreshToken, - }; - } + @override + 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 a5d39ea0..d9cc09a2 100644 --- a/lib/src/models/identity_list.dart +++ b/lib/src/models/identity_list.dart @@ -2,30 +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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "identities": identities.map((p) => p.toMap()).toList(), - }; - } + @override + 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 cda66c70..2000acb6 100644 --- a/lib/src/models/jwt.dart +++ b/lib/src/models/jwt.dart @@ -2,23 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return { - "jwt": jwt, - }; - } + @override + Map toMap() { + return { + "jwt": jwt, + }; + } } diff --git a/lib/src/models/language.dart b/lib/src/models/language.dart index 87dc3606..1422d065 100644 --- a/lib/src/models/language.dart +++ b/lib/src/models/language.dart @@ -2,35 +2,35 @@ 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(), + ); + } - @override - Map toMap() { - return { - "name": name, - "code": code, - "nativeName": nativeName, - }; - } + @override + 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 6198d61e..5d78a367 100644 --- a/lib/src/models/language_list.dart +++ b/lib/src/models/language_list.dart @@ -2,30 +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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "languages": languages.map((p) => p.toMap()).toList(), - }; - } + @override + 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 54dd0c29..3292a896 100644 --- a/lib/src/models/locale.dart +++ b/lib/src/models/locale.dart @@ -2,59 +2,59 @@ 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(), - ); - } - - @override - 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(), + ); + } + + @override + 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 21405aff..49ef3b0b 100644 --- a/lib/src/models/locale_code.dart +++ b/lib/src/models/locale_code.dart @@ -2,29 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return { - "code": code, - "name": name, - }; - } + @override + 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 202355a4..a3a26b61 100644 --- a/lib/src/models/locale_code_list.dart +++ b/lib/src/models/locale_code_list.dart @@ -2,30 +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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "localeCodes": localeCodes.map((p) => p.toMap()).toList(), - }; - } + @override + 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 572cce50..406fcbcf 100644 --- a/lib/src/models/log.dart +++ b/lib/src/models/log.dart @@ -2,149 +2,149 @@ part of '../../models.dart'; /// Log class Log implements Model { - /// Event name. - final String event; - - /// User ID of the actor recorded for this log. During impersonation, this is the original impersonator, not the impersonated target user. - final String userId; - - /// User email of the actor recorded for this log. During impersonation, this is the original impersonator. - final String userEmail; - - /// User name of the actor recorded for this log. During impersonation, this is the original impersonator. - final String userName; - - /// API mode when event triggered. - final String mode; - - /// User type who triggered the audit log. Possible values: user, admin, guest, keyProject, keyAccount, keyOrganization. - final String userType; - - /// 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.userType, - 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(), - userType: map['userType'].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(), - ); - } - - @override - Map toMap() { - return { - "event": event, - "userId": userId, - "userEmail": userEmail, - "userName": userName, - "mode": mode, - "userType": userType, - "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 of the actor recorded for this log. During impersonation, this is the original impersonator, not the impersonated target user. + final String userId; + + /// User email of the actor recorded for this log. During impersonation, this is the original impersonator. + final String userEmail; + + /// User name of the actor recorded for this log. During impersonation, this is the original impersonator. + final String userName; + + /// API mode when event triggered. + final String mode; + + /// User type who triggered the audit log. Possible values: user, admin, guest, keyProject, keyAccount, keyOrganization. + final String userType; + + /// 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.userType, + 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(), + userType: map['userType'].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(), + ); + } + + @override + Map toMap() { + return { + "event": event, + "userId": userId, + "userEmail": userEmail, + "userName": userName, + "mode": mode, + "userType": userType, + "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 3494b111..ebf593c2 100644 --- a/lib/src/models/log_list.dart +++ b/lib/src/models/log_list.dart @@ -2,29 +2,29 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "logs": logs.map((p) => p.toMap()).toList(), - }; - } + @override + 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 4d8a2f9b..4baffb71 100644 --- a/lib/src/models/membership.dart +++ b/lib/src/models/membership.dart @@ -2,107 +2,107 @@ 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; - - /// User phone number. Hide this attribute by toggling membership privacy in the Console. - final String userPhone; - - /// 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; - - /// Most recent access date in ISO 8601 format. Show this attribute by toggling membership privacy in the Console. - final String userAccessedAt; - - /// 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.userPhone, - required this.teamId, - required this.teamName, - required this.invited, - required this.joined, - required this.confirm, - required this.mfa, - required this.userAccessedAt, - 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(), - userPhone: map['userPhone'].toString(), - teamId: map['teamId'].toString(), - teamName: map['teamName'].toString(), - invited: map['invited'].toString(), - joined: map['joined'].toString(), - confirm: map['confirm'], - mfa: map['mfa'], - userAccessedAt: map['userAccessedAt'].toString(), - roles: List.from(map['roles'] ?? []), - ); - } - - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "userId": userId, - "userName": userName, - "userEmail": userEmail, - "userPhone": userPhone, - "teamId": teamId, - "teamName": teamName, - "invited": invited, - "joined": joined, - "confirm": confirm, - "mfa": mfa, - "userAccessedAt": userAccessedAt, - "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; + + /// User phone number. Hide this attribute by toggling membership privacy in the Console. + final String userPhone; + + /// 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; + + /// Most recent access date in ISO 8601 format. Show this attribute by toggling membership privacy in the Console. + final String userAccessedAt; + + /// 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.userPhone, + required this.teamId, + required this.teamName, + required this.invited, + required this.joined, + required this.confirm, + required this.mfa, + required this.userAccessedAt, + 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(), + userPhone: map['userPhone'].toString(), + teamId: map['teamId'].toString(), + teamName: map['teamName'].toString(), + invited: map['invited'].toString(), + joined: map['joined'].toString(), + confirm: map['confirm'], + mfa: map['mfa'], + userAccessedAt: map['userAccessedAt'].toString(), + roles: List.from(map['roles'] ?? []), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "userId": userId, + "userName": userName, + "userEmail": userEmail, + "userPhone": userPhone, + "teamId": teamId, + "teamName": teamName, + "invited": invited, + "joined": joined, + "confirm": confirm, + "mfa": mfa, + "userAccessedAt": userAccessedAt, + "roles": roles, + }; + } } diff --git a/lib/src/models/membership_list.dart b/lib/src/models/membership_list.dart index cc664c9f..a0641a28 100644 --- a/lib/src/models/membership_list.dart +++ b/lib/src/models/membership_list.dart @@ -2,30 +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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "memberships": memberships.map((p) => p.toMap()).toList(), - }; - } + @override + 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 fa385541..3d2e2335 100644 --- a/lib/src/models/mfa_challenge.dart +++ b/lib/src/models/mfa_challenge.dart @@ -2,41 +2,41 @@ 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(), + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "userId": userId, - "expire": expire, - }; - } + @override + 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 2777de7f..a7e5fefc 100644 --- a/lib/src/models/mfa_factors.dart +++ b/lib/src/models/mfa_factors.dart @@ -2,41 +2,41 @@ 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'], + ); + } - @override - Map toMap() { - return { - "totp": totp, - "phone": phone, - "email": email, - "recoveryCode": recoveryCode, - }; - } + @override + 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 864a5db8..33036476 100644 --- a/lib/src/models/mfa_recovery_codes.dart +++ b/lib/src/models/mfa_recovery_codes.dart @@ -2,23 +2,23 @@ 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'] ?? []), + ); + } - @override - Map toMap() { - return { - "recoveryCodes": recoveryCodes, - }; - } + @override + Map toMap() { + return { + "recoveryCodes": recoveryCodes, + }; + } } diff --git a/lib/src/models/mfa_type.dart b/lib/src/models/mfa_type.dart index fe5327fc..05cab363 100644 --- a/lib/src/models/mfa_type.dart +++ b/lib/src/models/mfa_type.dart @@ -2,29 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return { - "secret": secret, - "uri": uri, - }; - } + @override + 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 60e2abd9..7ac578e2 100644 --- a/lib/src/models/phone.dart +++ b/lib/src/models/phone.dart @@ -2,35 +2,35 @@ 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(), + ); + } - @override - Map toMap() { - return { - "code": code, - "countryCode": countryCode, - "countryName": countryName, - }; - } + @override + 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 1a197fc7..9791d590 100644 --- a/lib/src/models/phone_list.dart +++ b/lib/src/models/phone_list.dart @@ -2,29 +2,29 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "phones": phones.map((p) => p.toMap()).toList(), - }; - } + @override + 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 3ca04118..b107afe5 100644 --- a/lib/src/models/preferences.dart +++ b/lib/src/models/preferences.dart @@ -2,24 +2,24 @@ 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["data"] ?? map, - ); - } + factory Preferences.fromMap(Map map) { + return Preferences( + data: map["data"] ?? map, + ); + } - @override - Map toMap() { - return { - "data": data, - }; - } + @override + 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/presence.dart b/lib/src/models/presence.dart index d31911de..133fe66d 100644 --- a/lib/src/models/presence.dart +++ b/lib/src/models/presence.dart @@ -2,71 +2,71 @@ part of '../../models.dart'; /// Presence class Presence implements Model { - /// Presence ID. - final String $id; + /// Presence ID. + final String $id; - /// Presence creation date in ISO 8601 format. - final String $createdAt; + /// Presence creation date in ISO 8601 format. + final String $createdAt; - /// Presence update date in ISO 8601 format. - final String $updatedAt; + /// Presence update date in ISO 8601 format. + final String $updatedAt; - /// Presence permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; + /// Presence permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Presence status. - final String? status; + /// Presence status. + final String? status; - /// Presence source. - final String source; + /// Presence source. + final String source; - /// Presence expiry date in ISO 8601 format. - final String? expiresAt; + /// Presence expiry date in ISO 8601 format. + final String? expiresAt; - /// Presence metadata. - final Map? metadata; + /// Presence metadata. + final Map? metadata; - Presence({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.userId, - this.status, - required this.source, - this.expiresAt, - this.metadata, - }); + Presence({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.userId, + this.status, + required this.source, + this.expiresAt, + this.metadata, + }); - factory Presence.fromMap(Map map) { - return Presence( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - userId: map['userId'].toString(), - status: map['status']?.toString(), - source: map['source'].toString(), - expiresAt: map['expiresAt']?.toString(), - metadata: map['metadata'], - ); - } + factory Presence.fromMap(Map map) { + return Presence( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + userId: map['userId'].toString(), + status: map['status']?.toString(), + source: map['source'].toString(), + expiresAt: map['expiresAt']?.toString(), + metadata: map['metadata'], + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "userId": userId, - "status": status, - "source": source, - "expiresAt": expiresAt, - "metadata": metadata, - }; - } + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "userId": userId, + "status": status, + "source": source, + "expiresAt": expiresAt, + "metadata": metadata, + }; + } } diff --git a/lib/src/models/presence_list.dart b/lib/src/models/presence_list.dart index 3d010b1c..aebbe880 100644 --- a/lib/src/models/presence_list.dart +++ b/lib/src/models/presence_list.dart @@ -2,30 +2,29 @@ part of '../../models.dart'; /// Presences List class PresenceList implements Model { - /// Total number of presences that matched your query. - final int total; + /// Total number of presences that matched your query. + final int total; - /// List of presences. - final List presences; + /// List of presences. + final List presences; - PresenceList({ - required this.total, - required this.presences, - }); + PresenceList({ + required this.total, + required this.presences, + }); - factory PresenceList.fromMap(Map map) { - return PresenceList( - total: map['total'], - presences: - List.from(map['presences'].map((p) => Presence.fromMap(p))), - ); - } + factory PresenceList.fromMap(Map map) { + return PresenceList( + total: map['total'], + presences: List.from(map['presences'].map((p) => Presence.fromMap(p))), + ); + } - @override - Map toMap() { - return { - "total": total, - "presences": presences.map((p) => p.toMap()).toList(), - }; - } + @override + Map toMap() { + return { + "total": total, + "presences": presences.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/row.dart b/lib/src/models/row.dart index a825eab0..c5f233b4 100644 --- a/lib/src/models/row.dart +++ b/lib/src/models/row.dart @@ -2,66 +2,66 @@ part of '../../models.dart'; /// Row class Row implements Model { - /// Row ID. - final String $id; + /// Row ID. + final String $id; - /// Row sequence ID. - final String $sequence; + /// Row sequence ID. + final String $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'].toString(), - $tableId: map['\$tableId'].toString(), - $databaseId: map['\$databaseId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - data: map["data"] ?? map, - ); - } + factory Row.fromMap(Map map) { + return Row( + $id: map['\$id'].toString(), + $sequence: map['\$sequence'].toString(), + $tableId: map['\$tableId'].toString(), + $databaseId: map['\$databaseId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + data: map["data"] ?? map, + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$sequence": $sequence, - "\$tableId": $tableId, - "\$databaseId": $databaseId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "data": data, - }; - } + @override + 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 5023c633..90efa95f 100644 --- a/lib/src/models/row_list.dart +++ b/lib/src/models/row_list.dart @@ -2,32 +2,32 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "rows": rows.map((p) => p.toMap()).toList(), - }; - } + @override + 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 92e4034e..c37de95a 100644 --- a/lib/src/models/session.dart +++ b/lib/src/models/session.dart @@ -2,191 +2,191 @@ 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(), - ); - } - - @override - 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(), + ); + } + + @override + 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 4ea12394..d823d0e6 100644 --- a/lib/src/models/session_list.dart +++ b/lib/src/models/session_list.dart @@ -2,30 +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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "sessions": sessions.map((p) => p.toMap()).toList(), - }; - } + @override + 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 450aafd1..850ab8d2 100644 --- a/lib/src/models/subscriber.dart +++ b/lib/src/models/subscriber.dart @@ -2,71 +2,71 @@ 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(), + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "targetId": targetId, - "target": target.toMap(), - "userId": userId, - "userName": userName, - "topicId": topicId, - "providerType": providerType, - }; - } + @override + 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 c2e8c4dc..742e7590 100644 --- a/lib/src/models/target.dart +++ b/lib/src/models/target.dart @@ -2,71 +2,71 @@ 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'], + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "userId": userId, - "providerId": providerId, - "providerType": providerType, - "identifier": identifier, - "expired": expired, - }; - } + @override + 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 91b888b9..21e65e95 100644 --- a/lib/src/models/team.dart +++ b/lib/src/models/team.dart @@ -2,53 +2,53 @@ 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']), - ); - } - - @override - 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']), + ); + } + + @override + 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 e8f1c621..ffca5e98 100644 --- a/lib/src/models/team_list.dart +++ b/lib/src/models/team_list.dart @@ -2,29 +2,29 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "teams": teams.map((p) => p.toMap()).toList(), - }; - } + @override + 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 b5ea87c8..b05320da 100644 --- a/lib/src/models/token.dart +++ b/lib/src/models/token.dart @@ -2,53 +2,53 @@ 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(), - ); - } - - @override - 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(), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "userId": userId, + "secret": secret, + "expire": expire, + "phrase": phrase, + }; + } } diff --git a/lib/src/models/transaction.dart b/lib/src/models/transaction.dart index b0606dd8..e3f3e43d 100644 --- a/lib/src/models/transaction.dart +++ b/lib/src/models/transaction.dart @@ -2,53 +2,53 @@ part of '../../models.dart'; /// Transaction class Transaction implements Model { - /// Transaction ID. - final String $id; - - /// Transaction creation time in ISO 8601 format. - final String $createdAt; - - /// Transaction update date in ISO 8601 format. - final String $updatedAt; - - /// Current status of the transaction. One of: pending, committing, committed, rolled_back, failed. - final String status; - - /// Number of operations in the transaction. - final int operations; - - /// Expiration time in ISO 8601 format. - final String expiresAt; - - Transaction({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.status, - required this.operations, - required this.expiresAt, - }); - - factory Transaction.fromMap(Map map) { - return Transaction( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - status: map['status'].toString(), - operations: map['operations'], - expiresAt: map['expiresAt'].toString(), - ); - } - - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "status": status, - "operations": operations, - "expiresAt": expiresAt, - }; - } + /// Transaction ID. + final String $id; + + /// Transaction creation time in ISO 8601 format. + final String $createdAt; + + /// Transaction update date in ISO 8601 format. + final String $updatedAt; + + /// Current status of the transaction. One of: pending, committing, committed, rolled_back, failed. + final String status; + + /// Number of operations in the transaction. + final int operations; + + /// Expiration time in ISO 8601 format. + final String expiresAt; + + Transaction({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.status, + required this.operations, + required this.expiresAt, + }); + + factory Transaction.fromMap(Map map) { + return Transaction( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + status: map['status'].toString(), + operations: map['operations'], + expiresAt: map['expiresAt'].toString(), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "status": status, + "operations": operations, + "expiresAt": expiresAt, + }; + } } diff --git a/lib/src/models/transaction_list.dart b/lib/src/models/transaction_list.dart index 7f321175..19ea651d 100644 --- a/lib/src/models/transaction_list.dart +++ b/lib/src/models/transaction_list.dart @@ -2,30 +2,29 @@ part of '../../models.dart'; /// Transaction List class TransactionList implements Model { - /// Total number of transactions that matched your query. - final int total; + /// Total number of transactions that matched your query. + final int total; - /// List of transactions. - final List transactions; + /// List of transactions. + final List transactions; - TransactionList({ - required this.total, - required this.transactions, - }); + TransactionList({ + required this.total, + required this.transactions, + }); - factory TransactionList.fromMap(Map map) { - return TransactionList( - total: map['total'], - transactions: List.from( - map['transactions'].map((p) => Transaction.fromMap(p))), - ); - } + factory TransactionList.fromMap(Map map) { + return TransactionList( + total: map['total'], + transactions: List.from(map['transactions'].map((p) => Transaction.fromMap(p))), + ); + } - @override - Map toMap() { - return { - "total": total, - "transactions": transactions.map((p) => p.toMap()).toList(), - }; - } + @override + Map toMap() { + return { + "total": total, + "transactions": transactions.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/user.dart b/lib/src/models/user.dart index 5a6cad30..e3b9536b 100644 --- a/lib/src/models/user.dart +++ b/lib/src/models/user.dart @@ -2,173 +2,173 @@ part of '../../models.dart'; /// User class User implements Model { - /// User ID. - final String $id; + /// User ID. + final String $id; - /// User creation date in ISO 8601 format. - final String $createdAt; + /// User creation date in ISO 8601 format. + final String $createdAt; - /// User update date in ISO 8601 format. - final String $updatedAt; + /// 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; - - /// Canonical form of the user email address. - final String? emailCanonical; - - /// Whether the user email is from a free email provider. - final bool? emailIsFree; - - /// Whether the user email is from a disposable email provider. - final bool? emailIsDisposable; - - /// Whether the user email is from a corporate domain. - final bool? emailIsCorporate; - - /// Whether the user email is in its canonical form. - final bool? emailIsCanonical; - - /// 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; - - /// Whether the user can impersonate other users. - final bool? impersonator; - - /// ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data. - final String? impersonatorUserId; - - 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, - this.emailCanonical, - this.emailIsFree, - this.emailIsDisposable, - this.emailIsCorporate, - this.emailIsCanonical, - required this.phoneVerification, - required this.mfa, - required this.prefs, - required this.targets, - required this.accessedAt, - this.impersonator, - this.impersonatorUserId, - }); - - 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'], - emailCanonical: map['emailCanonical']?.toString(), - emailIsFree: map['emailIsFree'], - emailIsDisposable: map['emailIsDisposable'], - emailIsCorporate: map['emailIsCorporate'], - emailIsCanonical: map['emailIsCanonical'], - 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(), - impersonator: map['impersonator'], - impersonatorUserId: map['impersonatorUserId']?.toString(), - ); - } - - @override - 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, - "emailCanonical": emailCanonical, - "emailIsFree": emailIsFree, - "emailIsDisposable": emailIsDisposable, - "emailIsCorporate": emailIsCorporate, - "emailIsCanonical": emailIsCanonical, - "phoneVerification": phoneVerification, - "mfa": mfa, - "prefs": prefs.toMap(), - "targets": targets.map((p) => p.toMap()).toList(), - "accessedAt": accessedAt, - "impersonator": impersonator, - "impersonatorUserId": impersonatorUserId, - }; - } + /// 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; + + /// Canonical form of the user email address. + final String? emailCanonical; + + /// Whether the user email is from a free email provider. + final bool? emailIsFree; + + /// Whether the user email is from a disposable email provider. + final bool? emailIsDisposable; + + /// Whether the user email is from a corporate domain. + final bool? emailIsCorporate; + + /// Whether the user email is in its canonical form. + final bool? emailIsCanonical; + + /// 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; + + /// Whether the user can impersonate other users. + final bool? impersonator; + + /// ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data. + final String? impersonatorUserId; + + 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, + this.emailCanonical, + this.emailIsFree, + this.emailIsDisposable, + this.emailIsCorporate, + this.emailIsCanonical, + required this.phoneVerification, + required this.mfa, + required this.prefs, + required this.targets, + required this.accessedAt, + this.impersonator, + this.impersonatorUserId, + }); + + 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'], + emailCanonical: map['emailCanonical']?.toString(), + emailIsFree: map['emailIsFree'], + emailIsDisposable: map['emailIsDisposable'], + emailIsCorporate: map['emailIsCorporate'], + emailIsCanonical: map['emailIsCanonical'], + 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(), + impersonator: map['impersonator'], + impersonatorUserId: map['impersonatorUserId']?.toString(), + ); + } + + @override + 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, + "emailCanonical": emailCanonical, + "emailIsFree": emailIsFree, + "emailIsDisposable": emailIsDisposable, + "emailIsCorporate": emailIsCorporate, + "emailIsCanonical": emailIsCanonical, + "phoneVerification": phoneVerification, + "mfa": mfa, + "prefs": prefs.toMap(), + "targets": targets.map((p) => p.toMap()).toList(), + "accessedAt": accessedAt, + "impersonator": impersonator, + "impersonatorUserId": impersonatorUserId, + }; + } } diff --git a/lib/src/realtime.dart b/lib/src/realtime.dart index 28e4c43d..7a5e6303 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(); /// ``` - /// + /// /// You can also use Channel builders: /// ```dart /// final subscription = realtime.subscribe([ diff --git a/lib/src/realtime_io.dart b/lib/src/realtime_io.dart index 0ed367a6..83f01b4c 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) { 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 72edf5ee..6cebb5b1 100644 --- a/lib/src/realtime_mixin.dart +++ b/lib/src/realtime_mixin.dart @@ -58,7 +58,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" + })); } }); } @@ -138,11 +140,9 @@ mixin RealtimeMixin { case 'event': final messageData = data.data as Map; final message = RealtimeMessage.fromMap(messageData); - final subscriptions = - (messageData['subscriptions'] as List?) - ?.map((x) => x.toString()) - .toList() ?? - []; + final subscriptions = (messageData['subscriptions'] as List?) + ?.map((x) => x.toString()) + .toList() ?? []; if (subscriptions.isEmpty) { break; @@ -209,15 +209,13 @@ mixin RealtimeMixin { "Please set endPointRealtime to connect to realtime server"); } var uri = Uri.parse(client.endPointRealtime!); - - var queryParams = - "project=${Uri.encodeComponent(client.config['project']!)}"; + + var queryParams = "project=${Uri.encodeComponent(client.config['project']!)}"; final portPart = (uri.hasPort && uri.port != 80 && uri.port != 443) ? ':${uri.port}' : ''; - return Uri.parse( - "${uri.scheme}://${uri.host}$portPart${uri.path}/realtime?$queryParams"); + return Uri.parse("${uri.scheme}://${uri.host}$portPart${uri.path}/realtime?$queryParams"); } void _sendUnsubscribeMessage(List subscriptionIds) { @@ -312,11 +310,9 @@ mixin RealtimeMixin { return channel is String ? channel : channel.toString(); } - RealtimeSubscription subscribeTo(List channels, - [List queries = const []]) { + RealtimeSubscription subscribeTo(List channels, [List queries = const []]) { StreamController controller = StreamController.broadcast(); - final channelStrings = - channels.map((ch) => _channelToString(ch)).toList().cast(); + final channelStrings = channels.map((ch) => _channelToString(ch)).toList().cast(); final queryStrings = List.from(queries); final subscriptionId = _generateUniqueSubscriptionId(); @@ -333,7 +329,8 @@ mixin RealtimeMixin { _sendUnsubscribeMessage([subscriptionId]); } - Future update({List? channels, List? queries}) async { + Future update( + {List? channels, List? queries}) async { final current = _subscriptions[subscriptionId]; if (current == null) { return; @@ -420,4 +417,4 @@ mixin RealtimeMixin { // until the application-level handshake completes. _flushPendingPresence(); } -} +} \ No newline at end of file diff --git a/lib/src/realtime_response.dart b/lib/src/realtime_response.dart index b0356111..56e7669a 100644 --- a/lib/src/realtime_response.dart +++ b/lib/src/realtime_response.dart @@ -8,6 +8,7 @@ class RealtimeResponse { required this.type, required this.data, }); + RealtimeResponse copyWith({ String? type, @@ -35,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)'; @@ -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 diff --git a/lib/src/realtime_stub.dart b/lib/src/realtime_stub.dart index 3aab4e03..ce0b7e95 100644 --- a/lib/src/realtime_stub.dart +++ b/lib/src/realtime_stub.dart @@ -3,5 +3,5 @@ import 'client.dart'; /// Implemented in `realtime_browser.dart` and `realtime_io.dart`. RealtimeBase createRealtime(Client client) => throw UnsupportedError( - 'Cannot create a client without dart:html or dart:io.', - ); + 'Cannot create a client without dart:html or dart:io.', +); diff --git a/test/channel_test.dart b/test/channel_test.dart index 9e0e11d3..62031aec 100644 --- a/test/channel_test.dart +++ b/test/channel_test.dart @@ -13,22 +13,12 @@ void main() { }); test('returns database channel with action', () { - expect( - Channel.database('db1') - .collection('col1') - .document('doc1') - .create() - .toString(), + expect(Channel.database('db1').collection('col1').document('doc1').create().toString(), 'databases.db1.collections.col1.documents.doc1.create'); }); test('returns database channel with upsert action', () { - expect( - Channel.database('db1') - .collection('col1') - .document('doc1') - .upsert() - .toString(), + expect(Channel.database('db1').collection('col1').document('doc1').upsert().toString(), 'databases.db1.collections.col1.documents.doc1.upsert'); }); }); @@ -44,12 +34,7 @@ void main() { }); test('returns tablesdb channel with action', () { - expect( - Channel.tablesdb('db1') - .table('table1') - .row('row1') - .update() - .toString(), + expect(Channel.tablesdb('db1').table('table1').row('row1').update().toString(), 'tablesdb.db1.tables.table1.rows.row1.update'); }); }); @@ -62,16 +47,16 @@ void main() { group('bucket()', () { test('throws when bucket id is missing', () { - expect(() => Channel.bucket(''), throwsArgumentError); + expect(() => Channel.bucket(''), throwsArgumentError); }); test('returns buckets channel with specific IDs', () { - expect( - Channel.bucket('bucket1').file().toString(), 'buckets.bucket1.files'); + expect(Channel.bucket('bucket1').file().toString(), + 'buckets.bucket1.files'); }); test('returns buckets channel with action', () { - expect(Channel.bucket('bucket1').file('file1').delete().toString(), + expect(Channel.bucket('bucket1').file('file1').delete().toString(), 'buckets.bucket1.files.file1.delete'); }); }); @@ -98,30 +83,29 @@ void main() { group('teams()', () { test('throws when team id is missing', () { - expect(() => Channel.team(''), throwsArgumentError); + expect(() => Channel.team(''), throwsArgumentError); }); test('returns teams channel with specific team ID', () { - expect(Channel.team('team1').toString(), 'teams.team1'); + expect(Channel.team('team1').toString(), 'teams.team1'); }); test('returns teams channel with action', () { - expect(Channel.team('team1').create().toString(), 'teams.team1.create'); + expect(Channel.team('team1').create().toString(), 'teams.team1.create'); }); }); group('memberships()', () { test('throws when membership id is missing', () { - expect(() => Channel.membership(''), throwsArgumentError); + expect(() => Channel.membership(''), throwsArgumentError); }); test('returns memberships channel with specific membership ID', () { - expect(Channel.membership('membership1').toString(), - 'memberships.membership1'); + expect(Channel.membership('membership1').toString(), 'memberships.membership1'); }); test('returns memberships channel with action', () { - expect(Channel.membership('membership1').update().toString(), + expect(Channel.membership('membership1').update().toString(), 'memberships.membership1.update'); }); }); diff --git a/test/query_test.dart b/test/query_test.dart index db7b9214..25388fad 100644 --- a/test/query_test.dart +++ b/test/query_test.dart @@ -354,3 +354,4 @@ void main() { expect(query['method'], 'between'); }); } + diff --git a/test/services/account_test.dart b/test/services/account_test.dart index d5d61fe7..bd65aa32 100644 --- a/test/services/account_test.dart +++ b/test/services/account_test.dart @@ -24,11 +24,12 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -40,1356 +41,1540 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method( - #chunkedUpload, [path, params, paramName, idParamName, headers]), - returnValue: Response(data: {})); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Account test', () { - late MockClient client; - late Account account; + group('Account test', () { + late MockClient client; + late Account account; + + setUp(() { + client = MockClient(); + account = Account(client); + }); + + test('test method get()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.get( + ); + expect(response, isA()); - setUp(() { - client = MockClient(); - account = Account(client); - }); + }); + + test('test method create()', () async { - test('test method get()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.get(); - expect(response, isA()); - }); + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - test('test method create()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.create( - userId: '', - email: 'email@example.com', - password: 'password', - ); - expect(response, isA()); - }); - test('test method updateEmail()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateEmail( - email: 'email@example.com', - password: 'password', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - test('test method listIdentities()', () async { - final Map data = { - 'total': 5, - 'identities': [], - }; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final response = await account.create( + userId: '', + email: 'email@example.com', + password: 'password', + ); + expect(response, isA()); - final response = await account.listIdentities(); - expect(response, isA()); - }); + }); - test('test method deleteIdentity()', () async { - final data = ''; + test('test method updateEmail()', () async { - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - final response = await account.deleteIdentity( - identityId: '', - ); - }); - test('test method createJWT()', () async { - final Map data = { - 'jwt': - 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', - }; + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - final response = await account.createJWT(); - expect(response, isA()); - }); + final response = await account.updateEmail( + email: 'email@example.com', + password: 'password', + ); + expect(response, isA()); - test('test method listLogs()', () async { - final Map data = { - 'total': 5, - 'logs': [], - }; + }); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + test('test method listIdentities()', () async { - final response = await account.listLogs(); - expect(response, isA()); - }); + final Map data = { + 'total': 5, + 'identities': [],}; - test('test method updateMFA()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateMFA( - mfa: true, - ); - expect(response, isA()); - }); - test('test method createMfaAuthenticator()', () async { - final Map data = { - 'secret': '[SHARED_SECRET]', - 'uri': - 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createMfaAuthenticator( - type: enums.AuthenticatorType.totp, - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method createMFAAuthenticator()', () async { - final Map data = { - 'secret': '[SHARED_SECRET]', - 'uri': - 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createMFAAuthenticator( - type: enums.AuthenticatorType.totp, - ); - expect(response, isA()); - }); - test('test method updateMfaAuthenticator()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateMfaAuthenticator( - type: enums.AuthenticatorType.totp, - otp: '', - ); - expect(response, isA()); - }); + final response = await account.listIdentities( + ); + expect(response, isA()); - test('test method updateMFAAuthenticator()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateMFAAuthenticator( - type: enums.AuthenticatorType.totp, - otp: '', - ); - expect(response, isA()); - }); + }); - test('test method deleteMfaAuthenticator()', () async { - final data = ''; + test('test method deleteIdentity()', () async { - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + final data = ''; - final response = await account.deleteMfaAuthenticator( - type: enums.AuthenticatorType.totp, - ); - }); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - test('test method deleteMFAAuthenticator()', () async { - final data = ''; - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + final response = await account.deleteIdentity( + identityId: '', + ); + }); - final response = await account.deleteMFAAuthenticator( - type: enums.AuthenticatorType.totp, - ); - }); + test('test method createJWT()', () async { - test('test method createMfaChallenge()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'expire': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createMfaChallenge( - factor: enums.AuthenticationFactor.email, - ); - expect(response, isA()); - }); + final Map data = { + 'jwt': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c',}; - test('test method createMFAChallenge()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'expire': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createMFAChallenge( - factor: enums.AuthenticationFactor.email, - ); - expect(response, isA()); - }); - test('test method updateMfaChallenge()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateMfaChallenge( - challengeId: '', - otp: '', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - test('test method updateMFAChallenge()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateMFAChallenge( - challengeId: '', - otp: '', - ); - expect(response, isA()); - }); - test('test method listMfaFactors()', () async { - final Map data = { - 'totp': true, - 'phone': true, - 'email': true, - 'recoveryCode': true, - }; + final response = await account.createJWT( + ); + expect(response, isA()); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + }); - final response = await account.listMfaFactors(); - expect(response, isA()); - }); + test('test method listLogs()', () async { - test('test method listMFAFactors()', () async { - final Map data = { - 'totp': true, - 'phone': true, - 'email': true, - 'recoveryCode': true, - }; + final Map data = { + 'total': 5, + 'logs': [],}; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - final response = await account.listMFAFactors(); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method getMfaRecoveryCodes()', () async { - final Map data = { - 'recoveryCodes': [], - }; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final response = await account.listLogs( + ); + expect(response, isA()); - final response = await account.getMfaRecoveryCodes(); - expect(response, isA()); - }); + }); - test('test method getMFARecoveryCodes()', () async { - final Map data = { - 'recoveryCodes': [], - }; + test('test method updateMFA()', () async { - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - final response = await account.getMFARecoveryCodes(); - expect(response, isA()); - }); - test('test method createMfaRecoveryCodes()', () async { - final Map data = { - 'recoveryCodes': [], - }; + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - final response = await account.createMfaRecoveryCodes(); - expect(response, isA()); - }); + final response = await account.updateMFA( + mfa: true, + ); + expect(response, isA()); - test('test method createMFARecoveryCodes()', () async { - final Map data = { - 'recoveryCodes': [], - }; + }); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + test('test method createMfaAuthenticator()', () async { - final response = await account.createMFARecoveryCodes(); - expect(response, isA()); - }); + final Map data = { + 'secret': '[SHARED_SECRET]', + 'uri': 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite',}; - test('test method updateMfaRecoveryCodes()', () async { - final Map data = { - 'recoveryCodes': [], - }; - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - final response = await account.updateMfaRecoveryCodes(); - expect(response, isA()); - }); - test('test method updateMFARecoveryCodes()', () async { - final Map data = { - 'recoveryCodes': [], - }; + final response = await account.createMfaAuthenticator( + type: enums.AuthenticatorType.totp, + ); + expect(response, isA()); - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + }); - final response = await account.updateMFARecoveryCodes(); - expect(response, isA()); - }); + test('test method createMFAAuthenticator()', () async { - test('test method updateName()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateName( - name: '', - ); - expect(response, isA()); - }); + final Map data = { + 'secret': '[SHARED_SECRET]', + 'uri': 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite',}; - test('test method updatePassword()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updatePassword( - password: 'password', - ); - expect(response, isA()); - }); - test('test method updatePhone()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updatePhone( - phone: '+12065550100', - password: 'password', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - test('test method getPrefs()', () async { - final Map data = {}; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final response = await account.createMFAAuthenticator( + type: enums.AuthenticatorType.totp, + ); + expect(response, isA()); - final response = await account.getPrefs(); - expect(response, isA()); - }); + }); - test('test method updatePrefs()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updatePrefs( - prefs: {}, - ); - expect(response, isA()); - }); + test('test method updateMfaAuthenticator()', () async { - test('test method createRecovery()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createRecovery( - email: 'email@example.com', - url: 'https://example.com', - ); - expect(response, isA()); - }); + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - test('test method updateRecovery()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateRecovery( - userId: '', - secret: '', - password: 'password', - ); - expect(response, isA()); - }); - test('test method listSessions()', () async { - final Map data = { - 'total': 5, - 'sessions': [], - }; + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - final response = await account.listSessions(); - expect(response, isA()); - }); + final response = await account.updateMfaAuthenticator( + type: enums.AuthenticatorType.totp, + otp: '', + ); + expect(response, isA()); - test('test method deleteSessions()', () async { - final data = ''; + }); - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + test('test method updateMFAAuthenticator()', () async { - final response = await account.deleteSessions(); - }); + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - test('test method createAnonymousSession()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createAnonymousSession(); - expect(response, isA()); - }); - test('test method createEmailPasswordSession()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createEmailPasswordSession( - email: 'email@example.com', - password: 'password', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); - test('test method updateMagicURLSession()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateMagicURLSession( - userId: '', - secret: '', - ); - expect(response, isA()); - }); - test('test method createOAuth2Session()', () async { - when(client.webAuth( - argThat(isNotNull), - )).thenAnswer((_) async => 'done'); + final response = await account.updateMFAAuthenticator( + type: enums.AuthenticatorType.totp, + otp: '', + ); + expect(response, isA()); - final response = await account.createOAuth2Session( - provider: enums.OAuthProvider.amazon, - ); - expect(response, equals('done')); - }); + }); - test('test method updatePhoneSession()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updatePhoneSession( - userId: '', - secret: '', - ); - expect(response, isA()); - }); + test('test method deleteMfaAuthenticator()', () async { - test('test method createSession()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createSession( - userId: '', - secret: '', - ); - expect(response, isA()); - }); + final data = ''; - test('test method getSession()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.getSession( - sessionId: '', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - test('test method updateSession()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateSession( - sessionId: '', - ); - expect(response, isA()); - }); - test('test method deleteSession()', () async { - final data = ''; + final response = await account.deleteMfaAuthenticator( + type: enums.AuthenticatorType.totp, + ); + }); - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + test('test method deleteMFAAuthenticator()', () async { - final response = await account.deleteSession( - sessionId: '', - ); - }); + final data = ''; - test('test method updateStatus()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateStatus(); - expect(response, isA()); - }); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - test('test method createPushTarget()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'Apple iPhone 12', - 'userId': '259125845563242502', - 'providerType': 'email', - 'identifier': 'token', - 'expired': true, - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createPushTarget( - targetId: '', - identifier: '', - ); - expect(response, isA()); - }); - test('test method updatePushTarget()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'Apple iPhone 12', - 'userId': '259125845563242502', - 'providerType': 'email', - 'identifier': 'token', - 'expired': true, - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updatePushTarget( - targetId: '', - identifier: '', - ); - expect(response, isA()); - }); + final response = await account.deleteMFAAuthenticator( + type: enums.AuthenticatorType.totp, + ); + }); + + test('test method createMfaChallenge()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'expire': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createMfaChallenge( + factor: enums.AuthenticationFactor.email, + ); + expect(response, isA()); + + }); + + test('test method createMFAChallenge()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'expire': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createMFAChallenge( + factor: enums.AuthenticationFactor.email, + ); + expect(response, isA()); + + }); + + test('test method updateMfaChallenge()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - test('test method deletePushTarget()', () async { - final data = ''; - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); - final response = await account.deletePushTarget( - targetId: '', - ); - }); - test('test method createEmailToken()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createEmailToken( - userId: '', - email: 'email@example.com', - ); - expect(response, isA()); - }); + final response = await account.updateMfaChallenge( + challengeId: '', + otp: '', + ); + expect(response, isA()); - test('test method createMagicURLToken()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createMagicURLToken( - userId: '', - email: 'email@example.com', - ); - expect(response, isA()); - }); + }); - test('test method createOAuth2Token()', () async { - when(client.webAuth( - argThat(isNotNull), - )).thenAnswer((_) async => 'done'); + test('test method updateMFAChallenge()', () async { - final response = await account.createOAuth2Token( - provider: enums.OAuthProvider.amazon, - ); - expect(response, equals('done')); - }); + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - test('test method createPhoneToken()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createPhoneToken( - userId: '', - phone: '+12065550100', - ); - expect(response, isA()); - }); - test('test method createEmailVerification()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createEmailVerification( - url: 'https://example.com', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); - test('test method createVerification()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createVerification( - url: 'https://example.com', - ); - expect(response, isA()); - }); - test('test method updateEmailVerification()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateEmailVerification( - userId: '', - secret: '', - ); - expect(response, isA()); - }); + final response = await account.updateMFAChallenge( + challengeId: '', + otp: '', + ); + expect(response, isA()); - test('test method updateVerification()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateVerification( - userId: '', - secret: '', - ); - expect(response, isA()); - }); + }); - test('test method createPhoneVerification()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createPhoneVerification(); - expect(response, isA()); - }); + test('test method listMfaFactors()', () async { + + final Map data = { + 'totp': true, + 'phone': true, + 'email': true, + 'recoveryCode': true,}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.listMfaFactors( + ); + expect(response, isA()); + + }); + + test('test method listMFAFactors()', () async { + + final Map data = { + 'totp': true, + 'phone': true, + 'email': true, + 'recoveryCode': true,}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.listMFAFactors( + ); + expect(response, isA()); + + }); + + test('test method getMfaRecoveryCodes()', () async { + + final Map data = { + 'recoveryCodes': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.getMfaRecoveryCodes( + ); + expect(response, isA()); + + }); + + test('test method getMFARecoveryCodes()', () async { + + final Map data = { + 'recoveryCodes': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.getMFARecoveryCodes( + ); + expect(response, isA()); + + }); + + test('test method createMfaRecoveryCodes()', () async { + + final Map data = { + 'recoveryCodes': [],}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createMfaRecoveryCodes( + ); + expect(response, isA()); + + }); + + test('test method createMFARecoveryCodes()', () async { + + final Map data = { + 'recoveryCodes': [],}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createMFARecoveryCodes( + ); + expect(response, isA()); + + }); + + test('test method updateMfaRecoveryCodes()', () async { + + final Map data = { + 'recoveryCodes': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateMfaRecoveryCodes( + ); + expect(response, isA()); + + }); + + test('test method updateMFARecoveryCodes()', () async { + + final Map data = { + 'recoveryCodes': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateMFARecoveryCodes( + ); + expect(response, isA()); + + }); + + test('test method updateName()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateName( + name: '', + ); + expect(response, isA()); + + }); + + test('test method updatePassword()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updatePassword( + password: 'password', + ); + expect(response, isA()); + + }); + + test('test method updatePhone()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updatePhone( + phone: '+12065550100', + password: 'password', + ); + expect(response, isA()); + + }); + + test('test method getPrefs()', () async { + + final Map data = {}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.getPrefs( + ); + expect(response, isA()); + + }); + + test('test method updatePrefs()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updatePrefs( + prefs: {}, + ); + expect(response, isA()); + + }); + + test('test method createRecovery()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createRecovery( + email: 'email@example.com', + url: 'https://example.com', + ); + expect(response, isA()); + + }); + + test('test method updateRecovery()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateRecovery( + userId: '', + secret: '', + password: 'password', + ); + expect(response, isA()); + + }); + + test('test method listSessions()', () async { + + final Map data = { + 'total': 5, + 'sessions': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.listSessions( + ); + expect(response, isA()); + + }); + + test('test method deleteSessions()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.deleteSessions( + ); + }); + + test('test method createAnonymousSession()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createAnonymousSession( + ); + expect(response, isA()); + + }); + + test('test method createEmailPasswordSession()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createEmailPasswordSession( + email: 'email@example.com', + password: 'password', + ); + expect(response, isA()); + + }); + + test('test method updateMagicURLSession()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateMagicURLSession( + userId: '', + secret: '', + ); + expect(response, isA()); + + }); + + test('test method createOAuth2Session()', () async { + + + when(client.webAuth( + argThat(isNotNull), + )).thenAnswer((_) async => 'done'); + + + final response = await account.createOAuth2Session( + provider: enums.OAuthProvider.amazon, + ); + expect(response, equals('done')); + + }); + + test('test method updatePhoneSession()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updatePhoneSession( + userId: '', + secret: '', + ); + expect(response, isA()); + + }); + + test('test method createSession()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createSession( + userId: '', + secret: '', + ); + expect(response, isA()); + + }); + + test('test method getSession()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.getSession( + sessionId: '', + ); + expect(response, isA()); + + }); + + test('test method updateSession()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateSession( + sessionId: '', + ); + expect(response, isA()); + + }); + + test('test method deleteSession()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.deleteSession( + sessionId: '', + ); + }); + + test('test method updateStatus()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateStatus( + ); + expect(response, isA()); + + }); + + test('test method createPushTarget()', () async { + + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Apple iPhone 12', + 'userId': '259125845563242502', + 'providerType': 'email', + 'identifier': 'token', + 'expired': true,}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createPushTarget( + targetId: '', + identifier: '', + ); + expect(response, isA()); + + }); + + test('test method updatePushTarget()', () async { + + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Apple iPhone 12', + 'userId': '259125845563242502', + 'providerType': 'email', + 'identifier': 'token', + 'expired': true,}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updatePushTarget( + targetId: '', + identifier: '', + ); + expect(response, isA()); + + }); + + test('test method deletePushTarget()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.deletePushTarget( + targetId: '', + ); + }); + + test('test method createEmailToken()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createEmailToken( + userId: '', + email: 'email@example.com', + ); + expect(response, isA()); + + }); + + test('test method createMagicURLToken()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createMagicURLToken( + userId: '', + email: 'email@example.com', + ); + expect(response, isA()); + + }); + + test('test method createOAuth2Token()', () async { + + + when(client.webAuth( + argThat(isNotNull), + )).thenAnswer((_) async => 'done'); + + + final response = await account.createOAuth2Token( + provider: enums.OAuthProvider.amazon, + ); + expect(response, equals('done')); + + }); + + test('test method createPhoneToken()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createPhoneToken( + userId: '', + phone: '+12065550100', + ); + expect(response, isA()); + + }); + + test('test method createEmailVerification()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createEmailVerification( + url: 'https://example.com', + ); + expect(response, isA()); + + }); + + test('test method createVerification()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createVerification( + url: 'https://example.com', + ); + expect(response, isA()); + + }); + + test('test method updateEmailVerification()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateEmailVerification( + userId: '', + secret: '', + ); + expect(response, isA()); + + }); + + test('test method updateVerification()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateVerification( + userId: '', + secret: '', + ); + expect(response, isA()); + + }); + + test('test method createPhoneVerification()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createPhoneVerification( + ); + expect(response, isA()); + + }); + + test('test method updatePhoneVerification()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updatePhoneVerification( + userId: '', + secret: '', + ); + expect(response, isA()); + + }); - test('test method updatePhoneVerification()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updatePhoneVerification( - userId: '', - secret: '', - ); - expect(response, isA()); }); - }); } diff --git a/test/services/avatars_test.dart b/test/services/avatars_test.dart index 8d2c48fb..4bdb434d 100644 --- a/test/services/avatars_test.dart +++ b/test/services/avatars_test.dart @@ -24,11 +24,12 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -40,123 +41,138 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method( - #chunkedUpload, [path, params, paramName, idParamName, headers]), - returnValue: Response(data: {})); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Avatars test', () { - late MockClient client; - late Avatars avatars; + group('Avatars test', () { + late MockClient client; + late Avatars avatars; - setUp(() { - client = MockClient(); - avatars = Avatars(client); - }); + setUp(() { + client = MockClient(); + avatars = Avatars(client); + }); - test('test method getBrowser()', () async { - final Uint8List data = Uint8List.fromList([]); + test('test method getBrowser()', () async { +final Uint8List data = Uint8List.fromList([]); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await avatars.getBrowser( - code: enums.Browser.avantBrowser, - ); - expect(response, isA()); - }); - test('test method getCreditCard()', () async { - final Uint8List data = Uint8List.fromList([]); + final response = await avatars.getBrowser( + code: enums.Browser.avantBrowser, + ); + expect(response, isA()); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + }); - final response = await avatars.getCreditCard( - code: enums.CreditCard.americanExpress, - ); - expect(response, isA()); - }); + test('test method getCreditCard()', () async { +final Uint8List data = Uint8List.fromList([]); - test('test method getFavicon()', () async { - final Uint8List data = Uint8List.fromList([]); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - final response = await avatars.getFavicon( - url: 'https://example.com', - ); - expect(response, isA()); - }); + final response = await avatars.getCreditCard( + code: enums.CreditCard.americanExpress, + ); + expect(response, isA()); - test('test method getFlag()', () async { - final Uint8List data = Uint8List.fromList([]); + }); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + test('test method getFavicon()', () async { +final Uint8List data = Uint8List.fromList([]); - final response = await avatars.getFlag( - code: enums.Flag.afghanistan, - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method getImage()', () async { - final Uint8List data = Uint8List.fromList([]); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final response = await avatars.getFavicon( + url: 'https://example.com', + ); + expect(response, isA()); - final response = await avatars.getImage( - url: 'https://example.com', - ); - expect(response, isA()); - }); + }); - test('test method getInitials()', () async { - final Uint8List data = Uint8List.fromList([]); + test('test method getFlag()', () async { +final Uint8List data = Uint8List.fromList([]); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await avatars.getInitials(); - expect(response, isA()); - }); - test('test method getQR()', () async { - final Uint8List data = Uint8List.fromList([]); + final response = await avatars.getFlag( + code: enums.Flag.afghanistan, + ); + expect(response, isA()); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + }); + + test('test method getImage()', () async { +final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await avatars.getImage( + url: 'https://example.com', + ); + expect(response, isA()); + + }); + + test('test method getInitials()', () async { +final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await avatars.getInitials( + ); + expect(response, isA()); + + }); + + test('test method getQR()', () async { +final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await avatars.getQR( + text: '', + ); + expect(response, isA()); + + }); + + test('test method getScreenshot()', () async { +final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await avatars.getQR( - text: '', - ); - expect(response, isA()); - }); - test('test method getScreenshot()', () async { - final Uint8List data = Uint8List.fromList([]); + final response = await avatars.getScreenshot( + url: 'https://example.com', + ); + expect(response, isA()); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + }); - final response = await avatars.getScreenshot( - url: 'https://example.com', - ); - expect(response, isA()); }); - }); } diff --git a/test/services/databases_test.dart b/test/services/databases_test.dart index a3807093..a4b0a6cc 100644 --- a/test/services/databases_test.dart +++ b/test/services/databases_test.dart @@ -24,11 +24,12 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -40,297 +41,337 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method( - #chunkedUpload, [path, params, paramName, idParamName, headers]), - returnValue: Response(data: {})); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Databases test', () { - late MockClient client; - late Databases databases; + group('Databases test', () { + late MockClient client; + late Databases databases; - setUp(() { - client = MockClient(); - databases = Databases(client); - }); + setUp(() { + client = MockClient(); + databases = Databases(client); + }); - test('test method listTransactions()', () async { - final Map data = { - 'total': 5, - 'transactions': [], - }; + test('test method listTransactions()', () async { - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final Map data = { + 'total': 5, + 'transactions': [],}; - final response = await databases.listTransactions(); - expect(response, isA()); - }); - test('test method createTransaction()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await databases.createTransaction(); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method getTransaction()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await databases.getTransaction( - transactionId: '', - ); - expect(response, isA()); - }); - test('test method updateTransaction()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await databases.updateTransaction( - transactionId: '', - ); - expect(response, isA()); - }); + final response = await databases.listTransactions( + ); + expect(response, isA()); - test('test method deleteTransaction()', () async { - final data = ''; + }); - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + test('test method createTransaction()', () async { - final response = await databases.deleteTransaction( - transactionId: '', - ); - }); + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - test('test method createOperations()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await databases.createOperations( - transactionId: '', - ); - expect(response, isA()); - }); - test('test method listDocuments()', () async { - final Map data = { - 'total': 5, - 'documents': [], - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await databases.listDocuments( - databaseId: '', - collectionId: '', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - test('test method createDocument()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await databases.createDocument( - databaseId: '', - collectionId: '', - documentId: '', - data: {}, - ); - expect(response, isA()); - }); - test('test method getDocument()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await databases.getDocument( - databaseId: '', - collectionId: '', - documentId: '', - ); - expect(response, isA()); - }); + final response = await databases.createTransaction( + ); + expect(response, isA()); - test('test method upsertDocument()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await databases.upsertDocument( - databaseId: '', - collectionId: '', - documentId: '', - ); - expect(response, isA()); - }); + }); - test('test method updateDocument()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await databases.updateDocument( - databaseId: '', - collectionId: '', - documentId: '', - ); - expect(response, isA()); - }); + test('test method getTransaction()', () async { - test('test method deleteDocument()', () async { - final data = ''; + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - final response = await databases.deleteDocument( - databaseId: '', - collectionId: '', - documentId: '', - ); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method decrementDocumentAttribute()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await databases.decrementDocumentAttribute( - databaseId: '', - collectionId: '', - documentId: '', - attribute: '', - ); - expect(response, isA()); - }); - test('test method incrementDocumentAttribute()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await databases.incrementDocumentAttribute( - databaseId: '', - collectionId: '', - documentId: '', - attribute: '', - ); - expect(response, isA()); + final response = await databases.getTransaction( + transactionId: '', + ); + expect(response, isA()); + + }); + + test('test method updateTransaction()', () async { + + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.updateTransaction( + transactionId: '', + ); + expect(response, isA()); + + }); + + test('test method deleteTransaction()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.deleteTransaction( + transactionId: '', + ); + }); + + test('test method createOperations()', () async { + + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.createOperations( + transactionId: '', + ); + expect(response, isA()); + + }); + + test('test method listDocuments()', () async { + + final Map data = { + 'total': 5, + 'documents': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.listDocuments( + databaseId: '', + collectionId: '', + ); + expect(response, isA()); + + }); + + test('test method createDocument()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.createDocument( + databaseId: '', + collectionId: '', + documentId: '', + data: {}, + ); + expect(response, isA()); + + }); + + test('test method getDocument()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.getDocument( + databaseId: '', + collectionId: '', + documentId: '', + ); + expect(response, isA()); + + }); + + test('test method upsertDocument()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.upsertDocument( + databaseId: '', + collectionId: '', + documentId: '', + ); + expect(response, isA()); + + }); + + test('test method updateDocument()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.updateDocument( + databaseId: '', + collectionId: '', + documentId: '', + ); + expect(response, isA()); + + }); + + test('test method deleteDocument()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.deleteDocument( + databaseId: '', + collectionId: '', + documentId: '', + ); + }); + + test('test method decrementDocumentAttribute()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.decrementDocumentAttribute( + databaseId: '', + collectionId: '', + documentId: '', + attribute: '', + ); + expect(response, isA()); + + }); + + test('test method incrementDocumentAttribute()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.incrementDocumentAttribute( + databaseId: '', + collectionId: '', + documentId: '', + attribute: '', + ); + expect(response, isA()); + + }); + }); - }); } diff --git a/test/services/functions_test.dart b/test/services/functions_test.dart index c6e50a50..9b0d046f 100644 --- a/test/services/functions_test.dart +++ b/test/services/functions_test.dart @@ -24,11 +24,12 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -40,100 +41,107 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method( - #chunkedUpload, [path, params, paramName, idParamName, headers]), - returnValue: Response(data: {})); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Functions test', () { - late MockClient client; - late Functions functions; + group('Functions test', () { + late MockClient client; + late Functions functions; - setUp(() { - client = MockClient(); - functions = Functions(client); - }); + setUp(() { + client = MockClient(); + functions = Functions(client); + }); - test('test method listExecutions()', () async { - final Map data = { - 'total': 5, - 'executions': [], - }; + test('test method listExecutions()', () async { - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final Map data = { + 'total': 5, + 'executions': [],}; - final response = await functions.listExecutions( - functionId: '', - ); - expect(response, isA()); - }); - test('test method createExecution()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'functionId': '5e5ea6g16897e', - 'deploymentId': '5e5ea5c16897e', - 'trigger': 'http', - 'status': 'processing', - 'requestMethod': 'GET', - 'requestPath': '/articles?id=5', - 'requestHeaders': [], - 'responseStatusCode': 200, - 'responseBody': '', - 'responseHeaders': [], - 'logs': '', - 'errors': '', - 'duration': 0.4, - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await functions.createExecution( - functionId: '', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await functions.listExecutions( + functionId: '', + ); + expect(response, isA()); + + }); + + test('test method createExecution()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'functionId': '5e5ea6g16897e', + 'deploymentId': '5e5ea5c16897e', + 'trigger': 'http', + 'status': 'processing', + 'requestMethod': 'GET', + 'requestPath': '/articles?id=5', + 'requestHeaders': [], + 'responseStatusCode': 200, + 'responseBody': '', + 'responseHeaders': [], + 'logs': '', + 'errors': '', + 'duration': 0.4,}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await functions.createExecution( + functionId: '', + ); + expect(response, isA()); + + }); + + test('test method getExecution()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'functionId': '5e5ea6g16897e', + 'deploymentId': '5e5ea5c16897e', + 'trigger': 'http', + 'status': 'processing', + 'requestMethod': 'GET', + 'requestPath': '/articles?id=5', + 'requestHeaders': [], + 'responseStatusCode': 200, + 'responseBody': '', + 'responseHeaders': [], + 'logs': '', + 'errors': '', + 'duration': 0.4,}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await functions.getExecution( + functionId: '', + executionId: '', + ); + expect(response, isA()); + + }); - test('test method getExecution()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'functionId': '5e5ea6g16897e', - 'deploymentId': '5e5ea5c16897e', - 'trigger': 'http', - 'status': 'processing', - 'requestMethod': 'GET', - 'requestPath': '/articles?id=5', - 'requestHeaders': [], - 'responseStatusCode': 200, - 'responseBody': '', - 'responseHeaders': [], - 'logs': '', - 'errors': '', - 'duration': 0.4, - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await functions.getExecution( - functionId: '', - executionId: '', - ); - expect(response, isA()); }); - }); } diff --git a/test/services/graphql_test.dart b/test/services/graphql_test.dart index 84b7de1c..c548e414 100644 --- a/test/services/graphql_test.dart +++ b/test/services/graphql_test.dart @@ -24,11 +24,12 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -40,45 +41,47 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method( - #chunkedUpload, [path, params, paramName, idParamName, headers]), - returnValue: Response(data: {})); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Graphql test', () { - late MockClient client; - late Graphql graphql; + group('Graphql test', () { + late MockClient client; + late Graphql graphql; - setUp(() { - client = MockClient(); - graphql = Graphql(client); - }); + setUp(() { + client = MockClient(); + graphql = Graphql(client); + }); - test('test method query()', () async { - final data = ''; + test('test method query()', () async { - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + final data = ''; - final response = await graphql.query( - query: {}, - ); - }); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await graphql.query( + query: {}, + ); + }); + + test('test method mutation()', () async { + + final data = ''; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - test('test method mutation()', () async { - final data = ''; - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + final response = await graphql.mutation( + query: {}, + ); + }); - final response = await graphql.mutation( - query: {}, - ); }); - }); } diff --git a/test/services/locale_test.dart b/test/services/locale_test.dart index f9f6489d..42faaf72 100644 --- a/test/services/locale_test.dart +++ b/test/services/locale_test.dart @@ -24,11 +24,12 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -40,138 +41,168 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method( - #chunkedUpload, [path, params, paramName, idParamName, headers]), - returnValue: Response(data: {})); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Locale test', () { - late MockClient client; - late Locale locale; + group('Locale test', () { + late MockClient client; + late Locale locale; - setUp(() { - client = MockClient(); - locale = Locale(client); - }); + setUp(() { + client = MockClient(); + locale = Locale(client); + }); - test('test method get()', () async { - final Map data = { - 'ip': '127.0.0.1', - 'countryCode': 'US', - 'country': 'United States', - 'continentCode': 'NA', - 'continent': 'North America', - 'eu': true, - 'currency': 'USD', - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await locale.get(); - expect(response, isA()); - }); + test('test method get()', () async { - test('test method listCodes()', () async { - final Map data = { - 'total': 5, - 'localeCodes': [], - }; + final Map data = { + 'ip': '127.0.0.1', + 'countryCode': 'US', + 'country': 'United States', + 'continentCode': 'NA', + 'continent': 'North America', + 'eu': true, + 'currency': 'USD',}; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - final response = await locale.listCodes(); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method listContinents()', () async { - final Map data = { - 'total': 5, - 'continents': [], - }; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final response = await locale.get( + ); + expect(response, isA()); - final response = await locale.listContinents(); - expect(response, isA()); - }); + }); - test('test method listCountries()', () async { - final Map data = { - 'total': 5, - 'countries': [], - }; + test('test method listCodes()', () async { - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final Map data = { + 'total': 5, + 'localeCodes': [],}; - final response = await locale.listCountries(); - expect(response, isA()); - }); - test('test method listCountriesEU()', () async { - final Map data = { - 'total': 5, - 'countries': [], - }; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - final response = await locale.listCountriesEU(); - expect(response, isA()); - }); + final response = await locale.listCodes( + ); + expect(response, isA()); - test('test method listCountriesPhones()', () async { - final Map data = { - 'total': 5, - 'phones': [], - }; + }); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + test('test method listContinents()', () async { - final response = await locale.listCountriesPhones(); - expect(response, isA()); - }); + final Map data = { + 'total': 5, + 'continents': [],}; - test('test method listCurrencies()', () async { - final Map data = { - 'total': 5, - 'currencies': [], - }; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await locale.listContinents( + ); + expect(response, isA()); + + }); + + test('test method listCountries()', () async { + + final Map data = { + 'total': 5, + 'countries': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await locale.listCountries( + ); + expect(response, isA()); + + }); + + test('test method listCountriesEU()', () async { + + final Map data = { + 'total': 5, + 'countries': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await locale.listCountriesEU( + ); + expect(response, isA()); + + }); + + test('test method listCountriesPhones()', () async { + + final Map data = { + 'total': 5, + 'phones': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await locale.listCountriesPhones( + ); + expect(response, isA()); + + }); + + test('test method listCurrencies()', () async { + + final Map data = { + 'total': 5, + 'currencies': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await locale.listCurrencies( + ); + expect(response, isA()); + + }); + + test('test method listLanguages()', () async { + + final Map data = { + 'total': 5, + 'languages': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await locale.listCurrencies(); - expect(response, isA()); - }); - test('test method listLanguages()', () async { - final Map data = { - 'total': 5, - 'languages': [], - }; + final response = await locale.listLanguages( + ); + expect(response, isA()); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + }); - final response = await locale.listLanguages(); - expect(response, isA()); }); - }); } diff --git a/test/services/messaging_test.dart b/test/services/messaging_test.dart index 0c938eff..5899ace3 100644 --- a/test/services/messaging_test.dart +++ b/test/services/messaging_test.dart @@ -24,11 +24,12 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -40,68 +41,71 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method( - #chunkedUpload, [path, params, paramName, idParamName, headers]), - returnValue: Response(data: {})); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Messaging test', () { - late MockClient client; - late Messaging messaging; + group('Messaging test', () { + late MockClient client; + late Messaging messaging; - setUp(() { - client = MockClient(); - messaging = Messaging(client); - }); + setUp(() { + client = MockClient(); + messaging = Messaging(client); + }); - test('test method createSubscriber()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'targetId': '259125845563242502', - 'target': { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'Apple iPhone 12', - 'userId': '259125845563242502', - 'providerType': 'email', - 'identifier': 'token', - 'expired': true, - }, - 'userId': '5e5ea5c16897e', - 'userName': 'Aegon Targaryen', - 'topicId': '259125845563242502', - 'providerType': 'email', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await messaging.createSubscriber( - topicId: '', - subscriberId: '', - targetId: '', - ); - expect(response, isA()); - }); + test('test method createSubscriber()', () async { + + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'targetId': '259125845563242502', + 'target': { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Apple iPhone 12', + 'userId': '259125845563242502', + 'providerType': 'email', + 'identifier': 'token', + 'expired': true, + }, + 'userId': '5e5ea5c16897e', + 'userName': 'Aegon Targaryen', + 'topicId': '259125845563242502', + 'providerType': 'email',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.createSubscriber( + topicId: '', + subscriberId: '', + targetId: '', + ); + expect(response, isA()); + + }); + + test('test method deleteSubscriber()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - test('test method deleteSubscriber()', () async { - final data = ''; - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + final response = await messaging.deleteSubscriber( + topicId: '', + subscriberId: '', + ); + }); - final response = await messaging.deleteSubscriber( - topicId: '', - subscriberId: '', - ); }); - }); } diff --git a/test/services/presences_test.dart b/test/services/presences_test.dart index 7fed0439..7b99675f 100644 --- a/test/services/presences_test.dart +++ b/test/services/presences_test.dart @@ -24,11 +24,12 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -40,108 +41,121 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method( - #chunkedUpload, [path, params, paramName, idParamName, headers]), - returnValue: Response(data: {})); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Presences test', () { - late MockClient client; - late Presences presences; + group('Presences test', () { + late MockClient client; + late Presences presences; - setUp(() { - client = MockClient(); - presences = Presences(client); - }); + setUp(() { + client = MockClient(); + presences = Presences(client); + }); - test('test method list()', () async { - final Map data = { - 'total': 5, - 'presences': [], - }; + test('test method list()', () async { - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final Map data = { + 'total': 5, + 'presences': [],}; - final response = await presences.list(); - expect(response, isA()); - }); - test('test method get()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'userId': '674af8f3e12a5f9ac0be', - 'source': 'HTTP', - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await presences.get( - presenceId: '', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method upsert()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'userId': '674af8f3e12a5f9ac0be', - 'source': 'HTTP', - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await presences.upsert( - presenceId: '', - status: '', - ); - expect(response, isA()); - }); - test('test method update()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'userId': '674af8f3e12a5f9ac0be', - 'source': 'HTTP', - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await presences.update( - presenceId: '', - ); - expect(response, isA()); - }); + final response = await presences.list( + ); + expect(response, isA()); + + }); + + test('test method get()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'userId': '674af8f3e12a5f9ac0be', + 'source': 'HTTP',}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await presences.get( + presenceId: '', + ); + expect(response, isA()); + + }); + + test('test method upsert()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'userId': '674af8f3e12a5f9ac0be', + 'source': 'HTTP',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await presences.upsert( + presenceId: '', + status: '', + ); + expect(response, isA()); + + }); + + test('test method update()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'userId': '674af8f3e12a5f9ac0be', + 'source': 'HTTP',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await presences.update( + presenceId: '', + ); + expect(response, isA()); + + }); + + test('test method delete()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - test('test method delete()', () async { - final data = ''; - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + final response = await presences.delete( + presenceId: '', + ); + }); - final response = await presences.delete( - presenceId: '', - ); }); - }); } diff --git a/test/services/storage_test.dart b/test/services/storage_test.dart index 55a42f94..2390bfdd 100644 --- a/test/services/storage_test.dart +++ b/test/services/storage_test.dart @@ -24,11 +24,12 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -40,184 +41,202 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method( - #chunkedUpload, [path, params, paramName, idParamName, headers]), - returnValue: Response(data: {})); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Storage test', () { - late MockClient client; - late Storage storage; + group('Storage test', () { + late MockClient client; + late Storage storage; + + setUp(() { + client = MockClient(); + storage = Storage(client); + }); + + test('test method listFiles()', () async { + + final Map data = { + 'total': 5, + 'files': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await storage.listFiles( + bucketId: '', + ); + expect(response, isA()); + + }); + + test('test method createFile()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + 'bucketId': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'name': 'Pink.png', + 'signature': '5d529fd02b544198ae075bd57c1762bb', + 'mimeType': 'image/png', + 'sizeOriginal': 17890, + 'sizeActual': 12345, + 'chunksTotal': 17890, + 'chunksUploaded': 17890, + 'encryption': true, + 'compression': 'gzip',}; + - setUp(() { - client = MockClient(); - storage = Storage(client); - }); + when(client.chunkedUpload( + path: argThat(isNotNull), + params: argThat(isNotNull), + paramName: argThat(isNotNull), + idParamName: argThat(isNotNull), + headers: argThat(isNotNull), + )).thenAnswer((_) async => Response(data: data)); - test('test method listFiles()', () async { - final Map data = { - 'total': 5, - 'files': [], - }; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final response = await storage.createFile( + bucketId: '', + fileId: '', + file: InputFile.fromPath(path: './image.png'), + ); + expect(response, isA()); + + }); - final response = await storage.listFiles( - bucketId: '', - ); - expect(response, isA()); - }); + test('test method getFile()', () async { - test('test method createFile()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - 'bucketId': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'name': 'Pink.png', - 'signature': '5d529fd02b544198ae075bd57c1762bb', - 'mimeType': 'image/png', - 'sizeOriginal': 17890, - 'sizeActual': 12345, - 'chunksTotal': 17890, - 'chunksUploaded': 17890, - 'encryption': true, - 'compression': 'gzip', - }; - - when(client.chunkedUpload( - path: argThat(isNotNull), - params: argThat(isNotNull), - paramName: argThat(isNotNull), - idParamName: argThat(isNotNull), - headers: argThat(isNotNull), - )).thenAnswer((_) async => Response(data: data)); - - final response = await storage.createFile( - bucketId: '', - fileId: '', - file: InputFile.fromPath(path: './image.png'), - ); - expect(response, isA()); - }); + final Map data = { + '\$id': '5e5ea5c16897e', + 'bucketId': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'name': 'Pink.png', + 'signature': '5d529fd02b544198ae075bd57c1762bb', + 'mimeType': 'image/png', + 'sizeOriginal': 17890, + 'sizeActual': 12345, + 'chunksTotal': 17890, + 'chunksUploaded': 17890, + 'encryption': true, + 'compression': 'gzip',}; - test('test method getFile()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - 'bucketId': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'name': 'Pink.png', - 'signature': '5d529fd02b544198ae075bd57c1762bb', - 'mimeType': 'image/png', - 'sizeOriginal': 17890, - 'sizeActual': 12345, - 'chunksTotal': 17890, - 'chunksUploaded': 17890, - 'encryption': true, - 'compression': 'gzip', - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await storage.getFile( - bucketId: '', - fileId: '', - ); - expect(response, isA()); - }); - test('test method updateFile()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - 'bucketId': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'name': 'Pink.png', - 'signature': '5d529fd02b544198ae075bd57c1762bb', - 'mimeType': 'image/png', - 'sizeOriginal': 17890, - 'sizeActual': 12345, - 'chunksTotal': 17890, - 'chunksUploaded': 17890, - 'encryption': true, - 'compression': 'gzip', - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await storage.updateFile( - bucketId: '', - fileId: '', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method deleteFile()', () async { - final data = ''; - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + final response = await storage.getFile( + bucketId: '', + fileId: '', + ); + expect(response, isA()); - final response = await storage.deleteFile( - bucketId: '', - fileId: '', - ); - }); + }); - test('test method getFileDownload()', () async { - final Uint8List data = Uint8List.fromList([]); + test('test method updateFile()', () async { - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final Map data = { + '\$id': '5e5ea5c16897e', + 'bucketId': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'name': 'Pink.png', + 'signature': '5d529fd02b544198ae075bd57c1762bb', + 'mimeType': 'image/png', + 'sizeOriginal': 17890, + 'sizeActual': 12345, + 'chunksTotal': 17890, + 'chunksUploaded': 17890, + 'encryption': true, + 'compression': 'gzip',}; - final response = await storage.getFileDownload( - bucketId: '', - fileId: '', - ); - expect(response, isA()); - }); - test('test method getFilePreview()', () async { - final Uint8List data = Uint8List.fromList([]); + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - final response = await storage.getFilePreview( - bucketId: '', - fileId: '', - ); - expect(response, isA()); - }); + final response = await storage.updateFile( + bucketId: '', + fileId: '', + ); + expect(response, isA()); + + }); + + test('test method deleteFile()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await storage.deleteFile( + bucketId: '', + fileId: '', + ); + }); + + test('test method getFileDownload()', () async { +final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await storage.getFileDownload( + bucketId: '', + fileId: '', + ); + expect(response, isA()); + + }); + + test('test method getFilePreview()', () async { +final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await storage.getFilePreview( + bucketId: '', + fileId: '', + ); + expect(response, isA()); + + }); + + test('test method getFileView()', () async { +final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + - test('test method getFileView()', () async { - final Uint8List data = Uint8List.fromList([]); + final response = await storage.getFileView( + bucketId: '', + fileId: '', + ); + expect(response, isA()); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + }); - final response = await storage.getFileView( - bucketId: '', - fileId: '', - ); - expect(response, isA()); }); - }); } diff --git a/test/services/tables_db_test.dart b/test/services/tables_db_test.dart index f318cad2..5219d2bf 100644 --- a/test/services/tables_db_test.dart +++ b/test/services/tables_db_test.dart @@ -24,11 +24,12 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -40,297 +41,337 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method( - #chunkedUpload, [path, params, paramName, idParamName, headers]), - returnValue: Response(data: {})); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('TablesDB test', () { - late MockClient client; - late TablesDB tablesDB; + group('TablesDB test', () { + late MockClient client; + late TablesDB tablesDB; - setUp(() { - client = MockClient(); - tablesDB = TablesDB(client); - }); + setUp(() { + client = MockClient(); + tablesDB = TablesDB(client); + }); - test('test method listTransactions()', () async { - final Map data = { - 'total': 5, - 'transactions': [], - }; + test('test method listTransactions()', () async { - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final Map data = { + 'total': 5, + 'transactions': [],}; - final response = await tablesDB.listTransactions(); - expect(response, isA()); - }); - test('test method createTransaction()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.createTransaction(); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method getTransaction()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.getTransaction( - transactionId: '', - ); - expect(response, isA()); - }); - test('test method updateTransaction()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.updateTransaction( - transactionId: '', - ); - expect(response, isA()); - }); + final response = await tablesDB.listTransactions( + ); + expect(response, isA()); - test('test method deleteTransaction()', () async { - final data = ''; + }); - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + test('test method createTransaction()', () async { - final response = await tablesDB.deleteTransaction( - transactionId: '', - ); - }); + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - test('test method createOperations()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.createOperations( - transactionId: '', - ); - expect(response, isA()); - }); - test('test method listRows()', () async { - final Map data = { - 'total': 5, - 'rows': [], - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.listRows( - databaseId: '', - tableId: '', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - test('test method createRow()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.createRow( - databaseId: '', - tableId: '', - rowId: '', - data: {}, - ); - expect(response, isA()); - }); - test('test method getRow()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.getRow( - databaseId: '', - tableId: '', - rowId: '', - ); - expect(response, isA()); - }); + final response = await tablesDB.createTransaction( + ); + expect(response, isA()); - test('test method upsertRow()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.upsertRow( - databaseId: '', - tableId: '', - rowId: '', - ); - expect(response, isA()); - }); + }); - test('test method updateRow()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.updateRow( - databaseId: '', - tableId: '', - rowId: '', - ); - expect(response, isA()); - }); + test('test method getTransaction()', () async { - test('test method deleteRow()', () async { - final data = ''; + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - final response = await tablesDB.deleteRow( - databaseId: '', - tableId: '', - rowId: '', - ); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method decrementRowColumn()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.decrementRowColumn( - databaseId: '', - tableId: '', - rowId: '', - column: '', - ); - expect(response, isA()); - }); - test('test method incrementRowColumn()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.incrementRowColumn( - databaseId: '', - tableId: '', - rowId: '', - column: '', - ); - expect(response, isA()); + final response = await tablesDB.getTransaction( + transactionId: '', + ); + expect(response, isA()); + + }); + + test('test method updateTransaction()', () async { + + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.updateTransaction( + transactionId: '', + ); + expect(response, isA()); + + }); + + test('test method deleteTransaction()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.deleteTransaction( + transactionId: '', + ); + }); + + test('test method createOperations()', () async { + + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.createOperations( + transactionId: '', + ); + expect(response, isA()); + + }); + + test('test method listRows()', () async { + + final Map data = { + 'total': 5, + 'rows': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.listRows( + databaseId: '', + tableId: '', + ); + expect(response, isA()); + + }); + + test('test method createRow()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.createRow( + databaseId: '', + tableId: '', + rowId: '', + data: {}, + ); + expect(response, isA()); + + }); + + test('test method getRow()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.getRow( + databaseId: '', + tableId: '', + rowId: '', + ); + expect(response, isA()); + + }); + + test('test method upsertRow()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.upsertRow( + databaseId: '', + tableId: '', + rowId: '', + ); + expect(response, isA()); + + }); + + test('test method updateRow()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.updateRow( + databaseId: '', + tableId: '', + rowId: '', + ); + expect(response, isA()); + + }); + + test('test method deleteRow()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.deleteRow( + databaseId: '', + tableId: '', + rowId: '', + ); + }); + + test('test method decrementRowColumn()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.decrementRowColumn( + databaseId: '', + tableId: '', + rowId: '', + column: '', + ); + expect(response, isA()); + + }); + + test('test method incrementRowColumn()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.incrementRowColumn( + databaseId: '', + tableId: '', + rowId: '', + column: '', + ); + expect(response, isA()); + + }); + }); - }); } diff --git a/test/services/teams_test.dart b/test/services/teams_test.dart index 83f2667b..ea72a432 100644 --- a/test/services/teams_test.dart +++ b/test/services/teams_test.dart @@ -24,11 +24,12 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -40,288 +41,326 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method( - #chunkedUpload, [path, params, paramName, idParamName, headers]), - returnValue: Response(data: {})); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Teams test', () { - late MockClient client; - late Teams teams; + group('Teams test', () { + late MockClient client; + late Teams teams; - setUp(() { - client = MockClient(); - teams = Teams(client); - }); + setUp(() { + client = MockClient(); + teams = Teams(client); + }); - test('test method list()', () async { - final Map data = { - 'total': 5, - 'teams': [], - }; + test('test method list()', () async { - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final Map data = { + 'total': 5, + 'teams': [],}; - final response = await teams.list(); - expect(response, isA()); - }); - test('test method create()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'VIP', - 'total': 7, - 'prefs': {}, - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await teams.create( - teamId: '', - name: '', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method get()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'VIP', - 'total': 7, - 'prefs': {}, - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await teams.get( - teamId: '', - ); - expect(response, isA()); - }); - test('test method updateName()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'VIP', - 'total': 7, - 'prefs': {}, - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await teams.updateName( - teamId: '', - name: '', - ); - expect(response, isA()); - }); + final response = await teams.list( + ); + expect(response, isA()); - test('test method delete()', () async { - final data = ''; + }); - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + test('test method create()', () async { - final response = await teams.delete( - teamId: '', - ); - }); + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'VIP', + 'total': 7, + 'prefs': {},}; - test('test method listMemberships()', () async { - final Map data = { - 'total': 5, - 'memberships': [], - }; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - final response = await teams.listMemberships( - teamId: '', - ); - expect(response, isA()); - }); - test('test method createMembership()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [], - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await teams.createMembership( - teamId: '', - roles: [], - ); - expect(response, isA()); - }); + final response = await teams.create( + teamId: '', + name: '', + ); + expect(response, isA()); - test('test method getMembership()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [], - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await teams.getMembership( - teamId: '', - membershipId: '', - ); - expect(response, isA()); - }); + }); - test('test method updateMembership()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [], - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await teams.updateMembership( - teamId: '', - membershipId: '', - roles: [], - ); - expect(response, isA()); - }); + test('test method get()', () async { - test('test method deleteMembership()', () async { - final data = ''; + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'VIP', + 'total': 7, + 'prefs': {},}; - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - final response = await teams.deleteMembership( - teamId: '', - membershipId: '', - ); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method updateMembershipStatus()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [], - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await teams.updateMembershipStatus( - teamId: '', - membershipId: '', - userId: '', - secret: '', - ); - expect(response, isA()); - }); - test('test method getPrefs()', () async { - final Map data = {}; + final response = await teams.get( + teamId: '', + ); + expect(response, isA()); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + }); + + test('test method updateName()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'VIP', + 'total': 7, + 'prefs': {},}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.updateName( + teamId: '', + name: '', + ); + expect(response, isA()); + + }); + + test('test method delete()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.delete( + teamId: '', + ); + }); + + test('test method listMemberships()', () async { + + final Map data = { + 'total': 5, + 'memberships': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.listMemberships( + teamId: '', + ); + expect(response, isA()); + + }); + + test('test method createMembership()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'userPhone': '+1 555 555 5555', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'roles': [],}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.createMembership( + teamId: '', + roles: [], + ); + expect(response, isA()); + + }); + + test('test method getMembership()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'userPhone': '+1 555 555 5555', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'roles': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.getMembership( + teamId: '', + membershipId: '', + ); + expect(response, isA()); + + }); + + test('test method updateMembership()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'userPhone': '+1 555 555 5555', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'roles': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.updateMembership( + teamId: '', + membershipId: '', + roles: [], + ); + expect(response, isA()); + + }); + + test('test method deleteMembership()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.deleteMembership( + teamId: '', + membershipId: '', + ); + }); + + test('test method updateMembershipStatus()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'userPhone': '+1 555 555 5555', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'roles': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.updateMembershipStatus( + teamId: '', + membershipId: '', + userId: '', + secret: '', + ); + expect(response, isA()); + + }); + + test('test method getPrefs()', () async { + + final Map data = {}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.getPrefs( + teamId: '', + ); + expect(response, isA()); + + }); + + test('test method updatePrefs()', () async { + + final Map data = {}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); - final response = await teams.getPrefs( - teamId: '', - ); - expect(response, isA()); - }); - test('test method updatePrefs()', () async { - final Map data = {}; + final response = await teams.updatePrefs( + teamId: '', + prefs: {}, + ); + expect(response, isA()); - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + }); - final response = await teams.updatePrefs( - teamId: '', - prefs: {}, - ); - expect(response, isA()); }); - }); } diff --git a/test/src/models/algo_argon2_test.dart b/test/src/models/algo_argon2_test.dart index 261daa46..15e85f5a 100644 --- a/test/src/models/algo_argon2_test.dart +++ b/test/src/models/algo_argon2_test.dart @@ -14,10 +14,10 @@ void main() { final map = model.toMap(); final result = AlgoArgon2.fromMap(map); - expect(result.type, 'argon2'); - expect(result.memoryCost, 65536); - expect(result.timeCost, 4); - expect(result.threads, 3); - }); + expect(result.type, 'argon2'); + expect(result.memoryCost, 65536); + expect(result.timeCost, 4); + expect(result.threads, 3); + }); }); } diff --git a/test/src/models/algo_bcrypt_test.dart b/test/src/models/algo_bcrypt_test.dart index 3da36624..87a3ca3c 100644 --- a/test/src/models/algo_bcrypt_test.dart +++ b/test/src/models/algo_bcrypt_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = AlgoBcrypt.fromMap(map); - expect(result.type, 'bcrypt'); - }); + expect(result.type, 'bcrypt'); + }); }); } diff --git a/test/src/models/algo_md5_test.dart b/test/src/models/algo_md5_test.dart index e58fa5b5..3b842e6c 100644 --- a/test/src/models/algo_md5_test.dart +++ b/test/src/models/algo_md5_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = AlgoMd5.fromMap(map); - expect(result.type, 'md5'); - }); + expect(result.type, 'md5'); + }); }); } diff --git a/test/src/models/algo_phpass_test.dart b/test/src/models/algo_phpass_test.dart index 3bcbb488..49b1e22c 100644 --- a/test/src/models/algo_phpass_test.dart +++ b/test/src/models/algo_phpass_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = AlgoPhpass.fromMap(map); - expect(result.type, 'phpass'); - }); + expect(result.type, 'phpass'); + }); }); } diff --git a/test/src/models/algo_scrypt_modified_test.dart b/test/src/models/algo_scrypt_modified_test.dart index b2084927..dd7fa8c3 100644 --- a/test/src/models/algo_scrypt_modified_test.dart +++ b/test/src/models/algo_scrypt_modified_test.dart @@ -8,18 +8,16 @@ void main() { type: 'scryptMod', salt: 'UxLMreBr6tYyjQ==', saltSeparator: 'Bw==', - signerKey: - 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ==', + signerKey: 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ==', ); final map = model.toMap(); final result = AlgoScryptModified.fromMap(map); - expect(result.type, 'scryptMod'); - expect(result.salt, 'UxLMreBr6tYyjQ=='); - expect(result.saltSeparator, 'Bw=='); - expect(result.signerKey, - 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ=='); - }); + expect(result.type, 'scryptMod'); + expect(result.salt, 'UxLMreBr6tYyjQ=='); + expect(result.saltSeparator, 'Bw=='); + expect(result.signerKey, 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ=='); + }); }); } diff --git a/test/src/models/algo_scrypt_test.dart b/test/src/models/algo_scrypt_test.dart index 8c131568..c7d9cdbf 100644 --- a/test/src/models/algo_scrypt_test.dart +++ b/test/src/models/algo_scrypt_test.dart @@ -15,11 +15,11 @@ void main() { final map = model.toMap(); final result = AlgoScrypt.fromMap(map); - expect(result.type, 'scrypt'); - expect(result.costCpu, 8); - expect(result.costMemory, 14); - expect(result.costParallel, 1); - expect(result.length, 64); - }); + expect(result.type, 'scrypt'); + expect(result.costCpu, 8); + expect(result.costMemory, 14); + expect(result.costParallel, 1); + expect(result.length, 64); + }); }); } diff --git a/test/src/models/algo_sha_test.dart b/test/src/models/algo_sha_test.dart index d080569c..ae58b57e 100644 --- a/test/src/models/algo_sha_test.dart +++ b/test/src/models/algo_sha_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = AlgoSha.fromMap(map); - expect(result.type, 'sha'); - }); + expect(result.type, 'sha'); + }); }); } diff --git a/test/src/models/continent_list_test.dart b/test/src/models/continent_list_test.dart index e71dcae1..8de695b0 100644 --- a/test/src/models/continent_list_test.dart +++ b/test/src/models/continent_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = ContinentList.fromMap(map); - expect(result.total, 5); - expect(result.continents, []); - }); + expect(result.total, 5); + expect(result.continents, []); + }); }); } diff --git a/test/src/models/continent_test.dart b/test/src/models/continent_test.dart index 85e559f5..d5242a4e 100644 --- a/test/src/models/continent_test.dart +++ b/test/src/models/continent_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = Continent.fromMap(map); - expect(result.name, 'Europe'); - expect(result.code, 'EU'); - }); + expect(result.name, 'Europe'); + expect(result.code, 'EU'); + }); }); } diff --git a/test/src/models/country_list_test.dart b/test/src/models/country_list_test.dart index 6df5c584..869f5db6 100644 --- a/test/src/models/country_list_test.dart +++ b/test/src/models/country_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = CountryList.fromMap(map); - expect(result.total, 5); - expect(result.countries, []); - }); + expect(result.total, 5); + expect(result.countries, []); + }); }); } diff --git a/test/src/models/country_test.dart b/test/src/models/country_test.dart index d5404a7f..bc66ab7b 100644 --- a/test/src/models/country_test.dart +++ b/test/src/models/country_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = Country.fromMap(map); - expect(result.name, 'United States'); - expect(result.code, 'US'); - }); + expect(result.name, 'United States'); + expect(result.code, 'US'); + }); }); } diff --git a/test/src/models/currency_list_test.dart b/test/src/models/currency_list_test.dart index d7410db8..09da675c 100644 --- a/test/src/models/currency_list_test.dart +++ b/test/src/models/currency_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = CurrencyList.fromMap(map); - expect(result.total, 5); - expect(result.currencies, []); - }); + expect(result.total, 5); + expect(result.currencies, []); + }); }); } diff --git a/test/src/models/currency_test.dart b/test/src/models/currency_test.dart index 00e046c7..29890008 100644 --- a/test/src/models/currency_test.dart +++ b/test/src/models/currency_test.dart @@ -17,13 +17,13 @@ void main() { final map = model.toMap(); final result = Currency.fromMap(map); - expect(result.symbol, '\$'); - expect(result.name, 'US dollar'); - expect(result.symbolNative, '\$'); - expect(result.decimalDigits, 2); - expect(result.rounding, 0); - expect(result.code, 'USD'); - expect(result.namePlural, 'US dollars'); - }); + expect(result.symbol, '\$'); + expect(result.name, 'US dollar'); + expect(result.symbolNative, '\$'); + expect(result.decimalDigits, 2); + expect(result.rounding, 0); + expect(result.code, 'USD'); + expect(result.namePlural, 'US dollars'); + }); }); } diff --git a/test/src/models/document_list_test.dart b/test/src/models/document_list_test.dart index 217d37e8..f1a5b3cc 100644 --- a/test/src/models/document_list_test.dart +++ b/test/src/models/document_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = DocumentList.fromMap(map); - expect(result.total, 5); - expect(result.documents, []); - }); + expect(result.total, 5); + expect(result.documents, []); + }); }); } diff --git a/test/src/models/document_test.dart b/test/src/models/document_test.dart index 397b5fab..6c1fbb77 100644 --- a/test/src/models/document_test.dart +++ b/test/src/models/document_test.dart @@ -18,13 +18,13 @@ void main() { final map = model.toMap(); final result = Document.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$sequence, '1'); - expect(result.$collectionId, '5e5ea5c15117e'); - expect(result.$databaseId, '5e5ea5c15117e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$sequence, '1'); + expect(result.$collectionId, '5e5ea5c15117e'); + expect(result.$databaseId, '5e5ea5c15117e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + }); }); } diff --git a/test/src/models/execution_list_test.dart b/test/src/models/execution_list_test.dart index a3305e55..fe74af58 100644 --- a/test/src/models/execution_list_test.dart +++ b/test/src/models/execution_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = ExecutionList.fromMap(map); - expect(result.total, 5); - expect(result.executions, []); - }); + expect(result.total, 5); + expect(result.executions, []); + }); }); } diff --git a/test/src/models/execution_test.dart b/test/src/models/execution_test.dart index 80ef508a..6d9bf33c 100644 --- a/test/src/models/execution_test.dart +++ b/test/src/models/execution_test.dart @@ -28,23 +28,23 @@ void main() { final map = model.toMap(); final result = Execution.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - expect(result.functionId, '5e5ea6g16897e'); - expect(result.deploymentId, '5e5ea5c16897e'); - expect(result.trigger, ExecutionTrigger.http); - expect(result.status, ExecutionStatus.waiting); - expect(result.requestMethod, 'GET'); - expect(result.requestPath, '/articles?id=5'); - expect(result.requestHeaders, []); - expect(result.responseStatusCode, 200); - expect(result.responseBody, ''); - expect(result.responseHeaders, []); - expect(result.logs, ''); - expect(result.errors, ''); - expect(result.duration, 0.4); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + expect(result.functionId, '5e5ea6g16897e'); + expect(result.deploymentId, '5e5ea5c16897e'); + expect(result.trigger, ExecutionTrigger.http); + expect(result.status, ExecutionStatus.waiting); + expect(result.requestMethod, 'GET'); + expect(result.requestPath, '/articles?id=5'); + expect(result.requestHeaders, []); + expect(result.responseStatusCode, 200); + expect(result.responseBody, ''); + expect(result.responseHeaders, []); + expect(result.logs, ''); + expect(result.errors, ''); + expect(result.duration, 0.4); + }); }); } diff --git a/test/src/models/file_list_test.dart b/test/src/models/file_list_test.dart index 8e02f65e..d8e6c95c 100644 --- a/test/src/models/file_list_test.dart +++ b/test/src/models/file_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = FileList.fromMap(map); - expect(result.total, 5); - expect(result.files, []); - }); + expect(result.total, 5); + expect(result.files, []); + }); }); } diff --git a/test/src/models/file_test.dart b/test/src/models/file_test.dart index 7f132646..8a734a08 100644 --- a/test/src/models/file_test.dart +++ b/test/src/models/file_test.dart @@ -24,20 +24,20 @@ void main() { final map = model.toMap(); final result = File.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.bucketId, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - expect(result.name, 'Pink.png'); - expect(result.signature, '5d529fd02b544198ae075bd57c1762bb'); - expect(result.mimeType, 'image/png'); - expect(result.sizeOriginal, 17890); - expect(result.sizeActual, 12345); - expect(result.chunksTotal, 17890); - expect(result.chunksUploaded, 17890); - expect(result.encryption, true); - expect(result.compression, 'gzip'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.bucketId, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + expect(result.name, 'Pink.png'); + expect(result.signature, '5d529fd02b544198ae075bd57c1762bb'); + expect(result.mimeType, 'image/png'); + expect(result.sizeOriginal, 17890); + expect(result.sizeActual, 12345); + expect(result.chunksTotal, 17890); + expect(result.chunksUploaded, 17890); + expect(result.encryption, true); + expect(result.compression, 'gzip'); + }); }); } diff --git a/test/src/models/headers_test.dart b/test/src/models/headers_test.dart index 9252b469..489891d4 100644 --- a/test/src/models/headers_test.dart +++ b/test/src/models/headers_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = Headers.fromMap(map); - expect(result.name, 'Content-Type'); - expect(result.value, 'application/json'); - }); + expect(result.name, 'Content-Type'); + expect(result.value, 'application/json'); + }); }); } diff --git a/test/src/models/identity_list_test.dart b/test/src/models/identity_list_test.dart index 8c35afec..65f562a7 100644 --- a/test/src/models/identity_list_test.dart +++ b/test/src/models/identity_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = IdentityList.fromMap(map); - expect(result.total, 5); - expect(result.identities, []); - }); + expect(result.total, 5); + expect(result.identities, []); + }); }); } diff --git a/test/src/models/identity_test.dart b/test/src/models/identity_test.dart index 525af4ea..708c8c60 100644 --- a/test/src/models/identity_test.dart +++ b/test/src/models/identity_test.dart @@ -20,16 +20,16 @@ void main() { final map = model.toMap(); final result = Identity.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5bb8c16897e'); - expect(result.provider, 'email'); - expect(result.providerUid, '5e5bb8c16897e'); - expect(result.providerEmail, 'user@example.com'); - expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); - expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5bb8c16897e'); + expect(result.provider, 'email'); + expect(result.providerUid, '5e5bb8c16897e'); + expect(result.providerEmail, 'user@example.com'); + expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); + expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + }); }); } diff --git a/test/src/models/jwt_test.dart b/test/src/models/jwt_test.dart index 93376af1..e616a956 100644 --- a/test/src/models/jwt_test.dart +++ b/test/src/models/jwt_test.dart @@ -5,15 +5,13 @@ void main() { group('Jwt', () { test('model', () { final model = Jwt( - jwt: - 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', + jwt: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', ); final map = model.toMap(); final result = Jwt.fromMap(map); - expect(result.jwt, - 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'); - }); + expect(result.jwt, 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'); + }); }); } diff --git a/test/src/models/language_list_test.dart b/test/src/models/language_list_test.dart index a07c0b5f..94c1e33f 100644 --- a/test/src/models/language_list_test.dart +++ b/test/src/models/language_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = LanguageList.fromMap(map); - expect(result.total, 5); - expect(result.languages, []); - }); + expect(result.total, 5); + expect(result.languages, []); + }); }); } diff --git a/test/src/models/language_test.dart b/test/src/models/language_test.dart index 4a6c96c1..d4087d5e 100644 --- a/test/src/models/language_test.dart +++ b/test/src/models/language_test.dart @@ -13,9 +13,9 @@ void main() { final map = model.toMap(); final result = Language.fromMap(map); - expect(result.name, 'Italian'); - expect(result.code, 'it'); - expect(result.nativeName, 'Italiano'); - }); + expect(result.name, 'Italian'); + expect(result.code, 'it'); + expect(result.nativeName, 'Italiano'); + }); }); } diff --git a/test/src/models/locale_code_list_test.dart b/test/src/models/locale_code_list_test.dart index 65b44ad1..b6de5137 100644 --- a/test/src/models/locale_code_list_test.dart +++ b/test/src/models/locale_code_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = LocaleCodeList.fromMap(map); - expect(result.total, 5); - expect(result.localeCodes, []); - }); + expect(result.total, 5); + expect(result.localeCodes, []); + }); }); } diff --git a/test/src/models/locale_code_test.dart b/test/src/models/locale_code_test.dart index 88cf157b..f0fcdbce 100644 --- a/test/src/models/locale_code_test.dart +++ b/test/src/models/locale_code_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = LocaleCode.fromMap(map); - expect(result.code, 'en-us'); - expect(result.name, 'US'); - }); + expect(result.code, 'en-us'); + expect(result.name, 'US'); + }); }); } diff --git a/test/src/models/locale_test.dart b/test/src/models/locale_test.dart index 49cb1fc9..72102045 100644 --- a/test/src/models/locale_test.dart +++ b/test/src/models/locale_test.dart @@ -17,13 +17,13 @@ void main() { final map = model.toMap(); final result = Locale.fromMap(map); - expect(result.ip, '127.0.0.1'); - expect(result.countryCode, 'US'); - expect(result.country, 'United States'); - expect(result.continentCode, 'NA'); - expect(result.continent, 'North America'); - expect(result.eu, true); - expect(result.currency, 'USD'); - }); + expect(result.ip, '127.0.0.1'); + expect(result.countryCode, 'US'); + expect(result.country, 'United States'); + expect(result.continentCode, 'NA'); + expect(result.continent, 'North America'); + expect(result.eu, true); + expect(result.currency, 'USD'); + }); }); } diff --git a/test/src/models/log_list_test.dart b/test/src/models/log_list_test.dart index b07ca8ee..84c560c8 100644 --- a/test/src/models/log_list_test.dart +++ b/test/src/models/log_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = LogList.fromMap(map); - expect(result.total, 5); - expect(result.logs, []); - }); + expect(result.total, 5); + expect(result.logs, []); + }); }); } diff --git a/test/src/models/log_test.dart b/test/src/models/log_test.dart index c8211d3b..1b463633 100644 --- a/test/src/models/log_test.dart +++ b/test/src/models/log_test.dart @@ -32,28 +32,28 @@ void main() { final map = model.toMap(); final result = Log.fromMap(map); - expect(result.event, 'account.sessions.create'); - expect(result.userId, '610fc2f985ee0'); - expect(result.userEmail, 'john@appwrite.io'); - expect(result.userName, 'John Doe'); - expect(result.mode, 'admin'); - expect(result.userType, 'user'); - expect(result.ip, '127.0.0.1'); - expect(result.time, '2020-10-15T06:38:00.000+00:00'); - expect(result.osCode, 'Mac'); - expect(result.osName, 'Mac'); - expect(result.osVersion, 'Mac'); - expect(result.clientType, 'browser'); - expect(result.clientCode, 'CM'); - expect(result.clientName, 'Chrome Mobile iOS'); - expect(result.clientVersion, '84.0'); - expect(result.clientEngine, 'WebKit'); - expect(result.clientEngineVersion, '605.1.15'); - expect(result.deviceName, 'smartphone'); - expect(result.deviceBrand, 'Google'); - expect(result.deviceModel, 'Nexus 5'); - expect(result.countryCode, 'US'); - expect(result.countryName, 'United States'); - }); + expect(result.event, 'account.sessions.create'); + expect(result.userId, '610fc2f985ee0'); + expect(result.userEmail, 'john@appwrite.io'); + expect(result.userName, 'John Doe'); + expect(result.mode, 'admin'); + expect(result.userType, 'user'); + expect(result.ip, '127.0.0.1'); + expect(result.time, '2020-10-15T06:38:00.000+00:00'); + expect(result.osCode, 'Mac'); + expect(result.osName, 'Mac'); + expect(result.osVersion, 'Mac'); + expect(result.clientType, 'browser'); + expect(result.clientCode, 'CM'); + expect(result.clientName, 'Chrome Mobile iOS'); + expect(result.clientVersion, '84.0'); + expect(result.clientEngine, 'WebKit'); + expect(result.clientEngineVersion, '605.1.15'); + expect(result.deviceName, 'smartphone'); + expect(result.deviceBrand, 'Google'); + expect(result.deviceModel, 'Nexus 5'); + expect(result.countryCode, 'US'); + expect(result.countryName, 'United States'); + }); }); } diff --git a/test/src/models/membership_list_test.dart b/test/src/models/membership_list_test.dart index 4f30c48e..bb1f0946 100644 --- a/test/src/models/membership_list_test.dart +++ b/test/src/models/membership_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = MembershipList.fromMap(map); - expect(result.total, 5); - expect(result.memberships, []); - }); + expect(result.total, 5); + expect(result.memberships, []); + }); }); } diff --git a/test/src/models/membership_test.dart b/test/src/models/membership_test.dart index b2b8bd3d..ab136c24 100644 --- a/test/src/models/membership_test.dart +++ b/test/src/models/membership_test.dart @@ -25,21 +25,21 @@ void main() { final map = model.toMap(); final result = Membership.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5ea5c16897e'); - expect(result.userName, 'John Doe'); - expect(result.userEmail, 'john@appwrite.io'); - expect(result.userPhone, '+1 555 555 5555'); - expect(result.teamId, '5e5ea5c16897e'); - expect(result.teamName, 'VIP'); - expect(result.invited, '2020-10-15T06:38:00.000+00:00'); - expect(result.joined, '2020-10-15T06:38:00.000+00:00'); - expect(result.confirm, true); - expect(result.mfa, true); - expect(result.userAccessedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.roles, []); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5ea5c16897e'); + expect(result.userName, 'John Doe'); + expect(result.userEmail, 'john@appwrite.io'); + expect(result.userPhone, '+1 555 555 5555'); + expect(result.teamId, '5e5ea5c16897e'); + expect(result.teamName, 'VIP'); + expect(result.invited, '2020-10-15T06:38:00.000+00:00'); + expect(result.joined, '2020-10-15T06:38:00.000+00:00'); + expect(result.confirm, true); + expect(result.mfa, true); + expect(result.userAccessedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.roles, []); + }); }); } diff --git a/test/src/models/mfa_challenge_test.dart b/test/src/models/mfa_challenge_test.dart index 5d3febca..9410baa3 100644 --- a/test/src/models/mfa_challenge_test.dart +++ b/test/src/models/mfa_challenge_test.dart @@ -14,10 +14,10 @@ void main() { final map = model.toMap(); final result = MfaChallenge.fromMap(map); - expect(result.$id, 'bb8ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5ea5c168bb8'); - expect(result.expire, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, 'bb8ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5ea5c168bb8'); + expect(result.expire, '2020-10-15T06:38:00.000+00:00'); + }); }); } diff --git a/test/src/models/mfa_factors_test.dart b/test/src/models/mfa_factors_test.dart index 64cc55e4..ed6467d3 100644 --- a/test/src/models/mfa_factors_test.dart +++ b/test/src/models/mfa_factors_test.dart @@ -14,10 +14,10 @@ void main() { final map = model.toMap(); final result = MfaFactors.fromMap(map); - expect(result.totp, true); - expect(result.phone, true); - expect(result.email, true); - expect(result.recoveryCode, true); - }); + expect(result.totp, true); + expect(result.phone, true); + expect(result.email, true); + expect(result.recoveryCode, true); + }); }); } diff --git a/test/src/models/mfa_recovery_codes_test.dart b/test/src/models/mfa_recovery_codes_test.dart index 500913c8..fa097a49 100644 --- a/test/src/models/mfa_recovery_codes_test.dart +++ b/test/src/models/mfa_recovery_codes_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = MfaRecoveryCodes.fromMap(map); - expect(result.recoveryCodes, []); - }); + expect(result.recoveryCodes, []); + }); }); } diff --git a/test/src/models/mfa_type_test.dart b/test/src/models/mfa_type_test.dart index 81657394..3f45d288 100644 --- a/test/src/models/mfa_type_test.dart +++ b/test/src/models/mfa_type_test.dart @@ -6,16 +6,14 @@ void main() { test('model', () { final model = MfaType( secret: '[SHARED_SECRET]', - uri: - 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', + uri: 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', ); final map = model.toMap(); final result = MfaType.fromMap(map); - expect(result.secret, '[SHARED_SECRET]'); - expect(result.uri, - 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite'); - }); + expect(result.secret, '[SHARED_SECRET]'); + expect(result.uri, 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite'); + }); }); } diff --git a/test/src/models/phone_list_test.dart b/test/src/models/phone_list_test.dart index bf22a5c7..6ca46a63 100644 --- a/test/src/models/phone_list_test.dart +++ b/test/src/models/phone_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = PhoneList.fromMap(map); - expect(result.total, 5); - expect(result.phones, []); - }); + expect(result.total, 5); + expect(result.phones, []); + }); }); } diff --git a/test/src/models/phone_test.dart b/test/src/models/phone_test.dart index f70db0e3..d0e5333b 100644 --- a/test/src/models/phone_test.dart +++ b/test/src/models/phone_test.dart @@ -13,9 +13,9 @@ void main() { final map = model.toMap(); final result = Phone.fromMap(map); - expect(result.code, '+1'); - expect(result.countryCode, 'US'); - expect(result.countryName, 'United States'); - }); + expect(result.code, '+1'); + expect(result.countryCode, 'US'); + expect(result.countryName, 'United States'); + }); }); } diff --git a/test/src/models/preferences_test.dart b/test/src/models/preferences_test.dart index 9db30b03..acde349c 100644 --- a/test/src/models/preferences_test.dart +++ b/test/src/models/preferences_test.dart @@ -10,6 +10,7 @@ void main() { final map = model.toMap(); final result = Preferences.fromMap(map); + }); }); } diff --git a/test/src/models/presence_list_test.dart b/test/src/models/presence_list_test.dart index 46f69af6..57a86348 100644 --- a/test/src/models/presence_list_test.dart +++ b/test/src/models/presence_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = PresenceList.fromMap(map); - expect(result.total, 5); - expect(result.presences, []); - }); + expect(result.total, 5); + expect(result.presences, []); + }); }); } diff --git a/test/src/models/presence_test.dart b/test/src/models/presence_test.dart index ef2ebe31..edcfe5f5 100644 --- a/test/src/models/presence_test.dart +++ b/test/src/models/presence_test.dart @@ -16,12 +16,12 @@ void main() { final map = model.toMap(); final result = Presence.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - expect(result.userId, '674af8f3e12a5f9ac0be'); - expect(result.source, 'HTTP'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + expect(result.userId, '674af8f3e12a5f9ac0be'); + expect(result.source, 'HTTP'); + }); }); } diff --git a/test/src/models/row_list_test.dart b/test/src/models/row_list_test.dart index 12693926..d4900dd4 100644 --- a/test/src/models/row_list_test.dart +++ b/test/src/models/row_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = RowList.fromMap(map); - expect(result.total, 5); - expect(result.rows, []); - }); + expect(result.total, 5); + expect(result.rows, []); + }); }); } diff --git a/test/src/models/row_test.dart b/test/src/models/row_test.dart index 564bf303..4e72a449 100644 --- a/test/src/models/row_test.dart +++ b/test/src/models/row_test.dart @@ -18,13 +18,13 @@ void main() { final map = model.toMap(); final result = Row.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$sequence, '1'); - expect(result.$tableId, '5e5ea5c15117e'); - expect(result.$databaseId, '5e5ea5c15117e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$sequence, '1'); + expect(result.$tableId, '5e5ea5c15117e'); + expect(result.$databaseId, '5e5ea5c15117e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + }); }); } diff --git a/test/src/models/session_list_test.dart b/test/src/models/session_list_test.dart index 708e0583..eaab249e 100644 --- a/test/src/models/session_list_test.dart +++ b/test/src/models/session_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = SessionList.fromMap(map); - expect(result.total, 5); - expect(result.sessions, []); - }); + expect(result.total, 5); + expect(result.sessions, []); + }); }); } diff --git a/test/src/models/session_test.dart b/test/src/models/session_test.dart index 689e6048..0177e477 100644 --- a/test/src/models/session_test.dart +++ b/test/src/models/session_test.dart @@ -39,35 +39,35 @@ void main() { final map = model.toMap(); final result = Session.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5bb8c16897e'); - expect(result.expire, '2020-10-15T06:38:00.000+00:00'); - expect(result.provider, 'email'); - expect(result.providerUid, 'user@example.com'); - expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); - expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - expect(result.ip, '127.0.0.1'); - expect(result.osCode, 'Mac'); - expect(result.osName, 'Mac'); - expect(result.osVersion, 'Mac'); - expect(result.clientType, 'browser'); - expect(result.clientCode, 'CM'); - expect(result.clientName, 'Chrome Mobile iOS'); - expect(result.clientVersion, '84.0'); - expect(result.clientEngine, 'WebKit'); - expect(result.clientEngineVersion, '605.1.15'); - expect(result.deviceName, 'smartphone'); - expect(result.deviceBrand, 'Google'); - expect(result.deviceModel, 'Nexus 5'); - expect(result.countryCode, 'US'); - expect(result.countryName, 'United States'); - expect(result.current, true); - expect(result.factors, []); - expect(result.secret, '5e5bb8c16897e'); - expect(result.mfaUpdatedAt, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5bb8c16897e'); + expect(result.expire, '2020-10-15T06:38:00.000+00:00'); + expect(result.provider, 'email'); + expect(result.providerUid, 'user@example.com'); + expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); + expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + expect(result.ip, '127.0.0.1'); + expect(result.osCode, 'Mac'); + expect(result.osName, 'Mac'); + expect(result.osVersion, 'Mac'); + expect(result.clientType, 'browser'); + expect(result.clientCode, 'CM'); + expect(result.clientName, 'Chrome Mobile iOS'); + expect(result.clientVersion, '84.0'); + expect(result.clientEngine, 'WebKit'); + expect(result.clientEngineVersion, '605.1.15'); + expect(result.deviceName, 'smartphone'); + expect(result.deviceBrand, 'Google'); + expect(result.deviceModel, 'Nexus 5'); + expect(result.countryCode, 'US'); + expect(result.countryName, 'United States'); + expect(result.current, true); + expect(result.factors, []); + expect(result.secret, '5e5bb8c16897e'); + expect(result.mfaUpdatedAt, '2020-10-15T06:38:00.000+00:00'); + }); }); } diff --git a/test/src/models/subscriber_test.dart b/test/src/models/subscriber_test.dart index 7445514c..94c6a502 100644 --- a/test/src/models/subscriber_test.dart +++ b/test/src/models/subscriber_test.dart @@ -10,15 +10,15 @@ void main() { $updatedAt: '2020-10-15T06:38:00.000+00:00', targetId: '259125845563242502', target: Target( - $id: '259125845563242502', - $createdAt: '2020-10-15T06:38:00.000+00:00', - $updatedAt: '2020-10-15T06:38:00.000+00:00', - name: 'Apple iPhone 12', - userId: '259125845563242502', - providerType: 'email', - identifier: 'token', - expired: true, - ), + $id: '259125845563242502', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Apple iPhone 12', + userId: '259125845563242502', + providerType: 'email', + identifier: 'token', + expired: true, + ), userId: '5e5ea5c16897e', userName: 'Aegon Targaryen', topicId: '259125845563242502', @@ -28,14 +28,14 @@ void main() { final map = model.toMap(); final result = Subscriber.fromMap(map); - expect(result.$id, '259125845563242502'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.targetId, '259125845563242502'); - expect(result.userId, '5e5ea5c16897e'); - expect(result.userName, 'Aegon Targaryen'); - expect(result.topicId, '259125845563242502'); - expect(result.providerType, 'email'); - }); + expect(result.$id, '259125845563242502'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.targetId, '259125845563242502'); + expect(result.userId, '5e5ea5c16897e'); + expect(result.userName, 'Aegon Targaryen'); + expect(result.topicId, '259125845563242502'); + expect(result.providerType, 'email'); + }); }); } diff --git a/test/src/models/target_test.dart b/test/src/models/target_test.dart index 49f1e75e..a49f3def 100644 --- a/test/src/models/target_test.dart +++ b/test/src/models/target_test.dart @@ -18,14 +18,14 @@ void main() { final map = model.toMap(); final result = Target.fromMap(map); - expect(result.$id, '259125845563242502'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.name, 'Apple iPhone 12'); - expect(result.userId, '259125845563242502'); - expect(result.providerType, 'email'); - expect(result.identifier, 'token'); - expect(result.expired, true); - }); + expect(result.$id, '259125845563242502'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.name, 'Apple iPhone 12'); + expect(result.userId, '259125845563242502'); + expect(result.providerType, 'email'); + expect(result.identifier, 'token'); + expect(result.expired, true); + }); }); } diff --git a/test/src/models/team_list_test.dart b/test/src/models/team_list_test.dart index fe2f4a85..a19b667d 100644 --- a/test/src/models/team_list_test.dart +++ b/test/src/models/team_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = TeamList.fromMap(map); - expect(result.total, 5); - expect(result.teams, []); - }); + expect(result.total, 5); + expect(result.teams, []); + }); }); } diff --git a/test/src/models/team_test.dart b/test/src/models/team_test.dart index f652f2c1..43b2e45c 100644 --- a/test/src/models/team_test.dart +++ b/test/src/models/team_test.dart @@ -16,11 +16,11 @@ void main() { final map = model.toMap(); final result = Team.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.name, 'VIP'); - expect(result.total, 7); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.name, 'VIP'); + expect(result.total, 7); + }); }); } diff --git a/test/src/models/token_test.dart b/test/src/models/token_test.dart index 8f0957c9..7ee4b268 100644 --- a/test/src/models/token_test.dart +++ b/test/src/models/token_test.dart @@ -16,12 +16,12 @@ void main() { final map = model.toMap(); final result = Token.fromMap(map); - expect(result.$id, 'bb8ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5ea5c168bb8'); - expect(result.secret, ''); - expect(result.expire, '2020-10-15T06:38:00.000+00:00'); - expect(result.phrase, 'Golden Fox'); - }); + expect(result.$id, 'bb8ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5ea5c168bb8'); + expect(result.secret, ''); + expect(result.expire, '2020-10-15T06:38:00.000+00:00'); + expect(result.phrase, 'Golden Fox'); + }); }); } diff --git a/test/src/models/transaction_list_test.dart b/test/src/models/transaction_list_test.dart index a524ef71..68023e18 100644 --- a/test/src/models/transaction_list_test.dart +++ b/test/src/models/transaction_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = TransactionList.fromMap(map); - expect(result.total, 5); - expect(result.transactions, []); - }); + expect(result.total, 5); + expect(result.transactions, []); + }); }); } diff --git a/test/src/models/transaction_test.dart b/test/src/models/transaction_test.dart index 0169427f..723ebac2 100644 --- a/test/src/models/transaction_test.dart +++ b/test/src/models/transaction_test.dart @@ -16,12 +16,12 @@ void main() { final map = model.toMap(); final result = Transaction.fromMap(map); - expect(result.$id, '259125845563242502'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.status, 'pending'); - expect(result.operations, 5); - expect(result.expiresAt, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, '259125845563242502'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.status, 'pending'); + expect(result.operations, 5); + expect(result.expiresAt, '2020-10-15T06:38:00.000+00:00'); + }); }); } diff --git a/test/src/models/user_test.dart b/test/src/models/user_test.dart index 77c7dd97..c058ea26 100644 --- a/test/src/models/user_test.dart +++ b/test/src/models/user_test.dart @@ -26,21 +26,21 @@ void main() { final map = model.toMap(); final result = User.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.name, 'John Doe'); - expect(result.registration, '2020-10-15T06:38:00.000+00:00'); - expect(result.status, true); - expect(result.labels, []); - expect(result.passwordUpdate, '2020-10-15T06:38:00.000+00:00'); - expect(result.email, 'john@appwrite.io'); - expect(result.phone, '+4930901820'); - expect(result.emailVerification, true); - expect(result.phoneVerification, true); - expect(result.mfa, true); - expect(result.targets, []); - expect(result.accessedAt, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.name, 'John Doe'); + expect(result.registration, '2020-10-15T06:38:00.000+00:00'); + expect(result.status, true); + expect(result.labels, []); + expect(result.passwordUpdate, '2020-10-15T06:38:00.000+00:00'); + expect(result.email, 'john@appwrite.io'); + expect(result.phone, '+4930901820'); + expect(result.emailVerification, true); + expect(result.phoneVerification, true); + expect(result.mfa, true); + expect(result.targets, []); + expect(result.accessedAt, '2020-10-15T06:38:00.000+00:00'); + }); }); } From d108221f42e2f5f47eed16209e683524d6f6b7d7 Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Thu, 25 Jun 2026 04:48:07 +0000 Subject: [PATCH 4/8] Commit from GitHub Actions (Format and push) --- lib/appwrite.dart | 2 +- lib/channel.dart | 20 +- lib/client_browser.dart | 2 +- lib/client_io.dart | 2 +- lib/operator.dart | 11 +- lib/query.dart | 91 +- lib/realtime_browser.dart | 2 +- lib/realtime_io.dart | 2 +- lib/role.dart | 2 +- lib/services/account.dart | 1560 +++++----- lib/services/avatars.dart | 351 ++- lib/services/databases.dart | 603 ++-- lib/services/functions.dart | 115 +- lib/services/graphql.dart | 50 +- lib/services/locale.dart | 142 +- lib/services/messaging.dart | 70 +- lib/services/presences.dart | 182 +- lib/services/storage.dart | 342 ++- lib/services/tables_db.dart | 547 ++-- lib/services/teams.dart | 421 +-- lib/src/client.dart | 4 +- lib/src/client_base.dart | 7 + lib/src/client_browser.dart | 15 +- lib/src/client_io.dart | 15 +- lib/src/client_mixin.dart | 9 +- lib/src/enums/authentication_factor.dart | 18 +- lib/src/enums/authenticator_type.dart | 12 +- lib/src/enums/browser.dart | 38 +- lib/src/enums/browser_permission.dart | 50 +- lib/src/enums/browser_theme.dart | 14 +- lib/src/enums/credit_card.dart | 44 +- lib/src/enums/execution_method.dart | 24 +- lib/src/enums/execution_status.dart | 20 +- lib/src/enums/execution_trigger.dart | 16 +- 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 | 96 +- lib/src/enums/timezone.dart | 848 +++--- lib/src/exception.dart | 2 +- lib/src/models/algo_argon2.dart | 62 +- lib/src/models/algo_bcrypt.dart | 32 +- lib/src/models/algo_md5.dart | 32 +- lib/src/models/algo_phpass.dart | 32 +- lib/src/models/algo_scrypt.dart | 86 +- lib/src/models/algo_scrypt_modified.dart | 62 +- lib/src/models/algo_sha.dart | 32 +- lib/src/models/continent.dart | 42 +- lib/src/models/continent_list.dart | 43 +- lib/src/models/country.dart | 42 +- lib/src/models/country_list.dart | 43 +- lib/src/models/currency.dart | 110 +- lib/src/models/currency_list.dart | 43 +- lib/src/models/document.dart | 102 +- lib/src/models/document_list.dart | 47 +- lib/src/models/execution.dart | 246 +- lib/src/models/execution_list.dart | 43 +- lib/src/models/file.dart | 194 +- lib/src/models/file_list.dart | 42 +- lib/src/models/headers.dart | 42 +- lib/src/models/identity.dart | 122 +- lib/src/models/identity_list.dart | 43 +- lib/src/models/jwt.dart | 32 +- lib/src/models/language.dart | 52 +- lib/src/models/language_list.dart | 43 +- lib/src/models/locale.dart | 110 +- lib/src/models/locale_code.dart | 42 +- lib/src/models/locale_code_list.dart | 43 +- lib/src/models/log.dart | 290 +- lib/src/models/log_list.dart | 42 +- lib/src/models/membership.dart | 206 +- lib/src/models/membership_list.dart | 43 +- lib/src/models/mfa_challenge.dart | 62 +- lib/src/models/mfa_factors.dart | 62 +- lib/src/models/mfa_recovery_codes.dart | 32 +- lib/src/models/mfa_type.dart | 42 +- lib/src/models/model.dart | 2 +- lib/src/models/phone.dart | 52 +- lib/src/models/phone_list.dart | 42 +- lib/src/models/preferences.dart | 32 +- lib/src/models/presence.dart | 112 +- lib/src/models/presence_list.dart | 43 +- lib/src/models/row.dart | 102 +- lib/src/models/row_list.dart | 46 +- lib/src/models/session.dart | 360 +-- lib/src/models/session_list.dart | 43 +- lib/src/models/subscriber.dart | 112 +- lib/src/models/target.dart | 112 +- lib/src/models/team.dart | 98 +- lib/src/models/team_list.dart | 42 +- lib/src/models/token.dart | 98 +- lib/src/models/transaction.dart | 98 +- lib/src/models/transaction_list.dart | 43 +- lib/src/models/user.dart | 332 +- lib/src/realtime.dart | 6 +- lib/src/realtime_io.dart | 4 +- lib/src/realtime_message.dart | 2 +- lib/src/realtime_mixin.dart | 31 +- lib/src/realtime_response.dart | 10 +- lib/src/realtime_stub.dart | 4 +- test/channel_test.dart | 42 +- test/query_test.dart | 1 - test/services/account_test.dart | 2691 ++++++++--------- test/services/avatars_test.dart | 204 +- test/services/databases_test.dart | 585 ++-- test/services/functions_test.dart | 188 +- test/services/graphql_test.dart | 71 +- test/services/locale_test.dart | 253 +- test/services/messaging_test.dart | 122 +- test/services/presences_test.dart | 202 +- test/services/storage_test.dart | 341 +-- test/services/tables_db_test.dart | 585 ++-- test/services/teams_test.dart | 555 ++-- test/src/models/algo_argon2_test.dart | 10 +- test/src/models/algo_bcrypt_test.dart | 4 +- test/src/models/algo_md5_test.dart | 4 +- test/src/models/algo_phpass_test.dart | 4 +- .../src/models/algo_scrypt_modified_test.dart | 14 +- test/src/models/algo_scrypt_test.dart | 12 +- test/src/models/algo_sha_test.dart | 4 +- test/src/models/continent_list_test.dart | 6 +- test/src/models/continent_test.dart | 6 +- test/src/models/country_list_test.dart | 6 +- test/src/models/country_test.dart | 6 +- test/src/models/currency_list_test.dart | 6 +- test/src/models/currency_test.dart | 16 +- test/src/models/document_list_test.dart | 6 +- test/src/models/document_test.dart | 16 +- test/src/models/execution_list_test.dart | 6 +- test/src/models/execution_test.dart | 36 +- test/src/models/file_list_test.dart | 6 +- test/src/models/file_test.dart | 30 +- test/src/models/headers_test.dart | 6 +- test/src/models/identity_list_test.dart | 6 +- test/src/models/identity_test.dart | 22 +- test/src/models/jwt_test.dart | 8 +- test/src/models/language_list_test.dart | 6 +- test/src/models/language_test.dart | 8 +- test/src/models/locale_code_list_test.dart | 6 +- test/src/models/locale_code_test.dart | 6 +- test/src/models/locale_test.dart | 16 +- test/src/models/log_list_test.dart | 6 +- test/src/models/log_test.dart | 46 +- test/src/models/membership_list_test.dart | 6 +- test/src/models/membership_test.dart | 32 +- test/src/models/mfa_challenge_test.dart | 10 +- test/src/models/mfa_factors_test.dart | 10 +- test/src/models/mfa_recovery_codes_test.dart | 4 +- test/src/models/mfa_type_test.dart | 10 +- test/src/models/phone_list_test.dart | 6 +- test/src/models/phone_test.dart | 8 +- test/src/models/preferences_test.dart | 1 - test/src/models/presence_list_test.dart | 6 +- test/src/models/presence_test.dart | 14 +- test/src/models/row_list_test.dart | 6 +- test/src/models/row_test.dart | 16 +- test/src/models/session_list_test.dart | 6 +- test/src/models/session_test.dart | 60 +- test/src/models/subscriber_test.dart | 36 +- test/src/models/target_test.dart | 18 +- test/src/models/team_list_test.dart | 6 +- test/src/models/team_test.dart | 12 +- test/src/models/token_test.dart | 14 +- test/src/models/transaction_list_test.dart | 6 +- test/src/models/transaction_test.dart | 14 +- test/src/models/user_test.dart | 32 +- 166 files changed, 8516 insertions(+), 8661 deletions(-) diff --git a/lib/appwrite.dart b/lib/appwrite.dart index 6615de8a..ae51be5e 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.9.x. +/// This SDK is compatible with Appwrite server version 1.9.x. /// For older versions, please check /// [previous releases](https://github.com/appwrite/sdk-for-flutter/releases). library appwrite; diff --git a/lib/channel.dart b/lib/channel.dart index d511f5a4..afc68efa 100644 --- a/lib/channel.dart +++ b/lib/channel.dart @@ -2,19 +2,33 @@ part of appwrite; // Marker classes for type safety class _Root {} + class _Database {} + class _Collection {} + class _Document {} + class _TablesDB {} + class _Table {} + class _Row {} + class _Bucket {} + class _File {} + class _Func {} + class _Execution {} + class _Team {} + class _Membership {} + class _Presence {} + class _Resolved {} // Helper function for normalizing ID @@ -99,15 +113,15 @@ extension DatabaseChannel on Channel<_Database> { /// Only available on Channel<_Collection> extension CollectionChannel on Channel<_Collection> { - Channel<_Document> document([String? id]) => _next<_Document>('documents', id); + Channel<_Document> document([String? id]) => + _next<_Document>('documents', id); } // --- TABLESDB ROUTE --- /// Only available on Channel<_TablesDB> extension TablesDBChannel on Channel<_TablesDB> { - Channel<_Table> table(String id) => - _next<_Table>('tables', id); + Channel<_Table> table(String id) => _next<_Table>('tables', id); } /// Only available on Channel<_Table> 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/operator.dart b/lib/operator.dart index 9dd7f4c7..337dda30 100644 --- a/lib/operator.dart +++ b/lib/operator.dart @@ -31,7 +31,7 @@ class Operator { result['method'] = method; - if(values != null) { + if (values != null) { result['values'] = values is List ? values : [values]; } @@ -147,8 +147,7 @@ class Operator { Operator._('arrayRemove', [value]).toString(); /// Remove duplicate values from an array attribute. - static String arrayUnique() => - Operator._('arrayUnique', []).toString(); + static String arrayUnique() => Operator._('arrayUnique', []).toString(); /// Keep only values that exist in both the current array and the provided array. static String arrayIntersect(List values) => @@ -173,8 +172,7 @@ class Operator { Operator._('stringReplace', [search, replace]).toString(); /// Toggle a boolean attribute. - static String toggle() => - Operator._('toggle', []).toString(); + static String toggle() => Operator._('toggle', []).toString(); /// Add days to a date attribute. static String dateAddDays(int days) => @@ -185,6 +183,5 @@ class Operator { Operator._('dateSubDays', [days]).toString(); /// Set a date attribute to the current date and time. - static String dateSetNow() => - Operator._('dateSetNow', []).toString(); + static String dateSetNow() => Operator._('dateSetNow', []).toString(); } diff --git a/lib/query.dart b/lib/query.dart index 95365bf7..3693dce6 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. @@ -140,50 +140,46 @@ class Query { Query._('notEndsWith', attribute, value).toString(); /// Filter resources where document was created before [value]. - static String createdBefore(String value) => - lessThan('\$createdAt', value); + static String createdBefore(String value) => lessThan('\$createdAt', value); /// Filter resources where document was created after [value]. - static String createdAfter(String value) => - greaterThan('\$createdAt', value); + static String createdAfter(String value) => greaterThan('\$createdAt', value); /// Filter resources where document was created between [start] and [end] (inclusive). static String createdBetween(String start, String end) => between('\$createdAt', start, end); /// Filter resources where document was updated before [value]. - static String updatedBefore(String value) => - lessThan('\$updatedAt', value); + static String updatedBefore(String value) => lessThan('\$updatedAt', value); /// Filter resources where document was updated after [value]. - static String updatedAfter(String value) => - greaterThan('\$updatedAt', value); + static String updatedAfter(String value) => greaterThan('\$updatedAt', value); /// Filter resources where document was updated between [start] and [end] (inclusive). static String updatedBetween(String start, String end) => between('\$updatedAt', start, end); static String or(List queries) => Query._( - 'or', - null, - queries.map((query) => jsonDecode(query)).toList(), - ).toString(); + 'or', + null, + queries.map((query) => jsonDecode(query)).toList(), + ).toString(); static String and(List queries) => Query._( - 'and', - null, - queries.map((query) => jsonDecode(query)).toList(), - ).toString(); + 'and', + null, + queries.map((query) => jsonDecode(query)).toList(), + ).toString(); /// Filter array elements where at least one element matches all the specified queries. /// /// [attribute] The attribute containing the array to filter on. /// [queries] The list of query strings to match against array elements. static String elemMatch(String attribute, List queries) => Query._( - 'elemMatch', - attribute, - queries.map((query) => jsonDecode(query)).toList(), - ).toString(); + 'elemMatch', + attribute, + queries.map((query) => jsonDecode(query)).toList(), + ).toString(); /// Specify which attributes should be returned by the API call. static String select(List attributes) => @@ -198,18 +194,17 @@ class Query { Query._('orderDesc', attribute).toString(); /// Sort results randomly. - static String orderRandom() => - Query._('orderRandom').toString(); + static String orderRandom() => Query._('orderRandom').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) => @@ -219,27 +214,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) => @@ -272,4 +283,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 9c021e93..48b60041 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 { final String apiPath = '/account'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -30,29 +29,30 @@ 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 { final String apiPath = '/account'; - final Map apiParams = { - 'userId': userId, - - 'email': email, - - 'password': password, - - if (name != null) 'name': name, - - }; + final Map apiParams = { + 'userId': userId, + 'email': email, + 'password': password, + if (name != null) 'name': name, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - 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 @@ -62,66 +62,65 @@ 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 { final String apiPath = '/account/email'; - final Map apiParams = { - 'email': email, - - 'password': password, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + 'email': email, + 'password': password, + }; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 list of identities for the currently logged in user. - Future listIdentities({List? queries, bool? total}) async { + Future listIdentities( + {List? queries, bool? total}) async { final String apiPath = '/account/identities'; - final Map apiParams = { - if (queries != null) 'queries': queries, + final Map apiParams = { + if (queries != null) 'queries': queries, + if (total != null) 'total': total, + }; - if (total != null) 'total': total, + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: 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 Map apiParams = { - }; + final String apiPath = '/account/identities/{identityId}' + .replaceAll('{identityId}', identityId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - 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 @@ -132,20 +131,20 @@ class Account extends Service { Future createJWT({int? duration}) async { final String apiPath = '/account/jwts'; - final Map apiParams = { - if (duration != null) 'duration': duration, + final Map apiParams = { + if (duration != null) 'duration': duration, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - 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 @@ -153,212 +152,224 @@ class Account extends Service { Future listLogs({List? queries, bool? total}) async { final String apiPath = '/account/logs'; - final Map apiParams = { - if (queries != null) 'queries': queries, - - if (total != null) 'total': total, - - }; + final Map apiParams = { + if (queries != null) 'queries': queries, + if (total != null) 'total': total, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 { final String apiPath = '/account/mfa'; - final Map apiParams = { - 'mfa': mfa, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + 'mfa': mfa, + }; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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); + @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 apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.MfaType.fromMap(res.data); + 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 = { - }; + Future createMFAAuthenticator( + {required enums.AuthenticatorType type}) async { + final String apiPath = + '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - return models.MfaType.fromMap(res.data); + 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, - - }; + Future updateMFAAuthenticator( + {required enums.AuthenticatorType type, required String otp}) async { + final String apiPath = + '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + 'otp': otp, + }; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - return models.User.fromMap(res.data); + 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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 { final String apiPath = '/account/mfa/challenges'; - final Map apiParams = { - 'factor': factor.value, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + 'factor': factor.value, + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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); } /// 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 { final String apiPath = '/account/mfa/challenges'; - final Map apiParams = { - 'factor': factor.value, + final Map apiParams = { + 'factor': factor.value, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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); } /// Complete the MFA challenge by providing the one-time password. Finish the @@ -366,26 +377,27 @@ 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 { final String apiPath = '/account/mfa/challenges'; - final Map apiParams = { - 'challengeId': challengeId, - - 'otp': otp, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 @@ -393,84 +405,83 @@ 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 { final String apiPath = '/account/mfa/challenges'; - final Map apiParams = { - 'challengeId': challengeId, + final Map apiParams = { + 'challengeId': challengeId, + 'otp': otp, + }; - 'otp': otp, + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 { final String apiPath = '/account/mfa/factors'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 { final String apiPath = '/account/mfa/factors'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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); } /// 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 { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -480,18 +491,17 @@ class Account extends Service { Future getMFARecoveryCodes() async { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -499,22 +509,23 @@ 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 { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 @@ -525,40 +536,41 @@ class Account extends Service { Future createMFARecoveryCodes() async { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 @@ -568,62 +580,62 @@ class Account extends Service { Future updateMFARecoveryCodes() async { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - 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 { final String apiPath = '/account/name'; - final Map apiParams = { - 'name': name, - - }; + final Map apiParams = { + 'name': name, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 { final String apiPath = '/account/password'; - final Map apiParams = { - 'password': password, - - if (oldPassword != null) 'oldPassword': oldPassword, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + 'password': password, + if (oldPassword != null) 'oldPassword': oldPassword, + }; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 @@ -631,43 +643,42 @@ 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 { final String apiPath = '/account/phone'; - final Map apiParams = { - 'phone': phone, + final Map apiParams = { + 'phone': phone, + 'password': password, + }; - 'password': password, + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 preferences as a key-value object for the currently logged in user. Future getPrefs() async { final String apiPath = '/account/prefs'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -676,20 +687,20 @@ class Account extends Service { Future updatePrefs({required Map prefs}) async { final String apiPath = '/account/prefs'; - final Map apiParams = { - 'prefs': prefs, + final Map apiParams = { + 'prefs': prefs, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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. @@ -700,25 +711,25 @@ 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 { final String apiPath = '/account/recovery'; - final Map apiParams = { - 'email': email, - - 'url': url, - - }; + final Map apiParams = { + 'email': email, + 'url': url, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 account password reset. Both the @@ -726,32 +737,33 @@ 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 { final 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - 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 @@ -759,18 +771,17 @@ class Account extends Service { Future listSessions() async { final String apiPath = '/account/sessions'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -778,18 +789,17 @@ class Account extends Service { Future deleteSessions() async { final String apiPath = '/account/sessions'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - 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 @@ -802,213 +812,216 @@ class Account extends Service { Future createAnonymousSession() async { final String apiPath = '/account/sessions/anonymous'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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); } /// 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 { final String apiPath = '/account/sessions/email'; - final Map apiParams = { - 'email': email, - - 'password': password, + final Map apiParams = { + 'email': email, + 'password': password, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 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 { final String apiPath = '/account/sessions/magic-url'; - final Map apiParams = { - 'userId': userId, - - 'secret': secret, - - }; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 = { - - if (success != null) 'success': success, - - if (failure != null) 'failure': failure, - - if (scopes != null) 'scopes': scopes, - - - 'project': client.config['project'], - }; - - final List query = []; - - params.forEach((key, value) { - if (value is List) { - for (var item in value) { - query.add( + /// + 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 = { + if (success != null) 'success': success, + if (failure != null) 'failure': failure, + if (scopes != null) '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); + } + } 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 { final String apiPath = '/account/sessions/phone'; - final Map apiParams = { - 'userId': userId, - - 'secret': secret, + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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); } /// 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 { final String apiPath = '/account/sessions/token'; - final Map apiParams = { - 'userId': userId, - - 'secret': secret, - - }; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 String apiPath = + '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, @@ -1017,20 +1030,20 @@ 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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 @@ -1039,18 +1052,18 @@ class Account extends Service { Future updateStatus() async { final String apiPath = '/account/status'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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); } /// Use this endpoint to register a device for push notifications. Provide a @@ -1058,27 +1071,28 @@ 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 { final String apiPath = '/account/targets/push'; - final Map apiParams = { - 'targetId': targetId, - - 'identifier': identifier, - - if (providerId != null) 'providerId': providerId, - - }; + final Map apiParams = { + 'targetId': targetId, + 'identifier': identifier, + if (providerId != null) 'providerId': providerId, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 @@ -1086,43 +1100,45 @@ 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, + 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Target.fromMap(res.data); + 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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 @@ -1134,32 +1150,31 @@ 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 { final String apiPath = '/account/tokens/email'; - final Map apiParams = { - 'userId': userId, + final Map apiParams = { + 'userId': userId, + 'email': email, + if (phrase != null) 'phrase': phrase, + }; - 'email': email, + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - if (phrase != null) 'phrase': phrase, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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); } /// Sends the user an email with a secret key for creating a session. If the @@ -1171,87 +1186,88 @@ 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 { final String apiPath = '/account/tokens/magic-url'; - final Map apiParams = { - 'userId': userId, - - 'email': email, - - if (url != null) 'url': url, - - if (phrase != null) 'phrase': phrase, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + 'userId': userId, + 'email': email, + if (url != null) 'url': url, + if (phrase != null) 'phrase': phrase, + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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); } /// 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 = { - - if (success != null) 'success': success, - - if (failure != null) 'failure': failure, - - if (scopes != null) 'scopes': scopes, - - - 'project': client.config['project'], - }; - - final List query = []; - - params.forEach((key, value) { - if (value is List) { - for (var item in value) { - query.add( + 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 = { + if (success != null) 'success': success, + if (failure != null) 'failure': failure, + if (scopes != null) '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); + } + } 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 @@ -1260,29 +1276,29 @@ 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 { final String apiPath = '/account/tokens/phone'; - final Map apiParams = { - 'userId': userId, - - 'phone': phone, + final Map apiParams = { + 'userId': userId, + 'phone': phone, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 @@ -1294,29 +1310,29 @@ 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 createEmailVerification({required String url}) async { final String apiPath = '/account/verifications/email'; - final Map apiParams = { - 'url': url, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + 'url': url, + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 send a verification message to your user email address @@ -1328,81 +1344,83 @@ 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. - /// - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.createEmailVerification` instead.') + /// + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.createEmailVerification` instead.') Future createVerification({required String url}) async { final String apiPath = '/account/verifications/email'; - final Map apiParams = { - 'url': url, + final Map apiParams = { + 'url': url, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 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 updateEmailVerification({required String userId, required String secret}) async { + Future updateEmailVerification( + {required String userId, required String secret}) async { final String apiPath = '/account/verifications/email'; - final Map apiParams = { - 'userId': userId, - - 'secret': secret, - - }; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - 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 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. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.updateEmailVerification` instead.') - Future updateVerification({required String userId, required String secret}) async { + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.updateEmailVerification` instead.') + Future updateVerification( + {required String userId, required String secret}) async { final String apiPath = '/account/verifications/email'; - final Map apiParams = { - 'userId': userId, - - 'secret': secret, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 @@ -1416,42 +1434,42 @@ class Account extends Service { Future createPhoneVerification() async { final String apiPath = '/account/verifications/phone'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 { final String apiPath = '/account/verifications/phone'; - final Map apiParams = { - 'userId': userId, - - 'secret': secret, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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); } } diff --git a/lib/services/avatars.dart b/lib/services/avatars.dart index 4dca3b16..cdd93e6e 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,139 +11,134 @@ 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 = { - - if (width != null) 'width': width, - - if (height != null) 'height': height, - - if (quality != null) 'quality': quality, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + if (width != null) 'width': width, + if (height != null) 'height': height, + if (quality != null) 'quality': quality, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 = { - - if (width != null) 'width': width, - - if (height != null) 'height': height, - - if (quality != null) 'quality': quality, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + if (width != null) 'width': width, + if (height != null) 'height': height, + if (quality != null) 'quality': quality, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 { final String apiPath = '/avatars/favicon'; - final Map params = { - - 'url': url, + final Map params = { + 'url': url, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { - - if (width != null) 'width': width, - - if (height != null) 'height': height, - - if (quality != null) 'quality': quality, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + if (width != null) 'width': width, + if (height != null) 'height': height, + if (quality != null) 'quality': quality, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 { final String apiPath = '/avatars/image'; - final Map params = { - - 'url': url, - - if (width != null) 'width': width, - - if (height != null) 'height': height, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + 'url': url, + if (width != null) 'width': width, + if (height != null) 'height': height, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 @@ -151,125 +146,117 @@ 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 { final String apiPath = '/avatars/initials'; - final Map params = { - - if (name != null) 'name': name, - - if (width != null) 'width': width, - - if (height != null) 'height': height, - - if (background != null) 'background': background, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + if (name != null) 'name': name, + if (width != null) 'width': width, + if (height != null) 'height': height, + if (background != null) 'background': background, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 { final String apiPath = '/avatars/qr'; - final Map params = { - - 'text': text, - - if (size != null) 'size': size, - - if (margin != null) 'margin': margin, - - if (download != null) 'download': download, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + 'text': text, + if (size != null) 'size': size, + if (margin != null) 'margin': margin, + if (download != null) 'download': download, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + final res = await client.call(HttpMethod.get, + path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// Use this endpoint to capture a screenshot of any website URL. This endpoint /// uses a headless browser to render the webpage and capture it as an image. - /// + /// /// You can configure the browser viewport size, theme, user agent, /// geolocation, permissions, and more. Capture either just the viewport or the /// full page scroll. - /// + /// /// When width and height are specified, the image is resized accordingly. If /// both dimensions are 0, the API provides an image at original size. If /// dimensions are not specified, the default viewport size is 1280x720px. - Future getScreenshot({required String url, Map? headers, int? viewportWidth, int? viewportHeight, double? scale, enums.BrowserTheme? theme, String? userAgent, bool? fullpage, String? locale, enums.Timezone? timezone, double? latitude, double? longitude, double? accuracy, bool? touch, List? permissions, int? sleep, int? width, int? height, int? quality, enums.ImageFormat? output}) async { + Future getScreenshot( + {required String url, + Map? headers, + int? viewportWidth, + int? viewportHeight, + double? scale, + enums.BrowserTheme? theme, + String? userAgent, + bool? fullpage, + String? locale, + enums.Timezone? timezone, + double? latitude, + double? longitude, + double? accuracy, + bool? touch, + List? permissions, + int? sleep, + int? width, + int? height, + int? quality, + enums.ImageFormat? output}) async { final String apiPath = '/avatars/screenshots'; - final Map params = { - - 'url': url, - - if (headers != null) 'headers': headers, - - if (viewportWidth != null) 'viewportWidth': viewportWidth, - - if (viewportHeight != null) 'viewportHeight': viewportHeight, - - if (scale != null) 'scale': scale, - - if (theme != null) 'theme': theme.value, - - if (userAgent != null) 'userAgent': userAgent, - - if (fullpage != null) 'fullpage': fullpage, - - if (locale != null) 'locale': locale, - - if (timezone != null) 'timezone': timezone.value, - - if (latitude != null) 'latitude': latitude, - - if (longitude != null) 'longitude': longitude, - - if (accuracy != null) 'accuracy': accuracy, - - if (touch != null) 'touch': touch, - - if (permissions != null) 'permissions': permissions.map((e) => e.value).toList(), - - if (sleep != null) 'sleep': sleep, - - if (width != null) 'width': width, - - if (height != null) 'height': height, - - if (quality != null) 'quality': quality, - - if (output != null) 'output': output.value, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + 'url': url, + if (headers != null) 'headers': headers, + if (viewportWidth != null) 'viewportWidth': viewportWidth, + if (viewportHeight != null) 'viewportHeight': viewportHeight, + if (scale != null) 'scale': scale, + if (theme != null) 'theme': theme.value, + if (userAgent != null) 'userAgent': userAgent, + if (fullpage != null) 'fullpage': fullpage, + if (locale != null) 'locale': locale, + if (timezone != null) 'timezone': timezone.value, + if (latitude != null) 'latitude': latitude, + if (longitude != null) 'longitude': longitude, + if (accuracy != null) 'accuracy': accuracy, + if (touch != null) 'touch': touch, + if (permissions != null) + 'permissions': permissions.map((e) => e.value).toList(), + if (sleep != null) 'sleep': sleep, + if (width != null) 'width': width, + if (height != null) 'height': height, + if (quality != null) 'quality': quality, + if (output != null) 'output': output.value, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + final res = await client.call(HttpMethod.get, + path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } } diff --git a/lib/services/databases.dart b/lib/services/databases.dart index 0bfd935a..0ff3fb72 100644 --- a/lib/services/databases.dart +++ b/lib/services/databases.dart @@ -1,339 +1,418 @@ 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); /// List transactions across all databases. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.listTransactions` instead.') - Future listTransactions({List? queries}) async { + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.listTransactions` instead.') + Future listTransactions( + {List? queries}) async { final String apiPath = '/databases/transactions'; - final Map apiParams = { - if (queries != null) 'queries': queries, + final Map apiParams = { + if (queries != null) 'queries': queries, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.TransactionList.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.TransactionList.fromMap(res.data); } /// Create a new transaction. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.createTransaction` instead.') + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.createTransaction` instead.') Future createTransaction({int? ttl}) async { final String apiPath = '/databases/transactions'; - final Map apiParams = { - if (ttl != null) 'ttl': ttl, - - }; + final Map apiParams = { + if (ttl != null) 'ttl': ttl, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Transaction.fromMap(res.data); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.Transaction.fromMap(res.data); } /// Get a transaction by its unique ID. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.getTransaction` instead.') - Future getTransaction({required String transactionId}) async { - final String apiPath = '/databases/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - }; + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.getTransaction` instead.') + Future getTransaction( + {required String transactionId}) async { + final String apiPath = '/databases/transactions/{transactionId}' + .replaceAll('{transactionId}', transactionId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - return models.Transaction.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.Transaction.fromMap(res.data); } /// Update a transaction, to either commit or roll back its operations. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.updateTransaction` instead.') - Future updateTransaction({required String transactionId, bool? commit, bool? rollback}) async { - final String apiPath = '/databases/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - if (commit != null) 'commit': commit, - - if (rollback != null) 'rollback': rollback, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Transaction.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.updateTransaction` instead.') + Future updateTransaction( + {required String transactionId, bool? commit, bool? rollback}) async { + final String apiPath = '/databases/transactions/{transactionId}' + .replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + if (commit != null) 'commit': commit, + if (rollback != null) 'rollback': rollback, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Transaction.fromMap(res.data); } /// Delete a transaction by its unique ID. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.deleteTransaction` instead.') + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.deleteTransaction` instead.') Future deleteTransaction({required String transactionId}) async { - final String apiPath = '/databases/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - }; + final String apiPath = '/databases/transactions/{transactionId}' + .replaceAll('{transactionId}', transactionId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - return res.data; + final res = await client.call(HttpMethod.delete, + path: apiPath, params: apiParams, headers: apiHeaders); + return res.data; } /// Create multiple operations in a single transaction. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.createOperations` instead.') - Future createOperations({required String transactionId, List? operations}) async { - final String apiPath = '/databases/transactions/{transactionId}/operations'.replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - if (operations != null) 'operations': operations, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Transaction.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.createOperations` instead.') + Future createOperations( + {required String transactionId, List? operations}) async { + final String apiPath = '/databases/transactions/{transactionId}/operations' + .replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + if (operations != null) 'operations': operations, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Transaction.fromMap(res.data); } /// 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, String? transactionId, bool? total, int? ttl}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - - if (transactionId != null) 'transactionId': transactionId, - - if (total != null) 'total': total, - - if (ttl != null) 'ttl': ttl, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, + String? transactionId, + bool? total, + int? ttl}) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + if (transactionId != null) 'transactionId': transactionId, + if (total != null) 'total': total, + if (ttl != null) 'ttl': ttl, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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, String? transactionId}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); - - final Map apiParams = { - 'documentId': documentId, - - 'data': data, - - 'permissions': permissions, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + String? transactionId}) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId); + + final Map apiParams = { + 'documentId': documentId, + 'data': data, + 'permissions': permissions, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, String? transactionId}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - - if (transactionId != null) 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, + String? transactionId}) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + if (transactionId != null) 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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, Map? data, List? permissions, String? transactionId}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - - final Map apiParams = { - if (data != null) 'data': data, - - 'permissions': permissions, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + Map? data, + List? permissions, + String? transactionId}) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId); + + final Map apiParams = { + if (data != null) 'data': data, + 'permissions': permissions, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, String? transactionId}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - - final Map apiParams = { - if (data != null) 'data': data, - - 'permissions': permissions, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + String? transactionId}) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId); + + final Map apiParams = { + if (data != null) 'data': data, + 'permissions': permissions, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, String? transactionId}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - - final Map apiParams = { - if (transactionId != null) 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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, + String? transactionId}) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId); + + final Map apiParams = { + if (transactionId != null) 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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, String? transactionId}) 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 = { - if (value != null) 'value': value, - - 'min': min, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + String? transactionId}) 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 = { + if (value != null) 'value': value, + 'min': min, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, String? transactionId}) 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 = { - if (value != null) 'value': value, - - 'max': max, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + String? transactionId}) 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 = { + if (value != null) 'value': value, + 'max': max, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); } } diff --git a/lib/services/functions.dart b/lib/services/functions.dart index 0640f80f..ed97921b 100644 --- a/lib/services/functions.dart +++ b/lib/services/functions.dart @@ -1,82 +1,87 @@ 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, bool? total}) async { - final String apiPath = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); + Future listExecutions( + {required String functionId, List? queries, bool? total}) async { + final String apiPath = '/functions/{functionId}/executions' + .replaceAll('{functionId}', functionId); - final Map apiParams = { - if (queries != null) 'queries': queries, + final Map apiParams = { + if (queries != null) 'queries': queries, + if (total != null) 'total': total, + }; - if (total != null) 'total': total, + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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 = { - if (body != null) 'body': body, - - if (xasync != null) 'async': xasync, - - if (path != null) 'path': path, - - if (method != null) 'method': method.value, - - if (headers != null) 'headers': headers, - - 'scheduledAt': scheduledAt, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + if (body != null) 'body': body, + if (xasync != null) 'async': xasync, + if (path != null) 'path': path, + if (method != null) 'method': method.value, + if (headers != null) 'headers': headers, + 'scheduledAt': scheduledAt, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 = { - }; + Future getExecution( + {required String functionId, required String executionId}) async { + final String apiPath = '/functions/{functionId}/executions/{executionId}' + .replaceAll('{functionId}', functionId) + .replaceAll('{executionId}', executionId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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); } } diff --git a/lib/services/graphql.dart b/lib/services/graphql.dart index 978331fa..c86f3719 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,39 +10,41 @@ class Graphql extends Service { Future query({required Map query}) async { final String apiPath = '/graphql'; - final Map apiParams = { - 'query': query, + final Map apiParams = { + 'query': query, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'x-sdk-graphql': 'true', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'x-sdk-graphql': 'true', 'content-type': 'application/json', 'accept': '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 { final String apiPath = '/graphql/mutation'; - final Map apiParams = { - 'query': query, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'x-sdk-graphql': 'true', 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + 'query': query, + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'x-sdk-graphql': 'true', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - return res.data; + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); + return res.data; } } diff --git a/lib/services/locale.dart b/lib/services/locale.dart index c45a1269..87ea162e 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 { final String apiPath = '/locale'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -34,18 +33,17 @@ class Locale extends Service { Future listCodes() async { final String apiPath = '/locale/codes'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -53,18 +51,17 @@ class Locale extends Service { Future listContinents() async { final String apiPath = '/locale/continents'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -72,18 +69,17 @@ class Locale extends Service { Future listCountries() async { final String apiPath = '/locale/countries'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -91,18 +87,17 @@ class Locale extends Service { Future listCountriesEU() async { final String apiPath = '/locale/countries/eu'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -110,18 +105,17 @@ class Locale extends Service { Future listCountriesPhones() async { final String apiPath = '/locale/countries/phones'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -130,18 +124,17 @@ class Locale extends Service { Future listCurrencies() async { final String apiPath = '/locale/currencies'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -149,17 +142,16 @@ class Locale extends Service { Future listLanguages() async { final String apiPath = '/locale/languages'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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); } } diff --git a/lib/services/messaging.dart b/lib/services/messaging.dart index 3dffe41b..61ecefee 100644 --- a/lib/services/messaging.dart +++ b/lib/services/messaging.dart @@ -1,48 +1,54 @@ 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - return res.data; + final res = await client.call(HttpMethod.delete, + path: apiPath, params: apiParams, headers: apiHeaders); + return res.data; } } diff --git a/lib/services/presences.dart b/lib/services/presences.dart index 088700cb..1c9b651b 100644 --- a/lib/services/presences.dart +++ b/lib/services/presences.dart @@ -5,123 +5,127 @@ class Presences extends Service { Presences(super.client); /// List presence logs. Expired entries are filtered out automatically. - /// - Future list({List? queries, bool? total, int? ttl}) async { + /// + Future list( + {List? queries, bool? total, int? ttl}) async { final String apiPath = '/presences'; - final Map apiParams = { - if (queries != null) 'queries': queries, + final Map apiParams = { + if (queries != null) 'queries': queries, + if (total != null) 'total': total, + if (ttl != null) 'ttl': ttl, + }; - if (total != null) 'total': total, + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - if (ttl != null) 'ttl': ttl, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.PresenceList.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.PresenceList.fromMap(res.data); } /// Get a presence log by its unique ID. Entries whose `expiresAt` is in the /// past are treated as not found. - /// + /// Future get({required String presenceId}) async { - final String apiPath = '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); + final String apiPath = + '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Presence.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.Presence.fromMap(res.data); } /// Create or update a presence log by its user ID. - /// - Future upsert({required String presenceId, required String status, List? permissions, String? expiresAt, Map? metadata}) async { - final String apiPath = '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); - - final Map apiParams = { - 'status': status, - - if (permissions != null) 'permissions': permissions, - - if (expiresAt != null) 'expiresAt': expiresAt, - - if (metadata != null) 'metadata': metadata, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Presence.fromMap(res.data); - + /// + Future upsert( + {required String presenceId, + required String status, + List? permissions, + String? expiresAt, + Map? metadata}) async { + final String apiPath = + '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); + + final Map apiParams = { + 'status': status, + if (permissions != null) 'permissions': permissions, + if (expiresAt != null) 'expiresAt': expiresAt, + if (metadata != null) 'metadata': metadata, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Presence.fromMap(res.data); } /// Update a presence log by its unique ID. Using the patch method you can pass /// only specific fields that will get updated. - /// - Future update({required String presenceId, String? status, String? expiresAt, Map? metadata, List? permissions, bool? purge}) async { - final String apiPath = '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); - - final Map apiParams = { - if (status != null) 'status': status, - - if (expiresAt != null) 'expiresAt': expiresAt, - - if (metadata != null) 'metadata': metadata, - - if (permissions != null) 'permissions': permissions, - - if (purge != null) 'purge': purge, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Presence.fromMap(res.data); - + /// + Future update( + {required String presenceId, + String? status, + String? expiresAt, + Map? metadata, + List? permissions, + bool? purge}) async { + final String apiPath = + '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); + + final Map apiParams = { + if (status != null) 'status': status, + if (expiresAt != null) 'expiresAt': expiresAt, + if (metadata != null) 'metadata': metadata, + if (permissions != null) 'permissions': permissions, + if (purge != null) 'purge': purge, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Presence.fromMap(res.data); } /// Delete a presence log by its unique ID. - /// + /// Future delete({required String presenceId}) async { - final String apiPath = '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); - - final Map apiParams = { - }; + final String apiPath = + '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - return res.data; + final res = await client.call(HttpMethod.delete, + path: apiPath, params: apiParams, headers: apiHeaders); + return res.data; } } diff --git a/lib/services/storage.dart b/lib/services/storage.dart index c9499a99..cdb626de 100644 --- a/lib/services/storage.dart +++ b/lib/services/storage.dart @@ -1,166 +1,178 @@ 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, bool? total}) async { - final String apiPath = '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - - if (search != null) 'search': search, - - if (total != null) 'total': total, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, + bool? total}) async { + final String apiPath = + '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + if (search != null) 'search': search, + if (total != null) 'total': total, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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, - - if (permissions != null) 'permissions': permissions, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'multipart/form-data', 'accept': 'application/json', - }; - - 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, + if (permissions != null) 'permissions': permissions, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'multipart/form-data', + 'accept': 'application/json', + }; + + 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); + 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 apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.File.fromMap(res.data); + 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 = { - if (name != null) 'name': name, - - 'permissions': permissions, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + if (name != null) 'name': name, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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 = { - - if (token != null) 'token': token, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + if (token != null) 'token': token, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 @@ -168,60 +180,64 @@ 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 = { - - if (width != null) 'width': width, - - if (height != null) 'height': height, - - if (gravity != null) 'gravity': gravity.value, - - if (quality != null) 'quality': quality, - - if (borderWidth != null) 'borderWidth': borderWidth, - - if (borderColor != null) 'borderColor': borderColor, - - if (borderRadius != null) 'borderRadius': borderRadius, - - if (opacity != null) 'opacity': opacity, - - if (rotation != null) 'rotation': rotation, - - if (background != null) 'background': background, - - if (output != null) 'output': output.value, - - if (token != null) 'token': token, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + if (width != null) 'width': width, + if (height != null) 'height': height, + if (gravity != null) 'gravity': gravity.value, + if (quality != null) 'quality': quality, + if (borderWidth != null) 'borderWidth': borderWidth, + if (borderColor != null) 'borderColor': borderColor, + if (borderRadius != null) 'borderRadius': borderRadius, + if (opacity != null) 'opacity': opacity, + if (rotation != null) 'rotation': rotation, + if (background != null) 'background': background, + if (output != null) 'output': output.value, + if (token != null) 'token': token, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 = { - - if (token != null) 'token': token, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + if (token != null) 'token': token, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + final res = await client.call(HttpMethod.get, + path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } } diff --git a/lib/services/tables_db.dart b/lib/services/tables_db.dart index 42572021..8b6284b3 100644 --- a/lib/services/tables_db.dart +++ b/lib/services/tables_db.dart @@ -5,319 +5,382 @@ class TablesDB extends Service { TablesDB(super.client); /// List transactions across all databases. - Future listTransactions({List? queries}) async { + Future listTransactions( + {List? queries}) async { final String apiPath = '/tablesdb/transactions'; - final Map apiParams = { - if (queries != null) 'queries': queries, + final Map apiParams = { + if (queries != null) 'queries': queries, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.TransactionList.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.TransactionList.fromMap(res.data); } /// Create a new transaction. Future createTransaction({int? ttl}) async { final String apiPath = '/tablesdb/transactions'; - final Map apiParams = { - if (ttl != null) 'ttl': ttl, - - }; + final Map apiParams = { + if (ttl != null) 'ttl': ttl, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Transaction.fromMap(res.data); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.Transaction.fromMap(res.data); } /// Get a transaction by its unique ID. - Future getTransaction({required String transactionId}) async { - final String apiPath = '/tablesdb/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - }; + Future getTransaction( + {required String transactionId}) async { + final String apiPath = '/tablesdb/transactions/{transactionId}' + .replaceAll('{transactionId}', transactionId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - return models.Transaction.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.Transaction.fromMap(res.data); } /// Update a transaction, to either commit or roll back its operations. - Future updateTransaction({required String transactionId, bool? commit, bool? rollback}) async { - final String apiPath = '/tablesdb/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - if (commit != null) 'commit': commit, - - if (rollback != null) 'rollback': rollback, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Transaction.fromMap(res.data); - + Future updateTransaction( + {required String transactionId, bool? commit, bool? rollback}) async { + final String apiPath = '/tablesdb/transactions/{transactionId}' + .replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + if (commit != null) 'commit': commit, + if (rollback != null) 'rollback': rollback, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Transaction.fromMap(res.data); } /// Delete a transaction by its unique ID. Future deleteTransaction({required String transactionId}) async { - final String apiPath = '/tablesdb/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - }; + final String apiPath = '/tablesdb/transactions/{transactionId}' + .replaceAll('{transactionId}', transactionId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - return res.data; + final res = await client.call(HttpMethod.delete, + path: apiPath, params: apiParams, headers: apiHeaders); + return res.data; } /// Create multiple operations in a single transaction. - Future createOperations({required String transactionId, List? operations}) async { - final String apiPath = '/tablesdb/transactions/{transactionId}/operations'.replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - if (operations != null) 'operations': operations, - - }; + Future createOperations( + {required String transactionId, List? operations}) async { + final String apiPath = '/tablesdb/transactions/{transactionId}/operations' + .replaceAll('{transactionId}', transactionId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + if (operations != null) 'operations': operations, + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - return models.Transaction.fromMap(res.data); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.Transaction.fromMap(res.data); } /// 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, String? transactionId, bool? total, int? ttl}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - - if (transactionId != null) 'transactionId': transactionId, - - if (total != null) 'total': total, - - if (ttl != null) 'ttl': ttl, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, + String? transactionId, + bool? total, + int? ttl}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + if (transactionId != null) 'transactionId': transactionId, + if (total != null) 'total': total, + if (ttl != null) 'ttl': ttl, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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/references/cloud/server-dart/tablesDB#createTable) /// API or directly from your database console. - Future createRow({required String databaseId, required String tableId, required String rowId, required Map data, List? permissions, String? transactionId}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); - - final Map apiParams = { - 'rowId': rowId, - - 'data': data, - - 'permissions': permissions, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + String? transactionId}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId); + + final Map apiParams = { + 'rowId': rowId, + 'data': data, + 'permissions': permissions, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, String? transactionId}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - - if (transactionId != null) 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, + String? transactionId}) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + if (transactionId != null) 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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/references/cloud/server-dart/tablesDB#createTable) /// API or directly from your database console. - Future upsertRow({required String databaseId, required String tableId, required String rowId, Map? data, List? permissions, String? transactionId}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - if (data != null) 'data': data, - - 'permissions': permissions, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + String? transactionId}) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId); + + final Map apiParams = { + if (data != null) 'data': data, + 'permissions': permissions, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, String? transactionId}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - if (data != null) 'data': data, - - 'permissions': permissions, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + String? transactionId}) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId); + + final Map apiParams = { + if (data != null) 'data': data, + 'permissions': permissions, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, String? transactionId}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - if (transactionId != null) 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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, + String? transactionId}) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId); + + final Map apiParams = { + if (transactionId != null) 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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, String? transactionId}) 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 = { - if (value != null) 'value': value, - - 'min': min, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + String? transactionId}) 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 = { + if (value != null) 'value': value, + 'min': min, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, String? transactionId}) 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 = { - if (value != null) 'value': value, - - 'max': max, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + String? transactionId}) 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 = { + if (value != null) 'value': value, + 'max': max, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); } } diff --git a/lib/services/teams.dart b/lib/services/teams.dart index 27bc561e..1f4022f6 100644 --- a/lib/services/teams.dart +++ b/lib/services/teams.dart @@ -1,98 +1,97 @@ 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); /// Get a list of all the teams in which the current user is a member. You can /// use the parameters to filter your results. - Future list({List? queries, String? search, bool? total}) async { + Future list( + {List? queries, String? search, bool? total}) async { final String apiPath = '/teams'; - final Map apiParams = { - if (queries != null) 'queries': queries, + final Map apiParams = { + if (queries != null) 'queries': queries, + if (search != null) 'search': search, + if (total != null) 'total': total, + }; - if (search != null) 'search': search, + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - if (total != null) 'total': total, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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 { final String apiPath = '/teams'; - final Map apiParams = { - 'teamId': teamId, - - 'name': name, - - if (roles != null) 'roles': roles, - - }; + final Map apiParams = { + 'teamId': teamId, + 'name': name, + if (roles != null) 'roles': roles, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 apiParams = { + 'name': name, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - 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 @@ -100,44 +99,45 @@ class Teams extends Service { Future delete({required String teamId}) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - 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, bool? total}) async { - final String apiPath = '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - - if (search != null) 'search': search, - - if (total != null) 'total': total, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, + bool? total}) async { + final String apiPath = + '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + if (search != null) 'search': search, + if (total != null) 'total': total, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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 @@ -146,180 +146,199 @@ 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 = { - if (email != null) 'email': email, - - if (userId != null) 'userId': userId, - - if (phone != null) 'phone': phone, - - 'roles': roles, - - if (url != null) 'url': url, - - if (name != null) 'name': name, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + if (email != null) 'email': email, + if (userId != null) 'userId': userId, + if (phone != null) 'phone': phone, + 'roles': roles, + if (url != null) 'url': url, + if (name != null) 'name': name, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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); + 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 apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 = { - }; + Future deleteMembership( + {required String teamId, required String membershipId}) async { + final String apiPath = '/teams/{teamId}/memberships/{membershipId}' + .replaceAll('{teamId}', teamId) + .replaceAll('{membershipId}', membershipId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + 'prefs': prefs, + }; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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); } } diff --git a/lib/src/client.dart b/lib/src/client.dart index 65b2f044..cc077e56 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -27,7 +27,8 @@ abstract class Client { factory Client({ String endPoint = 'https://cloud.appwrite.io/v1', bool selfSigned = false, - }) => createClient(endPoint: endPoint, selfSigned: selfSigned); + }) => + createClient(endPoint: endPoint, selfSigned: selfSigned); /// Handle OAuth2 session creation. Future webAuth(Uri url, {String? callbackUrlScheme}); @@ -107,7 +108,6 @@ abstract class Client { /// Send a ping to project as part of onboarding. Future ping(); - /// Send the API request. Future call( HttpMethod method, { diff --git a/lib/src/client_base.dart b/lib/src/client_base.dart index 9e964a79..da1a5225 100644 --- a/lib/src/client_base.dart +++ b/lib/src/client_base.dart @@ -6,26 +6,33 @@ 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); + /// The user cookie to authenticate with. Used by SDKs that forward an incoming Cookie header in server-side runtimes. @override ClientBase setCookie(value); + /// Impersonate a user by ID @override ClientBase setImpersonateUserId(value); + /// Impersonate a user by email @override ClientBase setImpersonateUserEmail(value); + /// Impersonate a user by phone @override ClientBase setImpersonateUserPhone(value); diff --git a/lib/src/client_browser.dart b/lib/src/client_browser.dart index 2f4c7b48..32945efd 100644 --- a/lib/src/client_browser.dart +++ b/lib/src/client_browser.dart @@ -62,6 +62,7 @@ class ClientBrowser extends ClientBase with ClientMixin { config['project'] = value; return this; } + /// Your secret JSON Web Token @override ClientBrowser setJWT(value) { @@ -69,12 +70,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) { @@ -82,6 +85,7 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Session', value); return this; } + /// Your secret dev API key @override ClientBrowser setDevKey(value) { @@ -89,6 +93,7 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Dev-Key', value); return this; } + /// The user cookie to authenticate with. Used by SDKs that forward an incoming Cookie header in server-side runtimes. @override ClientBrowser setCookie(value) { @@ -96,6 +101,7 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('Cookie', value); return this; } + /// Impersonate a user by ID @override ClientBrowser setImpersonateUserId(value) { @@ -103,6 +109,7 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Impersonate-User-Id', value); return this; } + /// Impersonate a user by email @override ClientBrowser setImpersonateUserEmail(value) { @@ -110,6 +117,7 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Impersonate-User-Email', value); return this; } + /// Impersonate a user by phone @override ClientBrowser setImpersonateUserPhone(value) { @@ -219,7 +227,8 @@ class ClientBrowser extends ClientBase with ClientMixin { final totalChunks = (size / chunkSize).ceil(); - Future uploadChunk(int index, int start, int end, String? id) async { + Future uploadChunk( + int index, int start, int end, String? id) async { List chunk = []; chunk = file.bytes!.getRange(start, end).toList(); @@ -257,7 +266,9 @@ class ClientBrowser extends ClientBase with ClientMixin { bool isUploadComplete(Response response) { final chunksUploaded = response.data['chunksUploaded']; final chunksTotal = response.data['chunksTotal'] ?? totalChunks; - return chunksUploaded is num && chunksTotal is num && chunksUploaded >= chunksTotal; + return chunksUploaded is num && + chunksTotal is num && + chunksUploaded >= chunksTotal; } final progress = UploadProgress( diff --git a/lib/src/client_io.dart b/lib/src/client_io.dart index 6e6e2ee8..78a368ae 100644 --- a/lib/src/client_io.dart +++ b/lib/src/client_io.dart @@ -88,6 +88,7 @@ class ClientIO extends ClientBase with ClientMixin { config['project'] = value; return this; } + /// Your secret JSON Web Token @override ClientIO setJWT(value) { @@ -95,12 +96,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) { @@ -108,6 +111,7 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Session', value); return this; } + /// Your secret dev API key @override ClientIO setDevKey(value) { @@ -115,6 +119,7 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Dev-Key', value); return this; } + /// The user cookie to authenticate with. Used by SDKs that forward an incoming Cookie header in server-side runtimes. @override ClientIO setCookie(value) { @@ -122,6 +127,7 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('Cookie', value); return this; } + /// Impersonate a user by ID @override ClientIO setImpersonateUserId(value) { @@ -129,6 +135,7 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Impersonate-User-Id', value); return this; } + /// Impersonate a user by email @override ClientIO setImpersonateUserEmail(value) { @@ -136,6 +143,7 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Impersonate-User-Email', value); return this; } + /// Impersonate a user by phone @override ClientIO setImpersonateUserPhone(value) { @@ -394,7 +402,9 @@ class ClientIO extends ClientBase with ClientMixin { bool isUploadComplete(Response response) { final chunksUploaded = response.data['chunksUploaded']; final chunksTotal = response.data['chunksTotal'] ?? totalChunks; - return chunksUploaded is num && chunksTotal is num && chunksUploaded >= chunksTotal; + return chunksUploaded is num && + chunksTotal is num && + chunksUploaded >= chunksTotal; } final progress = UploadProgress( @@ -418,7 +428,8 @@ class ClientIO extends ClientBase with ClientMixin { var nextChunk = 0; Future uploadNext() async { - final raf = file.bytes == null ? await iofile!.open(mode: FileMode.read) : null; + final raf = + file.bytes == null ? await iofile!.open(mode: FileMode.read) : null; try { while (nextChunk < chunks.length) { final chunk = chunks[nextChunk++]; diff --git a/lib/src/client_mixin.dart b/lib/src/client_mixin.dart index 40484946..89aad359 100644 --- a/lib/src/client_mixin.dart +++ b/lib/src/client_mixin.dart @@ -12,7 +12,6 @@ mixin ClientMixin { required Map headers, required Map params, }) { - http.BaseRequest request = http.Request(method.name(), uri); if (headers['content-type'] == 'multipart/form-data') { request = http.MultipartRequest(method.name(), uri); @@ -128,9 +127,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/browser_permission.dart b/lib/src/enums/browser_permission.dart index 765b3e0c..fb4983db 100644 --- a/lib/src/enums/browser_permission.dart +++ b/lib/src/enums/browser_permission.dart @@ -1,32 +1,30 @@ part of '../../enums.dart'; enum BrowserPermission { - geolocation(value: 'geolocation'), - camera(value: 'camera'), - microphone(value: 'microphone'), - notifications(value: 'notifications'), - midi(value: 'midi'), - push(value: 'push'), - clipboardRead(value: 'clipboard-read'), - clipboardWrite(value: 'clipboard-write'), - paymentHandler(value: 'payment-handler'), - usb(value: 'usb'), - bluetooth(value: 'bluetooth'), - accelerometer(value: 'accelerometer'), - gyroscope(value: 'gyroscope'), - magnetometer(value: 'magnetometer'), - ambientLightSensor(value: 'ambient-light-sensor'), - backgroundSync(value: 'background-sync'), - persistentStorage(value: 'persistent-storage'), - screenWakeLock(value: 'screen-wake-lock'), - webShare(value: 'web-share'), - xrSpatialTracking(value: 'xr-spatial-tracking'); + geolocation(value: 'geolocation'), + camera(value: 'camera'), + microphone(value: 'microphone'), + notifications(value: 'notifications'), + midi(value: 'midi'), + push(value: 'push'), + clipboardRead(value: 'clipboard-read'), + clipboardWrite(value: 'clipboard-write'), + paymentHandler(value: 'payment-handler'), + usb(value: 'usb'), + bluetooth(value: 'bluetooth'), + accelerometer(value: 'accelerometer'), + gyroscope(value: 'gyroscope'), + magnetometer(value: 'magnetometer'), + ambientLightSensor(value: 'ambient-light-sensor'), + backgroundSync(value: 'background-sync'), + persistentStorage(value: 'persistent-storage'), + screenWakeLock(value: 'screen-wake-lock'), + webShare(value: 'web-share'), + xrSpatialTracking(value: 'xr-spatial-tracking'); - const BrowserPermission({ - required this.value - }); + const BrowserPermission({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_theme.dart b/lib/src/enums/browser_theme.dart index e81a0f68..1e059c2c 100644 --- a/lib/src/enums/browser_theme.dart +++ b/lib/src/enums/browser_theme.dart @@ -1,14 +1,12 @@ part of '../../enums.dart'; enum BrowserTheme { - light(value: 'light'), - dark(value: 'dark'); + light(value: 'light'), + dark(value: 'dark'); - const BrowserTheme({ - required this.value - }); + const BrowserTheme({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/execution_status.dart b/lib/src/enums/execution_status.dart index f54859c9..7ea9865e 100644 --- a/lib/src/enums/execution_status.dart +++ b/lib/src/enums/execution_status.dart @@ -1,17 +1,15 @@ part of '../../enums.dart'; enum ExecutionStatus { - waiting(value: 'waiting'), - processing(value: 'processing'), - completed(value: 'completed'), - failed(value: 'failed'), - scheduled(value: 'scheduled'); + waiting(value: 'waiting'), + processing(value: 'processing'), + completed(value: 'completed'), + failed(value: 'failed'), + scheduled(value: 'scheduled'); - const ExecutionStatus({ - required this.value - }); + const ExecutionStatus({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_trigger.dart b/lib/src/enums/execution_trigger.dart index 8a14ae60..fb05eb7d 100644 --- a/lib/src/enums/execution_trigger.dart +++ b/lib/src/enums/execution_trigger.dart @@ -1,15 +1,13 @@ part of '../../enums.dart'; enum ExecutionTrigger { - http(value: 'http'), - schedule(value: 'schedule'), - event(value: 'event'); + http(value: 'http'), + schedule(value: 'schedule'), + event(value: 'event'); - const ExecutionTrigger({ - required this.value - }); + const ExecutionTrigger({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 8ed7ecff..b88e0a55 100644 --- a/lib/src/enums/o_auth_provider.dart +++ b/lib/src/enums/o_auth_provider.dart @@ -1,55 +1,53 @@ 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'), - fusionauth(value: 'fusionauth'), - github(value: 'github'), - gitlab(value: 'gitlab'), - google(value: 'google'), - keycloak(value: 'keycloak'), - kick(value: 'kick'), - 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'), - x(value: 'x'), - yahoo(value: 'yahoo'), - yammer(value: 'yammer'), - yandex(value: 'yandex'), - zoho(value: 'zoho'), - zoom(value: 'zoom'); + 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'), + fusionauth(value: 'fusionauth'), + github(value: 'github'), + gitlab(value: 'gitlab'), + google(value: 'google'), + keycloak(value: 'keycloak'), + kick(value: 'kick'), + 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'), + x(value: 'x'), + yahoo(value: 'yahoo'), + yammer(value: 'yammer'), + yandex(value: 'yandex'), + zoho(value: 'zoho'), + zoom(value: 'zoom'); - 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/enums/timezone.dart b/lib/src/enums/timezone.dart index 4a8de1ce..d5d8d94a 100644 --- a/lib/src/enums/timezone.dart +++ b/lib/src/enums/timezone.dart @@ -1,431 +1,429 @@ part of '../../enums.dart'; enum Timezone { - africaAbidjan(value: 'africa/abidjan'), - africaAccra(value: 'africa/accra'), - africaAddisAbaba(value: 'africa/addis_ababa'), - africaAlgiers(value: 'africa/algiers'), - africaAsmara(value: 'africa/asmara'), - africaBamako(value: 'africa/bamako'), - africaBangui(value: 'africa/bangui'), - africaBanjul(value: 'africa/banjul'), - africaBissau(value: 'africa/bissau'), - africaBlantyre(value: 'africa/blantyre'), - africaBrazzaville(value: 'africa/brazzaville'), - africaBujumbura(value: 'africa/bujumbura'), - africaCairo(value: 'africa/cairo'), - africaCasablanca(value: 'africa/casablanca'), - africaCeuta(value: 'africa/ceuta'), - africaConakry(value: 'africa/conakry'), - africaDakar(value: 'africa/dakar'), - africaDarEsSalaam(value: 'africa/dar_es_salaam'), - africaDjibouti(value: 'africa/djibouti'), - africaDouala(value: 'africa/douala'), - africaElAaiun(value: 'africa/el_aaiun'), - africaFreetown(value: 'africa/freetown'), - africaGaborone(value: 'africa/gaborone'), - africaHarare(value: 'africa/harare'), - africaJohannesburg(value: 'africa/johannesburg'), - africaJuba(value: 'africa/juba'), - africaKampala(value: 'africa/kampala'), - africaKhartoum(value: 'africa/khartoum'), - africaKigali(value: 'africa/kigali'), - africaKinshasa(value: 'africa/kinshasa'), - africaLagos(value: 'africa/lagos'), - africaLibreville(value: 'africa/libreville'), - africaLome(value: 'africa/lome'), - africaLuanda(value: 'africa/luanda'), - africaLubumbashi(value: 'africa/lubumbashi'), - africaLusaka(value: 'africa/lusaka'), - africaMalabo(value: 'africa/malabo'), - africaMaputo(value: 'africa/maputo'), - africaMaseru(value: 'africa/maseru'), - africaMbabane(value: 'africa/mbabane'), - africaMogadishu(value: 'africa/mogadishu'), - africaMonrovia(value: 'africa/monrovia'), - africaNairobi(value: 'africa/nairobi'), - africaNdjamena(value: 'africa/ndjamena'), - africaNiamey(value: 'africa/niamey'), - africaNouakchott(value: 'africa/nouakchott'), - africaOuagadougou(value: 'africa/ouagadougou'), - africaPortoNovo(value: 'africa/porto-novo'), - africaSaoTome(value: 'africa/sao_tome'), - africaTripoli(value: 'africa/tripoli'), - africaTunis(value: 'africa/tunis'), - africaWindhoek(value: 'africa/windhoek'), - americaAdak(value: 'america/adak'), - americaAnchorage(value: 'america/anchorage'), - americaAnguilla(value: 'america/anguilla'), - americaAntigua(value: 'america/antigua'), - americaAraguaina(value: 'america/araguaina'), - americaArgentinaBuenosAires(value: 'america/argentina/buenos_aires'), - americaArgentinaCatamarca(value: 'america/argentina/catamarca'), - americaArgentinaCordoba(value: 'america/argentina/cordoba'), - americaArgentinaJujuy(value: 'america/argentina/jujuy'), - americaArgentinaLaRioja(value: 'america/argentina/la_rioja'), - americaArgentinaMendoza(value: 'america/argentina/mendoza'), - americaArgentinaRioGallegos(value: 'america/argentina/rio_gallegos'), - americaArgentinaSalta(value: 'america/argentina/salta'), - americaArgentinaSanJuan(value: 'america/argentina/san_juan'), - americaArgentinaSanLuis(value: 'america/argentina/san_luis'), - americaArgentinaTucuman(value: 'america/argentina/tucuman'), - americaArgentinaUshuaia(value: 'america/argentina/ushuaia'), - americaAruba(value: 'america/aruba'), - americaAsuncion(value: 'america/asuncion'), - americaAtikokan(value: 'america/atikokan'), - americaBahia(value: 'america/bahia'), - americaBahiaBanderas(value: 'america/bahia_banderas'), - americaBarbados(value: 'america/barbados'), - americaBelem(value: 'america/belem'), - americaBelize(value: 'america/belize'), - americaBlancSablon(value: 'america/blanc-sablon'), - americaBoaVista(value: 'america/boa_vista'), - americaBogota(value: 'america/bogota'), - americaBoise(value: 'america/boise'), - americaCambridgeBay(value: 'america/cambridge_bay'), - americaCampoGrande(value: 'america/campo_grande'), - americaCancun(value: 'america/cancun'), - americaCaracas(value: 'america/caracas'), - americaCayenne(value: 'america/cayenne'), - americaCayman(value: 'america/cayman'), - americaChicago(value: 'america/chicago'), - americaChihuahua(value: 'america/chihuahua'), - americaCiudadJuarez(value: 'america/ciudad_juarez'), - americaCostaRica(value: 'america/costa_rica'), - americaCoyhaique(value: 'america/coyhaique'), - americaCreston(value: 'america/creston'), - americaCuiaba(value: 'america/cuiaba'), - americaCuracao(value: 'america/curacao'), - americaDanmarkshavn(value: 'america/danmarkshavn'), - americaDawson(value: 'america/dawson'), - americaDawsonCreek(value: 'america/dawson_creek'), - americaDenver(value: 'america/denver'), - americaDetroit(value: 'america/detroit'), - americaDominica(value: 'america/dominica'), - americaEdmonton(value: 'america/edmonton'), - americaEirunepe(value: 'america/eirunepe'), - americaElSalvador(value: 'america/el_salvador'), - americaFortNelson(value: 'america/fort_nelson'), - americaFortaleza(value: 'america/fortaleza'), - americaGlaceBay(value: 'america/glace_bay'), - americaGooseBay(value: 'america/goose_bay'), - americaGrandTurk(value: 'america/grand_turk'), - americaGrenada(value: 'america/grenada'), - americaGuadeloupe(value: 'america/guadeloupe'), - americaGuatemala(value: 'america/guatemala'), - americaGuayaquil(value: 'america/guayaquil'), - americaGuyana(value: 'america/guyana'), - americaHalifax(value: 'america/halifax'), - americaHavana(value: 'america/havana'), - americaHermosillo(value: 'america/hermosillo'), - americaIndianaIndianapolis(value: 'america/indiana/indianapolis'), - americaIndianaKnox(value: 'america/indiana/knox'), - americaIndianaMarengo(value: 'america/indiana/marengo'), - americaIndianaPetersburg(value: 'america/indiana/petersburg'), - americaIndianaTellCity(value: 'america/indiana/tell_city'), - americaIndianaVevay(value: 'america/indiana/vevay'), - americaIndianaVincennes(value: 'america/indiana/vincennes'), - americaIndianaWinamac(value: 'america/indiana/winamac'), - americaInuvik(value: 'america/inuvik'), - americaIqaluit(value: 'america/iqaluit'), - americaJamaica(value: 'america/jamaica'), - americaJuneau(value: 'america/juneau'), - americaKentuckyLouisville(value: 'america/kentucky/louisville'), - americaKentuckyMonticello(value: 'america/kentucky/monticello'), - americaKralendijk(value: 'america/kralendijk'), - americaLaPaz(value: 'america/la_paz'), - americaLima(value: 'america/lima'), - americaLosAngeles(value: 'america/los_angeles'), - americaLowerPrinces(value: 'america/lower_princes'), - americaMaceio(value: 'america/maceio'), - americaManagua(value: 'america/managua'), - americaManaus(value: 'america/manaus'), - americaMarigot(value: 'america/marigot'), - americaMartinique(value: 'america/martinique'), - americaMatamoros(value: 'america/matamoros'), - americaMazatlan(value: 'america/mazatlan'), - americaMenominee(value: 'america/menominee'), - americaMerida(value: 'america/merida'), - americaMetlakatla(value: 'america/metlakatla'), - americaMexicoCity(value: 'america/mexico_city'), - americaMiquelon(value: 'america/miquelon'), - americaMoncton(value: 'america/moncton'), - americaMonterrey(value: 'america/monterrey'), - americaMontevideo(value: 'america/montevideo'), - americaMontserrat(value: 'america/montserrat'), - americaNassau(value: 'america/nassau'), - americaNewYork(value: 'america/new_york'), - americaNome(value: 'america/nome'), - americaNoronha(value: 'america/noronha'), - americaNorthDakotaBeulah(value: 'america/north_dakota/beulah'), - americaNorthDakotaCenter(value: 'america/north_dakota/center'), - americaNorthDakotaNewSalem(value: 'america/north_dakota/new_salem'), - americaNuuk(value: 'america/nuuk'), - americaOjinaga(value: 'america/ojinaga'), - americaPanama(value: 'america/panama'), - americaParamaribo(value: 'america/paramaribo'), - americaPhoenix(value: 'america/phoenix'), - americaPortAuPrince(value: 'america/port-au-prince'), - americaPortOfSpain(value: 'america/port_of_spain'), - americaPortoVelho(value: 'america/porto_velho'), - americaPuertoRico(value: 'america/puerto_rico'), - americaPuntaArenas(value: 'america/punta_arenas'), - americaRankinInlet(value: 'america/rankin_inlet'), - americaRecife(value: 'america/recife'), - americaRegina(value: 'america/regina'), - americaResolute(value: 'america/resolute'), - americaRioBranco(value: 'america/rio_branco'), - americaSantarem(value: 'america/santarem'), - americaSantiago(value: 'america/santiago'), - americaSantoDomingo(value: 'america/santo_domingo'), - americaSaoPaulo(value: 'america/sao_paulo'), - americaScoresbysund(value: 'america/scoresbysund'), - americaSitka(value: 'america/sitka'), - americaStBarthelemy(value: 'america/st_barthelemy'), - americaStJohns(value: 'america/st_johns'), - americaStKitts(value: 'america/st_kitts'), - americaStLucia(value: 'america/st_lucia'), - americaStThomas(value: 'america/st_thomas'), - americaStVincent(value: 'america/st_vincent'), - americaSwiftCurrent(value: 'america/swift_current'), - americaTegucigalpa(value: 'america/tegucigalpa'), - americaThule(value: 'america/thule'), - americaTijuana(value: 'america/tijuana'), - americaToronto(value: 'america/toronto'), - americaTortola(value: 'america/tortola'), - americaVancouver(value: 'america/vancouver'), - americaWhitehorse(value: 'america/whitehorse'), - americaWinnipeg(value: 'america/winnipeg'), - americaYakutat(value: 'america/yakutat'), - antarcticaCasey(value: 'antarctica/casey'), - antarcticaDavis(value: 'antarctica/davis'), - antarcticaDumontdurville(value: 'antarctica/dumontdurville'), - antarcticaMacquarie(value: 'antarctica/macquarie'), - antarcticaMawson(value: 'antarctica/mawson'), - antarcticaMcmurdo(value: 'antarctica/mcmurdo'), - antarcticaPalmer(value: 'antarctica/palmer'), - antarcticaRothera(value: 'antarctica/rothera'), - antarcticaSyowa(value: 'antarctica/syowa'), - antarcticaTroll(value: 'antarctica/troll'), - antarcticaVostok(value: 'antarctica/vostok'), - arcticLongyearbyen(value: 'arctic/longyearbyen'), - asiaAden(value: 'asia/aden'), - asiaAlmaty(value: 'asia/almaty'), - asiaAmman(value: 'asia/amman'), - asiaAnadyr(value: 'asia/anadyr'), - asiaAqtau(value: 'asia/aqtau'), - asiaAqtobe(value: 'asia/aqtobe'), - asiaAshgabat(value: 'asia/ashgabat'), - asiaAtyrau(value: 'asia/atyrau'), - asiaBaghdad(value: 'asia/baghdad'), - asiaBahrain(value: 'asia/bahrain'), - asiaBaku(value: 'asia/baku'), - asiaBangkok(value: 'asia/bangkok'), - asiaBarnaul(value: 'asia/barnaul'), - asiaBeirut(value: 'asia/beirut'), - asiaBishkek(value: 'asia/bishkek'), - asiaBrunei(value: 'asia/brunei'), - asiaChita(value: 'asia/chita'), - asiaColombo(value: 'asia/colombo'), - asiaDamascus(value: 'asia/damascus'), - asiaDhaka(value: 'asia/dhaka'), - asiaDili(value: 'asia/dili'), - asiaDubai(value: 'asia/dubai'), - asiaDushanbe(value: 'asia/dushanbe'), - asiaFamagusta(value: 'asia/famagusta'), - asiaGaza(value: 'asia/gaza'), - asiaHebron(value: 'asia/hebron'), - asiaHoChiMinh(value: 'asia/ho_chi_minh'), - asiaHongKong(value: 'asia/hong_kong'), - asiaHovd(value: 'asia/hovd'), - asiaIrkutsk(value: 'asia/irkutsk'), - asiaJakarta(value: 'asia/jakarta'), - asiaJayapura(value: 'asia/jayapura'), - asiaJerusalem(value: 'asia/jerusalem'), - asiaKabul(value: 'asia/kabul'), - asiaKamchatka(value: 'asia/kamchatka'), - asiaKarachi(value: 'asia/karachi'), - asiaKathmandu(value: 'asia/kathmandu'), - asiaKhandyga(value: 'asia/khandyga'), - asiaKolkata(value: 'asia/kolkata'), - asiaKrasnoyarsk(value: 'asia/krasnoyarsk'), - asiaKualaLumpur(value: 'asia/kuala_lumpur'), - asiaKuching(value: 'asia/kuching'), - asiaKuwait(value: 'asia/kuwait'), - asiaMacau(value: 'asia/macau'), - asiaMagadan(value: 'asia/magadan'), - asiaMakassar(value: 'asia/makassar'), - asiaManila(value: 'asia/manila'), - asiaMuscat(value: 'asia/muscat'), - asiaNicosia(value: 'asia/nicosia'), - asiaNovokuznetsk(value: 'asia/novokuznetsk'), - asiaNovosibirsk(value: 'asia/novosibirsk'), - asiaOmsk(value: 'asia/omsk'), - asiaOral(value: 'asia/oral'), - asiaPhnomPenh(value: 'asia/phnom_penh'), - asiaPontianak(value: 'asia/pontianak'), - asiaPyongyang(value: 'asia/pyongyang'), - asiaQatar(value: 'asia/qatar'), - asiaQostanay(value: 'asia/qostanay'), - asiaQyzylorda(value: 'asia/qyzylorda'), - asiaRiyadh(value: 'asia/riyadh'), - asiaSakhalin(value: 'asia/sakhalin'), - asiaSamarkand(value: 'asia/samarkand'), - asiaSeoul(value: 'asia/seoul'), - asiaShanghai(value: 'asia/shanghai'), - asiaSingapore(value: 'asia/singapore'), - asiaSrednekolymsk(value: 'asia/srednekolymsk'), - asiaTaipei(value: 'asia/taipei'), - asiaTashkent(value: 'asia/tashkent'), - asiaTbilisi(value: 'asia/tbilisi'), - asiaTehran(value: 'asia/tehran'), - asiaThimphu(value: 'asia/thimphu'), - asiaTokyo(value: 'asia/tokyo'), - asiaTomsk(value: 'asia/tomsk'), - asiaUlaanbaatar(value: 'asia/ulaanbaatar'), - asiaUrumqi(value: 'asia/urumqi'), - asiaUstNera(value: 'asia/ust-nera'), - asiaVientiane(value: 'asia/vientiane'), - asiaVladivostok(value: 'asia/vladivostok'), - asiaYakutsk(value: 'asia/yakutsk'), - asiaYangon(value: 'asia/yangon'), - asiaYekaterinburg(value: 'asia/yekaterinburg'), - asiaYerevan(value: 'asia/yerevan'), - atlanticAzores(value: 'atlantic/azores'), - atlanticBermuda(value: 'atlantic/bermuda'), - atlanticCanary(value: 'atlantic/canary'), - atlanticCapeVerde(value: 'atlantic/cape_verde'), - atlanticFaroe(value: 'atlantic/faroe'), - atlanticMadeira(value: 'atlantic/madeira'), - atlanticReykjavik(value: 'atlantic/reykjavik'), - atlanticSouthGeorgia(value: 'atlantic/south_georgia'), - atlanticStHelena(value: 'atlantic/st_helena'), - atlanticStanley(value: 'atlantic/stanley'), - australiaAdelaide(value: 'australia/adelaide'), - australiaBrisbane(value: 'australia/brisbane'), - australiaBrokenHill(value: 'australia/broken_hill'), - australiaDarwin(value: 'australia/darwin'), - australiaEucla(value: 'australia/eucla'), - australiaHobart(value: 'australia/hobart'), - australiaLindeman(value: 'australia/lindeman'), - australiaLordHowe(value: 'australia/lord_howe'), - australiaMelbourne(value: 'australia/melbourne'), - australiaPerth(value: 'australia/perth'), - australiaSydney(value: 'australia/sydney'), - europeAmsterdam(value: 'europe/amsterdam'), - europeAndorra(value: 'europe/andorra'), - europeAstrakhan(value: 'europe/astrakhan'), - europeAthens(value: 'europe/athens'), - europeBelgrade(value: 'europe/belgrade'), - europeBerlin(value: 'europe/berlin'), - europeBratislava(value: 'europe/bratislava'), - europeBrussels(value: 'europe/brussels'), - europeBucharest(value: 'europe/bucharest'), - europeBudapest(value: 'europe/budapest'), - europeBusingen(value: 'europe/busingen'), - europeChisinau(value: 'europe/chisinau'), - europeCopenhagen(value: 'europe/copenhagen'), - europeDublin(value: 'europe/dublin'), - europeGibraltar(value: 'europe/gibraltar'), - europeGuernsey(value: 'europe/guernsey'), - europeHelsinki(value: 'europe/helsinki'), - europeIsleOfMan(value: 'europe/isle_of_man'), - europeIstanbul(value: 'europe/istanbul'), - europeJersey(value: 'europe/jersey'), - europeKaliningrad(value: 'europe/kaliningrad'), - europeKirov(value: 'europe/kirov'), - europeKyiv(value: 'europe/kyiv'), - europeLisbon(value: 'europe/lisbon'), - europeLjubljana(value: 'europe/ljubljana'), - europeLondon(value: 'europe/london'), - europeLuxembourg(value: 'europe/luxembourg'), - europeMadrid(value: 'europe/madrid'), - europeMalta(value: 'europe/malta'), - europeMariehamn(value: 'europe/mariehamn'), - europeMinsk(value: 'europe/minsk'), - europeMonaco(value: 'europe/monaco'), - europeMoscow(value: 'europe/moscow'), - europeOslo(value: 'europe/oslo'), - europeParis(value: 'europe/paris'), - europePodgorica(value: 'europe/podgorica'), - europePrague(value: 'europe/prague'), - europeRiga(value: 'europe/riga'), - europeRome(value: 'europe/rome'), - europeSamara(value: 'europe/samara'), - europeSanMarino(value: 'europe/san_marino'), - europeSarajevo(value: 'europe/sarajevo'), - europeSaratov(value: 'europe/saratov'), - europeSimferopol(value: 'europe/simferopol'), - europeSkopje(value: 'europe/skopje'), - europeSofia(value: 'europe/sofia'), - europeStockholm(value: 'europe/stockholm'), - europeTallinn(value: 'europe/tallinn'), - europeTirane(value: 'europe/tirane'), - europeUlyanovsk(value: 'europe/ulyanovsk'), - europeVaduz(value: 'europe/vaduz'), - europeVatican(value: 'europe/vatican'), - europeVienna(value: 'europe/vienna'), - europeVilnius(value: 'europe/vilnius'), - europeVolgograd(value: 'europe/volgograd'), - europeWarsaw(value: 'europe/warsaw'), - europeZagreb(value: 'europe/zagreb'), - europeZurich(value: 'europe/zurich'), - indianAntananarivo(value: 'indian/antananarivo'), - indianChagos(value: 'indian/chagos'), - indianChristmas(value: 'indian/christmas'), - indianCocos(value: 'indian/cocos'), - indianComoro(value: 'indian/comoro'), - indianKerguelen(value: 'indian/kerguelen'), - indianMahe(value: 'indian/mahe'), - indianMaldives(value: 'indian/maldives'), - indianMauritius(value: 'indian/mauritius'), - indianMayotte(value: 'indian/mayotte'), - indianReunion(value: 'indian/reunion'), - pacificApia(value: 'pacific/apia'), - pacificAuckland(value: 'pacific/auckland'), - pacificBougainville(value: 'pacific/bougainville'), - pacificChatham(value: 'pacific/chatham'), - pacificChuuk(value: 'pacific/chuuk'), - pacificEaster(value: 'pacific/easter'), - pacificEfate(value: 'pacific/efate'), - pacificFakaofo(value: 'pacific/fakaofo'), - pacificFiji(value: 'pacific/fiji'), - pacificFunafuti(value: 'pacific/funafuti'), - pacificGalapagos(value: 'pacific/galapagos'), - pacificGambier(value: 'pacific/gambier'), - pacificGuadalcanal(value: 'pacific/guadalcanal'), - pacificGuam(value: 'pacific/guam'), - pacificHonolulu(value: 'pacific/honolulu'), - pacificKanton(value: 'pacific/kanton'), - pacificKiritimati(value: 'pacific/kiritimati'), - pacificKosrae(value: 'pacific/kosrae'), - pacificKwajalein(value: 'pacific/kwajalein'), - pacificMajuro(value: 'pacific/majuro'), - pacificMarquesas(value: 'pacific/marquesas'), - pacificMidway(value: 'pacific/midway'), - pacificNauru(value: 'pacific/nauru'), - pacificNiue(value: 'pacific/niue'), - pacificNorfolk(value: 'pacific/norfolk'), - pacificNoumea(value: 'pacific/noumea'), - pacificPagoPago(value: 'pacific/pago_pago'), - pacificPalau(value: 'pacific/palau'), - pacificPitcairn(value: 'pacific/pitcairn'), - pacificPohnpei(value: 'pacific/pohnpei'), - pacificPortMoresby(value: 'pacific/port_moresby'), - pacificRarotonga(value: 'pacific/rarotonga'), - pacificSaipan(value: 'pacific/saipan'), - pacificTahiti(value: 'pacific/tahiti'), - pacificTarawa(value: 'pacific/tarawa'), - pacificTongatapu(value: 'pacific/tongatapu'), - pacificWake(value: 'pacific/wake'), - pacificWallis(value: 'pacific/wallis'), - utc(value: 'utc'); + africaAbidjan(value: 'africa/abidjan'), + africaAccra(value: 'africa/accra'), + africaAddisAbaba(value: 'africa/addis_ababa'), + africaAlgiers(value: 'africa/algiers'), + africaAsmara(value: 'africa/asmara'), + africaBamako(value: 'africa/bamako'), + africaBangui(value: 'africa/bangui'), + africaBanjul(value: 'africa/banjul'), + africaBissau(value: 'africa/bissau'), + africaBlantyre(value: 'africa/blantyre'), + africaBrazzaville(value: 'africa/brazzaville'), + africaBujumbura(value: 'africa/bujumbura'), + africaCairo(value: 'africa/cairo'), + africaCasablanca(value: 'africa/casablanca'), + africaCeuta(value: 'africa/ceuta'), + africaConakry(value: 'africa/conakry'), + africaDakar(value: 'africa/dakar'), + africaDarEsSalaam(value: 'africa/dar_es_salaam'), + africaDjibouti(value: 'africa/djibouti'), + africaDouala(value: 'africa/douala'), + africaElAaiun(value: 'africa/el_aaiun'), + africaFreetown(value: 'africa/freetown'), + africaGaborone(value: 'africa/gaborone'), + africaHarare(value: 'africa/harare'), + africaJohannesburg(value: 'africa/johannesburg'), + africaJuba(value: 'africa/juba'), + africaKampala(value: 'africa/kampala'), + africaKhartoum(value: 'africa/khartoum'), + africaKigali(value: 'africa/kigali'), + africaKinshasa(value: 'africa/kinshasa'), + africaLagos(value: 'africa/lagos'), + africaLibreville(value: 'africa/libreville'), + africaLome(value: 'africa/lome'), + africaLuanda(value: 'africa/luanda'), + africaLubumbashi(value: 'africa/lubumbashi'), + africaLusaka(value: 'africa/lusaka'), + africaMalabo(value: 'africa/malabo'), + africaMaputo(value: 'africa/maputo'), + africaMaseru(value: 'africa/maseru'), + africaMbabane(value: 'africa/mbabane'), + africaMogadishu(value: 'africa/mogadishu'), + africaMonrovia(value: 'africa/monrovia'), + africaNairobi(value: 'africa/nairobi'), + africaNdjamena(value: 'africa/ndjamena'), + africaNiamey(value: 'africa/niamey'), + africaNouakchott(value: 'africa/nouakchott'), + africaOuagadougou(value: 'africa/ouagadougou'), + africaPortoNovo(value: 'africa/porto-novo'), + africaSaoTome(value: 'africa/sao_tome'), + africaTripoli(value: 'africa/tripoli'), + africaTunis(value: 'africa/tunis'), + africaWindhoek(value: 'africa/windhoek'), + americaAdak(value: 'america/adak'), + americaAnchorage(value: 'america/anchorage'), + americaAnguilla(value: 'america/anguilla'), + americaAntigua(value: 'america/antigua'), + americaAraguaina(value: 'america/araguaina'), + americaArgentinaBuenosAires(value: 'america/argentina/buenos_aires'), + americaArgentinaCatamarca(value: 'america/argentina/catamarca'), + americaArgentinaCordoba(value: 'america/argentina/cordoba'), + americaArgentinaJujuy(value: 'america/argentina/jujuy'), + americaArgentinaLaRioja(value: 'america/argentina/la_rioja'), + americaArgentinaMendoza(value: 'america/argentina/mendoza'), + americaArgentinaRioGallegos(value: 'america/argentina/rio_gallegos'), + americaArgentinaSalta(value: 'america/argentina/salta'), + americaArgentinaSanJuan(value: 'america/argentina/san_juan'), + americaArgentinaSanLuis(value: 'america/argentina/san_luis'), + americaArgentinaTucuman(value: 'america/argentina/tucuman'), + americaArgentinaUshuaia(value: 'america/argentina/ushuaia'), + americaAruba(value: 'america/aruba'), + americaAsuncion(value: 'america/asuncion'), + americaAtikokan(value: 'america/atikokan'), + americaBahia(value: 'america/bahia'), + americaBahiaBanderas(value: 'america/bahia_banderas'), + americaBarbados(value: 'america/barbados'), + americaBelem(value: 'america/belem'), + americaBelize(value: 'america/belize'), + americaBlancSablon(value: 'america/blanc-sablon'), + americaBoaVista(value: 'america/boa_vista'), + americaBogota(value: 'america/bogota'), + americaBoise(value: 'america/boise'), + americaCambridgeBay(value: 'america/cambridge_bay'), + americaCampoGrande(value: 'america/campo_grande'), + americaCancun(value: 'america/cancun'), + americaCaracas(value: 'america/caracas'), + americaCayenne(value: 'america/cayenne'), + americaCayman(value: 'america/cayman'), + americaChicago(value: 'america/chicago'), + americaChihuahua(value: 'america/chihuahua'), + americaCiudadJuarez(value: 'america/ciudad_juarez'), + americaCostaRica(value: 'america/costa_rica'), + americaCoyhaique(value: 'america/coyhaique'), + americaCreston(value: 'america/creston'), + americaCuiaba(value: 'america/cuiaba'), + americaCuracao(value: 'america/curacao'), + americaDanmarkshavn(value: 'america/danmarkshavn'), + americaDawson(value: 'america/dawson'), + americaDawsonCreek(value: 'america/dawson_creek'), + americaDenver(value: 'america/denver'), + americaDetroit(value: 'america/detroit'), + americaDominica(value: 'america/dominica'), + americaEdmonton(value: 'america/edmonton'), + americaEirunepe(value: 'america/eirunepe'), + americaElSalvador(value: 'america/el_salvador'), + americaFortNelson(value: 'america/fort_nelson'), + americaFortaleza(value: 'america/fortaleza'), + americaGlaceBay(value: 'america/glace_bay'), + americaGooseBay(value: 'america/goose_bay'), + americaGrandTurk(value: 'america/grand_turk'), + americaGrenada(value: 'america/grenada'), + americaGuadeloupe(value: 'america/guadeloupe'), + americaGuatemala(value: 'america/guatemala'), + americaGuayaquil(value: 'america/guayaquil'), + americaGuyana(value: 'america/guyana'), + americaHalifax(value: 'america/halifax'), + americaHavana(value: 'america/havana'), + americaHermosillo(value: 'america/hermosillo'), + americaIndianaIndianapolis(value: 'america/indiana/indianapolis'), + americaIndianaKnox(value: 'america/indiana/knox'), + americaIndianaMarengo(value: 'america/indiana/marengo'), + americaIndianaPetersburg(value: 'america/indiana/petersburg'), + americaIndianaTellCity(value: 'america/indiana/tell_city'), + americaIndianaVevay(value: 'america/indiana/vevay'), + americaIndianaVincennes(value: 'america/indiana/vincennes'), + americaIndianaWinamac(value: 'america/indiana/winamac'), + americaInuvik(value: 'america/inuvik'), + americaIqaluit(value: 'america/iqaluit'), + americaJamaica(value: 'america/jamaica'), + americaJuneau(value: 'america/juneau'), + americaKentuckyLouisville(value: 'america/kentucky/louisville'), + americaKentuckyMonticello(value: 'america/kentucky/monticello'), + americaKralendijk(value: 'america/kralendijk'), + americaLaPaz(value: 'america/la_paz'), + americaLima(value: 'america/lima'), + americaLosAngeles(value: 'america/los_angeles'), + americaLowerPrinces(value: 'america/lower_princes'), + americaMaceio(value: 'america/maceio'), + americaManagua(value: 'america/managua'), + americaManaus(value: 'america/manaus'), + americaMarigot(value: 'america/marigot'), + americaMartinique(value: 'america/martinique'), + americaMatamoros(value: 'america/matamoros'), + americaMazatlan(value: 'america/mazatlan'), + americaMenominee(value: 'america/menominee'), + americaMerida(value: 'america/merida'), + americaMetlakatla(value: 'america/metlakatla'), + americaMexicoCity(value: 'america/mexico_city'), + americaMiquelon(value: 'america/miquelon'), + americaMoncton(value: 'america/moncton'), + americaMonterrey(value: 'america/monterrey'), + americaMontevideo(value: 'america/montevideo'), + americaMontserrat(value: 'america/montserrat'), + americaNassau(value: 'america/nassau'), + americaNewYork(value: 'america/new_york'), + americaNome(value: 'america/nome'), + americaNoronha(value: 'america/noronha'), + americaNorthDakotaBeulah(value: 'america/north_dakota/beulah'), + americaNorthDakotaCenter(value: 'america/north_dakota/center'), + americaNorthDakotaNewSalem(value: 'america/north_dakota/new_salem'), + americaNuuk(value: 'america/nuuk'), + americaOjinaga(value: 'america/ojinaga'), + americaPanama(value: 'america/panama'), + americaParamaribo(value: 'america/paramaribo'), + americaPhoenix(value: 'america/phoenix'), + americaPortAuPrince(value: 'america/port-au-prince'), + americaPortOfSpain(value: 'america/port_of_spain'), + americaPortoVelho(value: 'america/porto_velho'), + americaPuertoRico(value: 'america/puerto_rico'), + americaPuntaArenas(value: 'america/punta_arenas'), + americaRankinInlet(value: 'america/rankin_inlet'), + americaRecife(value: 'america/recife'), + americaRegina(value: 'america/regina'), + americaResolute(value: 'america/resolute'), + americaRioBranco(value: 'america/rio_branco'), + americaSantarem(value: 'america/santarem'), + americaSantiago(value: 'america/santiago'), + americaSantoDomingo(value: 'america/santo_domingo'), + americaSaoPaulo(value: 'america/sao_paulo'), + americaScoresbysund(value: 'america/scoresbysund'), + americaSitka(value: 'america/sitka'), + americaStBarthelemy(value: 'america/st_barthelemy'), + americaStJohns(value: 'america/st_johns'), + americaStKitts(value: 'america/st_kitts'), + americaStLucia(value: 'america/st_lucia'), + americaStThomas(value: 'america/st_thomas'), + americaStVincent(value: 'america/st_vincent'), + americaSwiftCurrent(value: 'america/swift_current'), + americaTegucigalpa(value: 'america/tegucigalpa'), + americaThule(value: 'america/thule'), + americaTijuana(value: 'america/tijuana'), + americaToronto(value: 'america/toronto'), + americaTortola(value: 'america/tortola'), + americaVancouver(value: 'america/vancouver'), + americaWhitehorse(value: 'america/whitehorse'), + americaWinnipeg(value: 'america/winnipeg'), + americaYakutat(value: 'america/yakutat'), + antarcticaCasey(value: 'antarctica/casey'), + antarcticaDavis(value: 'antarctica/davis'), + antarcticaDumontdurville(value: 'antarctica/dumontdurville'), + antarcticaMacquarie(value: 'antarctica/macquarie'), + antarcticaMawson(value: 'antarctica/mawson'), + antarcticaMcmurdo(value: 'antarctica/mcmurdo'), + antarcticaPalmer(value: 'antarctica/palmer'), + antarcticaRothera(value: 'antarctica/rothera'), + antarcticaSyowa(value: 'antarctica/syowa'), + antarcticaTroll(value: 'antarctica/troll'), + antarcticaVostok(value: 'antarctica/vostok'), + arcticLongyearbyen(value: 'arctic/longyearbyen'), + asiaAden(value: 'asia/aden'), + asiaAlmaty(value: 'asia/almaty'), + asiaAmman(value: 'asia/amman'), + asiaAnadyr(value: 'asia/anadyr'), + asiaAqtau(value: 'asia/aqtau'), + asiaAqtobe(value: 'asia/aqtobe'), + asiaAshgabat(value: 'asia/ashgabat'), + asiaAtyrau(value: 'asia/atyrau'), + asiaBaghdad(value: 'asia/baghdad'), + asiaBahrain(value: 'asia/bahrain'), + asiaBaku(value: 'asia/baku'), + asiaBangkok(value: 'asia/bangkok'), + asiaBarnaul(value: 'asia/barnaul'), + asiaBeirut(value: 'asia/beirut'), + asiaBishkek(value: 'asia/bishkek'), + asiaBrunei(value: 'asia/brunei'), + asiaChita(value: 'asia/chita'), + asiaColombo(value: 'asia/colombo'), + asiaDamascus(value: 'asia/damascus'), + asiaDhaka(value: 'asia/dhaka'), + asiaDili(value: 'asia/dili'), + asiaDubai(value: 'asia/dubai'), + asiaDushanbe(value: 'asia/dushanbe'), + asiaFamagusta(value: 'asia/famagusta'), + asiaGaza(value: 'asia/gaza'), + asiaHebron(value: 'asia/hebron'), + asiaHoChiMinh(value: 'asia/ho_chi_minh'), + asiaHongKong(value: 'asia/hong_kong'), + asiaHovd(value: 'asia/hovd'), + asiaIrkutsk(value: 'asia/irkutsk'), + asiaJakarta(value: 'asia/jakarta'), + asiaJayapura(value: 'asia/jayapura'), + asiaJerusalem(value: 'asia/jerusalem'), + asiaKabul(value: 'asia/kabul'), + asiaKamchatka(value: 'asia/kamchatka'), + asiaKarachi(value: 'asia/karachi'), + asiaKathmandu(value: 'asia/kathmandu'), + asiaKhandyga(value: 'asia/khandyga'), + asiaKolkata(value: 'asia/kolkata'), + asiaKrasnoyarsk(value: 'asia/krasnoyarsk'), + asiaKualaLumpur(value: 'asia/kuala_lumpur'), + asiaKuching(value: 'asia/kuching'), + asiaKuwait(value: 'asia/kuwait'), + asiaMacau(value: 'asia/macau'), + asiaMagadan(value: 'asia/magadan'), + asiaMakassar(value: 'asia/makassar'), + asiaManila(value: 'asia/manila'), + asiaMuscat(value: 'asia/muscat'), + asiaNicosia(value: 'asia/nicosia'), + asiaNovokuznetsk(value: 'asia/novokuznetsk'), + asiaNovosibirsk(value: 'asia/novosibirsk'), + asiaOmsk(value: 'asia/omsk'), + asiaOral(value: 'asia/oral'), + asiaPhnomPenh(value: 'asia/phnom_penh'), + asiaPontianak(value: 'asia/pontianak'), + asiaPyongyang(value: 'asia/pyongyang'), + asiaQatar(value: 'asia/qatar'), + asiaQostanay(value: 'asia/qostanay'), + asiaQyzylorda(value: 'asia/qyzylorda'), + asiaRiyadh(value: 'asia/riyadh'), + asiaSakhalin(value: 'asia/sakhalin'), + asiaSamarkand(value: 'asia/samarkand'), + asiaSeoul(value: 'asia/seoul'), + asiaShanghai(value: 'asia/shanghai'), + asiaSingapore(value: 'asia/singapore'), + asiaSrednekolymsk(value: 'asia/srednekolymsk'), + asiaTaipei(value: 'asia/taipei'), + asiaTashkent(value: 'asia/tashkent'), + asiaTbilisi(value: 'asia/tbilisi'), + asiaTehran(value: 'asia/tehran'), + asiaThimphu(value: 'asia/thimphu'), + asiaTokyo(value: 'asia/tokyo'), + asiaTomsk(value: 'asia/tomsk'), + asiaUlaanbaatar(value: 'asia/ulaanbaatar'), + asiaUrumqi(value: 'asia/urumqi'), + asiaUstNera(value: 'asia/ust-nera'), + asiaVientiane(value: 'asia/vientiane'), + asiaVladivostok(value: 'asia/vladivostok'), + asiaYakutsk(value: 'asia/yakutsk'), + asiaYangon(value: 'asia/yangon'), + asiaYekaterinburg(value: 'asia/yekaterinburg'), + asiaYerevan(value: 'asia/yerevan'), + atlanticAzores(value: 'atlantic/azores'), + atlanticBermuda(value: 'atlantic/bermuda'), + atlanticCanary(value: 'atlantic/canary'), + atlanticCapeVerde(value: 'atlantic/cape_verde'), + atlanticFaroe(value: 'atlantic/faroe'), + atlanticMadeira(value: 'atlantic/madeira'), + atlanticReykjavik(value: 'atlantic/reykjavik'), + atlanticSouthGeorgia(value: 'atlantic/south_georgia'), + atlanticStHelena(value: 'atlantic/st_helena'), + atlanticStanley(value: 'atlantic/stanley'), + australiaAdelaide(value: 'australia/adelaide'), + australiaBrisbane(value: 'australia/brisbane'), + australiaBrokenHill(value: 'australia/broken_hill'), + australiaDarwin(value: 'australia/darwin'), + australiaEucla(value: 'australia/eucla'), + australiaHobart(value: 'australia/hobart'), + australiaLindeman(value: 'australia/lindeman'), + australiaLordHowe(value: 'australia/lord_howe'), + australiaMelbourne(value: 'australia/melbourne'), + australiaPerth(value: 'australia/perth'), + australiaSydney(value: 'australia/sydney'), + europeAmsterdam(value: 'europe/amsterdam'), + europeAndorra(value: 'europe/andorra'), + europeAstrakhan(value: 'europe/astrakhan'), + europeAthens(value: 'europe/athens'), + europeBelgrade(value: 'europe/belgrade'), + europeBerlin(value: 'europe/berlin'), + europeBratislava(value: 'europe/bratislava'), + europeBrussels(value: 'europe/brussels'), + europeBucharest(value: 'europe/bucharest'), + europeBudapest(value: 'europe/budapest'), + europeBusingen(value: 'europe/busingen'), + europeChisinau(value: 'europe/chisinau'), + europeCopenhagen(value: 'europe/copenhagen'), + europeDublin(value: 'europe/dublin'), + europeGibraltar(value: 'europe/gibraltar'), + europeGuernsey(value: 'europe/guernsey'), + europeHelsinki(value: 'europe/helsinki'), + europeIsleOfMan(value: 'europe/isle_of_man'), + europeIstanbul(value: 'europe/istanbul'), + europeJersey(value: 'europe/jersey'), + europeKaliningrad(value: 'europe/kaliningrad'), + europeKirov(value: 'europe/kirov'), + europeKyiv(value: 'europe/kyiv'), + europeLisbon(value: 'europe/lisbon'), + europeLjubljana(value: 'europe/ljubljana'), + europeLondon(value: 'europe/london'), + europeLuxembourg(value: 'europe/luxembourg'), + europeMadrid(value: 'europe/madrid'), + europeMalta(value: 'europe/malta'), + europeMariehamn(value: 'europe/mariehamn'), + europeMinsk(value: 'europe/minsk'), + europeMonaco(value: 'europe/monaco'), + europeMoscow(value: 'europe/moscow'), + europeOslo(value: 'europe/oslo'), + europeParis(value: 'europe/paris'), + europePodgorica(value: 'europe/podgorica'), + europePrague(value: 'europe/prague'), + europeRiga(value: 'europe/riga'), + europeRome(value: 'europe/rome'), + europeSamara(value: 'europe/samara'), + europeSanMarino(value: 'europe/san_marino'), + europeSarajevo(value: 'europe/sarajevo'), + europeSaratov(value: 'europe/saratov'), + europeSimferopol(value: 'europe/simferopol'), + europeSkopje(value: 'europe/skopje'), + europeSofia(value: 'europe/sofia'), + europeStockholm(value: 'europe/stockholm'), + europeTallinn(value: 'europe/tallinn'), + europeTirane(value: 'europe/tirane'), + europeUlyanovsk(value: 'europe/ulyanovsk'), + europeVaduz(value: 'europe/vaduz'), + europeVatican(value: 'europe/vatican'), + europeVienna(value: 'europe/vienna'), + europeVilnius(value: 'europe/vilnius'), + europeVolgograd(value: 'europe/volgograd'), + europeWarsaw(value: 'europe/warsaw'), + europeZagreb(value: 'europe/zagreb'), + europeZurich(value: 'europe/zurich'), + indianAntananarivo(value: 'indian/antananarivo'), + indianChagos(value: 'indian/chagos'), + indianChristmas(value: 'indian/christmas'), + indianCocos(value: 'indian/cocos'), + indianComoro(value: 'indian/comoro'), + indianKerguelen(value: 'indian/kerguelen'), + indianMahe(value: 'indian/mahe'), + indianMaldives(value: 'indian/maldives'), + indianMauritius(value: 'indian/mauritius'), + indianMayotte(value: 'indian/mayotte'), + indianReunion(value: 'indian/reunion'), + pacificApia(value: 'pacific/apia'), + pacificAuckland(value: 'pacific/auckland'), + pacificBougainville(value: 'pacific/bougainville'), + pacificChatham(value: 'pacific/chatham'), + pacificChuuk(value: 'pacific/chuuk'), + pacificEaster(value: 'pacific/easter'), + pacificEfate(value: 'pacific/efate'), + pacificFakaofo(value: 'pacific/fakaofo'), + pacificFiji(value: 'pacific/fiji'), + pacificFunafuti(value: 'pacific/funafuti'), + pacificGalapagos(value: 'pacific/galapagos'), + pacificGambier(value: 'pacific/gambier'), + pacificGuadalcanal(value: 'pacific/guadalcanal'), + pacificGuam(value: 'pacific/guam'), + pacificHonolulu(value: 'pacific/honolulu'), + pacificKanton(value: 'pacific/kanton'), + pacificKiritimati(value: 'pacific/kiritimati'), + pacificKosrae(value: 'pacific/kosrae'), + pacificKwajalein(value: 'pacific/kwajalein'), + pacificMajuro(value: 'pacific/majuro'), + pacificMarquesas(value: 'pacific/marquesas'), + pacificMidway(value: 'pacific/midway'), + pacificNauru(value: 'pacific/nauru'), + pacificNiue(value: 'pacific/niue'), + pacificNorfolk(value: 'pacific/norfolk'), + pacificNoumea(value: 'pacific/noumea'), + pacificPagoPago(value: 'pacific/pago_pago'), + pacificPalau(value: 'pacific/palau'), + pacificPitcairn(value: 'pacific/pitcairn'), + pacificPohnpei(value: 'pacific/pohnpei'), + pacificPortMoresby(value: 'pacific/port_moresby'), + pacificRarotonga(value: 'pacific/rarotonga'), + pacificSaipan(value: 'pacific/saipan'), + pacificTahiti(value: 'pacific/tahiti'), + pacificTarawa(value: 'pacific/tarawa'), + pacificTongatapu(value: 'pacific/tongatapu'), + pacificWake(value: 'pacific/wake'), + pacificWallis(value: 'pacific/wallis'), + utc(value: 'utc'); - const Timezone({ - required this.value - }); + const Timezone({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 f80fa854..344a8770 100644 --- a/lib/src/models/algo_argon2.dart +++ b/lib/src/models/algo_argon2.dart @@ -2,41 +2,41 @@ 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'], + ); + } - @override - Map toMap() { - return { - "type": type, - "memoryCost": memoryCost, - "timeCost": timeCost, - "threads": threads, - }; - } + @override + 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 c51da4bb..9909265e 100644 --- a/lib/src/models/algo_bcrypt.dart +++ b/lib/src/models/algo_bcrypt.dart @@ -2,23 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return { - "type": type, - }; - } + @override + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_md5.dart b/lib/src/models/algo_md5.dart index 43523ab1..746fbd52 100644 --- a/lib/src/models/algo_md5.dart +++ b/lib/src/models/algo_md5.dart @@ -2,23 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return { - "type": type, - }; - } + @override + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_phpass.dart b/lib/src/models/algo_phpass.dart index 8562c4e3..cab45e49 100644 --- a/lib/src/models/algo_phpass.dart +++ b/lib/src/models/algo_phpass.dart @@ -2,23 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return { - "type": type, - }; - } + @override + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_scrypt.dart b/lib/src/models/algo_scrypt.dart index 8e844839..a1648843 100644 --- a/lib/src/models/algo_scrypt.dart +++ b/lib/src/models/algo_scrypt.dart @@ -2,47 +2,47 @@ 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'], - ); - } - - @override - 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'], + ); + } + + @override + 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 5202db05..33ef4a6f 100644 --- a/lib/src/models/algo_scrypt_modified.dart +++ b/lib/src/models/algo_scrypt_modified.dart @@ -2,41 +2,41 @@ 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(), + ); + } - @override - Map toMap() { - return { - "type": type, - "salt": salt, - "saltSeparator": saltSeparator, - "signerKey": signerKey, - }; - } + @override + 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 3d08af9f..4984df75 100644 --- a/lib/src/models/algo_sha.dart +++ b/lib/src/models/algo_sha.dart @@ -2,23 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return { - "type": type, - }; - } + @override + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/continent.dart b/lib/src/models/continent.dart index 930900bf..ec3c41be 100644 --- a/lib/src/models/continent.dart +++ b/lib/src/models/continent.dart @@ -2,29 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return { - "name": name, - "code": code, - }; - } + @override + Map toMap() { + return { + "name": name, + "code": code, + }; + } } diff --git a/lib/src/models/continent_list.dart b/lib/src/models/continent_list.dart index 753bcacc..df28f04b 100644 --- a/lib/src/models/continent_list.dart +++ b/lib/src/models/continent_list.dart @@ -2,29 +2,30 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "continents": continents.map((p) => p.toMap()).toList(), - }; - } + @override + 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 c4838ba3..3bcbb76d 100644 --- a/lib/src/models/country.dart +++ b/lib/src/models/country.dart @@ -2,29 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return { - "name": name, - "code": code, - }; - } + @override + Map toMap() { + return { + "name": name, + "code": code, + }; + } } diff --git a/lib/src/models/country_list.dart b/lib/src/models/country_list.dart index f363a54b..79cb1256 100644 --- a/lib/src/models/country_list.dart +++ b/lib/src/models/country_list.dart @@ -2,29 +2,30 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "countries": countries.map((p) => p.toMap()).toList(), - }; - } + @override + 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 b6bb455f..f2b18093 100644 --- a/lib/src/models/currency.dart +++ b/lib/src/models/currency.dart @@ -2,59 +2,59 @@ 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(), - ); - } - - @override - 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(), + ); + } + + @override + 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 eb2bad19..6c39ae2e 100644 --- a/lib/src/models/currency_list.dart +++ b/lib/src/models/currency_list.dart @@ -2,29 +2,30 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "currencies": currencies.map((p) => p.toMap()).toList(), - }; - } + @override + 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 0d1fdeb0..be08d599 100644 --- a/lib/src/models/document.dart +++ b/lib/src/models/document.dart @@ -2,66 +2,66 @@ part of '../../models.dart'; /// Document class Document implements Model { - /// Document ID. - final String $id; + /// Document ID. + final String $id; - /// Document sequence ID. - final String $sequence; + /// Document sequence ID. + final String $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'].toString(), - $collectionId: map['\$collectionId'].toString(), - $databaseId: map['\$databaseId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - data: map["data"] ?? map, - ); - } + factory Document.fromMap(Map map) { + return Document( + $id: map['\$id'].toString(), + $sequence: map['\$sequence'].toString(), + $collectionId: map['\$collectionId'].toString(), + $databaseId: map['\$databaseId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + data: map["data"] ?? map, + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$sequence": $sequence, - "\$collectionId": $collectionId, - "\$databaseId": $databaseId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "data": data, - }; - } + @override + 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 0e30844a..76a07309 100644 --- a/lib/src/models/document_list.dart +++ b/lib/src/models/document_list.dart @@ -2,32 +2,33 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "documents": documents.map((p) => p.toMap()).toList(), - }; - } + @override + 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 3e767ca3..3629e1d6 100644 --- a/lib/src/models/execution.dart +++ b/lib/src/models/execution.dart @@ -2,125 +2,129 @@ 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 enums.ExecutionTrigger trigger; - - /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, `failed`, or `scheduled`. - final enums.ExecutionStatus status; - - /// HTTP request method type. - final String requestMethod; - - /// HTTP request path and query. - final String requestPath; - - /// HTTP request 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: enums.ExecutionTrigger.values.firstWhere((e) => e.value == map['trigger']), - status: enums.ExecutionStatus.values.firstWhere((e) => e.value == map['status']), - 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(), - ); - } - - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "functionId": functionId, - "deploymentId": deploymentId, - "trigger": trigger.value, - "status": status.value, - "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 enums.ExecutionTrigger trigger; + + /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, `failed`, or `scheduled`. + final enums.ExecutionStatus status; + + /// HTTP request method type. + final String requestMethod; + + /// HTTP request path and query. + final String requestPath; + + /// HTTP request 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: enums.ExecutionTrigger.values + .firstWhere((e) => e.value == map['trigger']), + status: enums.ExecutionStatus.values + .firstWhere((e) => e.value == map['status']), + 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(), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "functionId": functionId, + "deploymentId": deploymentId, + "trigger": trigger.value, + "status": status.value, + "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 45b60682..63c2ad7e 100644 --- a/lib/src/models/execution_list.dart +++ b/lib/src/models/execution_list.dart @@ -2,29 +2,30 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "executions": executions.map((p) => p.toMap()).toList(), - }; - } + @override + 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 9e5f9eb1..01cdcb3a 100644 --- a/lib/src/models/file.dart +++ b/lib/src/models/file.dart @@ -2,101 +2,101 @@ part of '../../models.dart'; /// File class File implements Model { - /// File ID. - final String $id; - - /// Bucket ID. - final String bucketId; - - /// File creation date in ISO 8601 format. - final String $createdAt; - - /// 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 name. - final String name; - - /// File MD5 signature. - final String signature; - - /// File mime type. - final String mimeType; - - /// File original size in bytes. - final int sizeOriginal; - - /// File actual stored size in bytes after compression and/or encryption. - final int sizeActual; - - /// Total number of chunks available - final int chunksTotal; - - /// Total number of chunks uploaded - final int chunksUploaded; - - /// Whether file contents are encrypted at rest. - final bool encryption; - - /// Compression algorithm used for the file. Will be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd). - final String compression; - - 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.sizeActual, - required this.chunksTotal, - required this.chunksUploaded, - required this.encryption, - required this.compression, - }); - - 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'], - sizeActual: map['sizeActual'], - chunksTotal: map['chunksTotal'], - chunksUploaded: map['chunksUploaded'], - encryption: map['encryption'], - compression: map['compression'].toString(), - ); - } - - @override - Map toMap() { - return { - "\$id": $id, - "bucketId": bucketId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "name": name, - "signature": signature, - "mimeType": mimeType, - "sizeOriginal": sizeOriginal, - "sizeActual": sizeActual, - "chunksTotal": chunksTotal, - "chunksUploaded": chunksUploaded, - "encryption": encryption, - "compression": compression, - }; - } + /// File ID. + final String $id; + + /// Bucket ID. + final String bucketId; + + /// File creation date in ISO 8601 format. + final String $createdAt; + + /// 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 name. + final String name; + + /// File MD5 signature. + final String signature; + + /// File mime type. + final String mimeType; + + /// File original size in bytes. + final int sizeOriginal; + + /// File actual stored size in bytes after compression and/or encryption. + final int sizeActual; + + /// Total number of chunks available + final int chunksTotal; + + /// Total number of chunks uploaded + final int chunksUploaded; + + /// Whether file contents are encrypted at rest. + final bool encryption; + + /// Compression algorithm used for the file. Will be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd). + final String compression; + + 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.sizeActual, + required this.chunksTotal, + required this.chunksUploaded, + required this.encryption, + required this.compression, + }); + + 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'], + sizeActual: map['sizeActual'], + chunksTotal: map['chunksTotal'], + chunksUploaded: map['chunksUploaded'], + encryption: map['encryption'], + compression: map['compression'].toString(), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "bucketId": bucketId, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "name": name, + "signature": signature, + "mimeType": mimeType, + "sizeOriginal": sizeOriginal, + "sizeActual": sizeActual, + "chunksTotal": chunksTotal, + "chunksUploaded": chunksUploaded, + "encryption": encryption, + "compression": compression, + }; + } } diff --git a/lib/src/models/file_list.dart b/lib/src/models/file_list.dart index 84c54b2e..1157554a 100644 --- a/lib/src/models/file_list.dart +++ b/lib/src/models/file_list.dart @@ -2,29 +2,29 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "files": files.map((p) => p.toMap()).toList(), - }; - } + @override + 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 bbccf88a..fa054420 100644 --- a/lib/src/models/headers.dart +++ b/lib/src/models/headers.dart @@ -2,29 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return { - "name": name, - "value": value, - }; - } + @override + Map toMap() { + return { + "name": name, + "value": value, + }; + } } diff --git a/lib/src/models/identity.dart b/lib/src/models/identity.dart index 7e90020c..cc659043 100644 --- a/lib/src/models/identity.dart +++ b/lib/src/models/identity.dart @@ -2,77 +2,77 @@ 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(), + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "userId": userId, - "provider": provider, - "providerUid": providerUid, - "providerEmail": providerEmail, - "providerAccessToken": providerAccessToken, - "providerAccessTokenExpiry": providerAccessTokenExpiry, - "providerRefreshToken": providerRefreshToken, - }; - } + @override + 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 d9cc09a2..a5d39ea0 100644 --- a/lib/src/models/identity_list.dart +++ b/lib/src/models/identity_list.dart @@ -2,29 +2,30 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "identities": identities.map((p) => p.toMap()).toList(), - }; - } + @override + 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 2000acb6..cda66c70 100644 --- a/lib/src/models/jwt.dart +++ b/lib/src/models/jwt.dart @@ -2,23 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return { - "jwt": jwt, - }; - } + @override + Map toMap() { + return { + "jwt": jwt, + }; + } } diff --git a/lib/src/models/language.dart b/lib/src/models/language.dart index 1422d065..87dc3606 100644 --- a/lib/src/models/language.dart +++ b/lib/src/models/language.dart @@ -2,35 +2,35 @@ 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(), + ); + } - @override - Map toMap() { - return { - "name": name, - "code": code, - "nativeName": nativeName, - }; - } + @override + 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 5d78a367..6198d61e 100644 --- a/lib/src/models/language_list.dart +++ b/lib/src/models/language_list.dart @@ -2,29 +2,30 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "languages": languages.map((p) => p.toMap()).toList(), - }; - } + @override + 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 3292a896..54dd0c29 100644 --- a/lib/src/models/locale.dart +++ b/lib/src/models/locale.dart @@ -2,59 +2,59 @@ 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(), - ); - } - - @override - 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(), + ); + } + + @override + 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 49ef3b0b..21405aff 100644 --- a/lib/src/models/locale_code.dart +++ b/lib/src/models/locale_code.dart @@ -2,29 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return { - "code": code, - "name": name, - }; - } + @override + 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 a3a26b61..202355a4 100644 --- a/lib/src/models/locale_code_list.dart +++ b/lib/src/models/locale_code_list.dart @@ -2,29 +2,30 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "localeCodes": localeCodes.map((p) => p.toMap()).toList(), - }; - } + @override + 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 406fcbcf..572cce50 100644 --- a/lib/src/models/log.dart +++ b/lib/src/models/log.dart @@ -2,149 +2,149 @@ part of '../../models.dart'; /// Log class Log implements Model { - /// Event name. - final String event; - - /// User ID of the actor recorded for this log. During impersonation, this is the original impersonator, not the impersonated target user. - final String userId; - - /// User email of the actor recorded for this log. During impersonation, this is the original impersonator. - final String userEmail; - - /// User name of the actor recorded for this log. During impersonation, this is the original impersonator. - final String userName; - - /// API mode when event triggered. - final String mode; - - /// User type who triggered the audit log. Possible values: user, admin, guest, keyProject, keyAccount, keyOrganization. - final String userType; - - /// 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.userType, - 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(), - userType: map['userType'].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(), - ); - } - - @override - Map toMap() { - return { - "event": event, - "userId": userId, - "userEmail": userEmail, - "userName": userName, - "mode": mode, - "userType": userType, - "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 of the actor recorded for this log. During impersonation, this is the original impersonator, not the impersonated target user. + final String userId; + + /// User email of the actor recorded for this log. During impersonation, this is the original impersonator. + final String userEmail; + + /// User name of the actor recorded for this log. During impersonation, this is the original impersonator. + final String userName; + + /// API mode when event triggered. + final String mode; + + /// User type who triggered the audit log. Possible values: user, admin, guest, keyProject, keyAccount, keyOrganization. + final String userType; + + /// 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.userType, + 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(), + userType: map['userType'].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(), + ); + } + + @override + Map toMap() { + return { + "event": event, + "userId": userId, + "userEmail": userEmail, + "userName": userName, + "mode": mode, + "userType": userType, + "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 ebf593c2..3494b111 100644 --- a/lib/src/models/log_list.dart +++ b/lib/src/models/log_list.dart @@ -2,29 +2,29 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "logs": logs.map((p) => p.toMap()).toList(), - }; - } + @override + 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 4baffb71..4d8a2f9b 100644 --- a/lib/src/models/membership.dart +++ b/lib/src/models/membership.dart @@ -2,107 +2,107 @@ 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; - - /// User phone number. Hide this attribute by toggling membership privacy in the Console. - final String userPhone; - - /// 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; - - /// Most recent access date in ISO 8601 format. Show this attribute by toggling membership privacy in the Console. - final String userAccessedAt; - - /// 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.userPhone, - required this.teamId, - required this.teamName, - required this.invited, - required this.joined, - required this.confirm, - required this.mfa, - required this.userAccessedAt, - 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(), - userPhone: map['userPhone'].toString(), - teamId: map['teamId'].toString(), - teamName: map['teamName'].toString(), - invited: map['invited'].toString(), - joined: map['joined'].toString(), - confirm: map['confirm'], - mfa: map['mfa'], - userAccessedAt: map['userAccessedAt'].toString(), - roles: List.from(map['roles'] ?? []), - ); - } - - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "userId": userId, - "userName": userName, - "userEmail": userEmail, - "userPhone": userPhone, - "teamId": teamId, - "teamName": teamName, - "invited": invited, - "joined": joined, - "confirm": confirm, - "mfa": mfa, - "userAccessedAt": userAccessedAt, - "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; + + /// User phone number. Hide this attribute by toggling membership privacy in the Console. + final String userPhone; + + /// 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; + + /// Most recent access date in ISO 8601 format. Show this attribute by toggling membership privacy in the Console. + final String userAccessedAt; + + /// 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.userPhone, + required this.teamId, + required this.teamName, + required this.invited, + required this.joined, + required this.confirm, + required this.mfa, + required this.userAccessedAt, + 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(), + userPhone: map['userPhone'].toString(), + teamId: map['teamId'].toString(), + teamName: map['teamName'].toString(), + invited: map['invited'].toString(), + joined: map['joined'].toString(), + confirm: map['confirm'], + mfa: map['mfa'], + userAccessedAt: map['userAccessedAt'].toString(), + roles: List.from(map['roles'] ?? []), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "userId": userId, + "userName": userName, + "userEmail": userEmail, + "userPhone": userPhone, + "teamId": teamId, + "teamName": teamName, + "invited": invited, + "joined": joined, + "confirm": confirm, + "mfa": mfa, + "userAccessedAt": userAccessedAt, + "roles": roles, + }; + } } diff --git a/lib/src/models/membership_list.dart b/lib/src/models/membership_list.dart index a0641a28..cc664c9f 100644 --- a/lib/src/models/membership_list.dart +++ b/lib/src/models/membership_list.dart @@ -2,29 +2,30 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "memberships": memberships.map((p) => p.toMap()).toList(), - }; - } + @override + 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 3d2e2335..fa385541 100644 --- a/lib/src/models/mfa_challenge.dart +++ b/lib/src/models/mfa_challenge.dart @@ -2,41 +2,41 @@ 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(), + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "userId": userId, - "expire": expire, - }; - } + @override + 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 a7e5fefc..2777de7f 100644 --- a/lib/src/models/mfa_factors.dart +++ b/lib/src/models/mfa_factors.dart @@ -2,41 +2,41 @@ 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'], + ); + } - @override - Map toMap() { - return { - "totp": totp, - "phone": phone, - "email": email, - "recoveryCode": recoveryCode, - }; - } + @override + 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 33036476..864a5db8 100644 --- a/lib/src/models/mfa_recovery_codes.dart +++ b/lib/src/models/mfa_recovery_codes.dart @@ -2,23 +2,23 @@ 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'] ?? []), + ); + } - @override - Map toMap() { - return { - "recoveryCodes": recoveryCodes, - }; - } + @override + Map toMap() { + return { + "recoveryCodes": recoveryCodes, + }; + } } diff --git a/lib/src/models/mfa_type.dart b/lib/src/models/mfa_type.dart index 05cab363..fe5327fc 100644 --- a/lib/src/models/mfa_type.dart +++ b/lib/src/models/mfa_type.dart @@ -2,29 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return { - "secret": secret, - "uri": uri, - }; - } + @override + 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 7ac578e2..60e2abd9 100644 --- a/lib/src/models/phone.dart +++ b/lib/src/models/phone.dart @@ -2,35 +2,35 @@ 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(), + ); + } - @override - Map toMap() { - return { - "code": code, - "countryCode": countryCode, - "countryName": countryName, - }; - } + @override + 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 9791d590..1a197fc7 100644 --- a/lib/src/models/phone_list.dart +++ b/lib/src/models/phone_list.dart @@ -2,29 +2,29 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "phones": phones.map((p) => p.toMap()).toList(), - }; - } + @override + 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 b107afe5..3ca04118 100644 --- a/lib/src/models/preferences.dart +++ b/lib/src/models/preferences.dart @@ -2,24 +2,24 @@ 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["data"] ?? map, - ); - } + factory Preferences.fromMap(Map map) { + return Preferences( + data: map["data"] ?? map, + ); + } - @override - Map toMap() { - return { - "data": data, - }; - } + @override + 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/presence.dart b/lib/src/models/presence.dart index 133fe66d..d31911de 100644 --- a/lib/src/models/presence.dart +++ b/lib/src/models/presence.dart @@ -2,71 +2,71 @@ part of '../../models.dart'; /// Presence class Presence implements Model { - /// Presence ID. - final String $id; + /// Presence ID. + final String $id; - /// Presence creation date in ISO 8601 format. - final String $createdAt; + /// Presence creation date in ISO 8601 format. + final String $createdAt; - /// Presence update date in ISO 8601 format. - final String $updatedAt; + /// Presence update date in ISO 8601 format. + final String $updatedAt; - /// Presence permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; + /// Presence permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Presence status. - final String? status; + /// Presence status. + final String? status; - /// Presence source. - final String source; + /// Presence source. + final String source; - /// Presence expiry date in ISO 8601 format. - final String? expiresAt; + /// Presence expiry date in ISO 8601 format. + final String? expiresAt; - /// Presence metadata. - final Map? metadata; + /// Presence metadata. + final Map? metadata; - Presence({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.userId, - this.status, - required this.source, - this.expiresAt, - this.metadata, - }); + Presence({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.userId, + this.status, + required this.source, + this.expiresAt, + this.metadata, + }); - factory Presence.fromMap(Map map) { - return Presence( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - userId: map['userId'].toString(), - status: map['status']?.toString(), - source: map['source'].toString(), - expiresAt: map['expiresAt']?.toString(), - metadata: map['metadata'], - ); - } + factory Presence.fromMap(Map map) { + return Presence( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + userId: map['userId'].toString(), + status: map['status']?.toString(), + source: map['source'].toString(), + expiresAt: map['expiresAt']?.toString(), + metadata: map['metadata'], + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "userId": userId, - "status": status, - "source": source, - "expiresAt": expiresAt, - "metadata": metadata, - }; - } + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "userId": userId, + "status": status, + "source": source, + "expiresAt": expiresAt, + "metadata": metadata, + }; + } } diff --git a/lib/src/models/presence_list.dart b/lib/src/models/presence_list.dart index aebbe880..3d010b1c 100644 --- a/lib/src/models/presence_list.dart +++ b/lib/src/models/presence_list.dart @@ -2,29 +2,30 @@ part of '../../models.dart'; /// Presences List class PresenceList implements Model { - /// Total number of presences that matched your query. - final int total; + /// Total number of presences that matched your query. + final int total; - /// List of presences. - final List presences; + /// List of presences. + final List presences; - PresenceList({ - required this.total, - required this.presences, - }); + PresenceList({ + required this.total, + required this.presences, + }); - factory PresenceList.fromMap(Map map) { - return PresenceList( - total: map['total'], - presences: List.from(map['presences'].map((p) => Presence.fromMap(p))), - ); - } + factory PresenceList.fromMap(Map map) { + return PresenceList( + total: map['total'], + presences: + List.from(map['presences'].map((p) => Presence.fromMap(p))), + ); + } - @override - Map toMap() { - return { - "total": total, - "presences": presences.map((p) => p.toMap()).toList(), - }; - } + @override + Map toMap() { + return { + "total": total, + "presences": presences.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/row.dart b/lib/src/models/row.dart index c5f233b4..a825eab0 100644 --- a/lib/src/models/row.dart +++ b/lib/src/models/row.dart @@ -2,66 +2,66 @@ part of '../../models.dart'; /// Row class Row implements Model { - /// Row ID. - final String $id; + /// Row ID. + final String $id; - /// Row sequence ID. - final String $sequence; + /// Row sequence ID. + final String $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'].toString(), - $tableId: map['\$tableId'].toString(), - $databaseId: map['\$databaseId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - data: map["data"] ?? map, - ); - } + factory Row.fromMap(Map map) { + return Row( + $id: map['\$id'].toString(), + $sequence: map['\$sequence'].toString(), + $tableId: map['\$tableId'].toString(), + $databaseId: map['\$databaseId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + data: map["data"] ?? map, + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$sequence": $sequence, - "\$tableId": $tableId, - "\$databaseId": $databaseId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "data": data, - }; - } + @override + 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 90efa95f..5023c633 100644 --- a/lib/src/models/row_list.dart +++ b/lib/src/models/row_list.dart @@ -2,32 +2,32 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "rows": rows.map((p) => p.toMap()).toList(), - }; - } + @override + 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 c37de95a..92e4034e 100644 --- a/lib/src/models/session.dart +++ b/lib/src/models/session.dart @@ -2,191 +2,191 @@ 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(), - ); - } - - @override - 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(), + ); + } + + @override + 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 d823d0e6..4ea12394 100644 --- a/lib/src/models/session_list.dart +++ b/lib/src/models/session_list.dart @@ -2,29 +2,30 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "sessions": sessions.map((p) => p.toMap()).toList(), - }; - } + @override + 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 850ab8d2..450aafd1 100644 --- a/lib/src/models/subscriber.dart +++ b/lib/src/models/subscriber.dart @@ -2,71 +2,71 @@ 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(), + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "targetId": targetId, - "target": target.toMap(), - "userId": userId, - "userName": userName, - "topicId": topicId, - "providerType": providerType, - }; - } + @override + 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 742e7590..c2e8c4dc 100644 --- a/lib/src/models/target.dart +++ b/lib/src/models/target.dart @@ -2,71 +2,71 @@ 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'], + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "userId": userId, - "providerId": providerId, - "providerType": providerType, - "identifier": identifier, - "expired": expired, - }; - } + @override + 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 21e65e95..91b888b9 100644 --- a/lib/src/models/team.dart +++ b/lib/src/models/team.dart @@ -2,53 +2,53 @@ 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']), - ); - } - - @override - 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']), + ); + } + + @override + 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 ffca5e98..e8f1c621 100644 --- a/lib/src/models/team_list.dart +++ b/lib/src/models/team_list.dart @@ -2,29 +2,29 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "teams": teams.map((p) => p.toMap()).toList(), - }; - } + @override + 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 b05320da..b5ea87c8 100644 --- a/lib/src/models/token.dart +++ b/lib/src/models/token.dart @@ -2,53 +2,53 @@ 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(), - ); - } - - @override - 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(), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "userId": userId, + "secret": secret, + "expire": expire, + "phrase": phrase, + }; + } } diff --git a/lib/src/models/transaction.dart b/lib/src/models/transaction.dart index e3f3e43d..b0606dd8 100644 --- a/lib/src/models/transaction.dart +++ b/lib/src/models/transaction.dart @@ -2,53 +2,53 @@ part of '../../models.dart'; /// Transaction class Transaction implements Model { - /// Transaction ID. - final String $id; - - /// Transaction creation time in ISO 8601 format. - final String $createdAt; - - /// Transaction update date in ISO 8601 format. - final String $updatedAt; - - /// Current status of the transaction. One of: pending, committing, committed, rolled_back, failed. - final String status; - - /// Number of operations in the transaction. - final int operations; - - /// Expiration time in ISO 8601 format. - final String expiresAt; - - Transaction({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.status, - required this.operations, - required this.expiresAt, - }); - - factory Transaction.fromMap(Map map) { - return Transaction( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - status: map['status'].toString(), - operations: map['operations'], - expiresAt: map['expiresAt'].toString(), - ); - } - - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "status": status, - "operations": operations, - "expiresAt": expiresAt, - }; - } + /// Transaction ID. + final String $id; + + /// Transaction creation time in ISO 8601 format. + final String $createdAt; + + /// Transaction update date in ISO 8601 format. + final String $updatedAt; + + /// Current status of the transaction. One of: pending, committing, committed, rolled_back, failed. + final String status; + + /// Number of operations in the transaction. + final int operations; + + /// Expiration time in ISO 8601 format. + final String expiresAt; + + Transaction({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.status, + required this.operations, + required this.expiresAt, + }); + + factory Transaction.fromMap(Map map) { + return Transaction( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + status: map['status'].toString(), + operations: map['operations'], + expiresAt: map['expiresAt'].toString(), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "status": status, + "operations": operations, + "expiresAt": expiresAt, + }; + } } diff --git a/lib/src/models/transaction_list.dart b/lib/src/models/transaction_list.dart index 19ea651d..7f321175 100644 --- a/lib/src/models/transaction_list.dart +++ b/lib/src/models/transaction_list.dart @@ -2,29 +2,30 @@ part of '../../models.dart'; /// Transaction List class TransactionList implements Model { - /// Total number of transactions that matched your query. - final int total; + /// Total number of transactions that matched your query. + final int total; - /// List of transactions. - final List transactions; + /// List of transactions. + final List transactions; - TransactionList({ - required this.total, - required this.transactions, - }); + TransactionList({ + required this.total, + required this.transactions, + }); - factory TransactionList.fromMap(Map map) { - return TransactionList( - total: map['total'], - transactions: List.from(map['transactions'].map((p) => Transaction.fromMap(p))), - ); - } + factory TransactionList.fromMap(Map map) { + return TransactionList( + total: map['total'], + transactions: List.from( + map['transactions'].map((p) => Transaction.fromMap(p))), + ); + } - @override - Map toMap() { - return { - "total": total, - "transactions": transactions.map((p) => p.toMap()).toList(), - }; - } + @override + Map toMap() { + return { + "total": total, + "transactions": transactions.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/user.dart b/lib/src/models/user.dart index e3b9536b..5a6cad30 100644 --- a/lib/src/models/user.dart +++ b/lib/src/models/user.dart @@ -2,173 +2,173 @@ part of '../../models.dart'; /// User class User implements Model { - /// User ID. - final String $id; + /// User ID. + final String $id; - /// User creation date in ISO 8601 format. - final String $createdAt; + /// User creation date in ISO 8601 format. + final String $createdAt; - /// User update date in ISO 8601 format. - final String $updatedAt; + /// 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; - - /// Canonical form of the user email address. - final String? emailCanonical; - - /// Whether the user email is from a free email provider. - final bool? emailIsFree; - - /// Whether the user email is from a disposable email provider. - final bool? emailIsDisposable; - - /// Whether the user email is from a corporate domain. - final bool? emailIsCorporate; - - /// Whether the user email is in its canonical form. - final bool? emailIsCanonical; - - /// 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; - - /// Whether the user can impersonate other users. - final bool? impersonator; - - /// ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data. - final String? impersonatorUserId; - - 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, - this.emailCanonical, - this.emailIsFree, - this.emailIsDisposable, - this.emailIsCorporate, - this.emailIsCanonical, - required this.phoneVerification, - required this.mfa, - required this.prefs, - required this.targets, - required this.accessedAt, - this.impersonator, - this.impersonatorUserId, - }); - - 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'], - emailCanonical: map['emailCanonical']?.toString(), - emailIsFree: map['emailIsFree'], - emailIsDisposable: map['emailIsDisposable'], - emailIsCorporate: map['emailIsCorporate'], - emailIsCanonical: map['emailIsCanonical'], - 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(), - impersonator: map['impersonator'], - impersonatorUserId: map['impersonatorUserId']?.toString(), - ); - } - - @override - 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, - "emailCanonical": emailCanonical, - "emailIsFree": emailIsFree, - "emailIsDisposable": emailIsDisposable, - "emailIsCorporate": emailIsCorporate, - "emailIsCanonical": emailIsCanonical, - "phoneVerification": phoneVerification, - "mfa": mfa, - "prefs": prefs.toMap(), - "targets": targets.map((p) => p.toMap()).toList(), - "accessedAt": accessedAt, - "impersonator": impersonator, - "impersonatorUserId": impersonatorUserId, - }; - } + /// 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; + + /// Canonical form of the user email address. + final String? emailCanonical; + + /// Whether the user email is from a free email provider. + final bool? emailIsFree; + + /// Whether the user email is from a disposable email provider. + final bool? emailIsDisposable; + + /// Whether the user email is from a corporate domain. + final bool? emailIsCorporate; + + /// Whether the user email is in its canonical form. + final bool? emailIsCanonical; + + /// 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; + + /// Whether the user can impersonate other users. + final bool? impersonator; + + /// ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data. + final String? impersonatorUserId; + + 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, + this.emailCanonical, + this.emailIsFree, + this.emailIsDisposable, + this.emailIsCorporate, + this.emailIsCanonical, + required this.phoneVerification, + required this.mfa, + required this.prefs, + required this.targets, + required this.accessedAt, + this.impersonator, + this.impersonatorUserId, + }); + + 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'], + emailCanonical: map['emailCanonical']?.toString(), + emailIsFree: map['emailIsFree'], + emailIsDisposable: map['emailIsDisposable'], + emailIsCorporate: map['emailIsCorporate'], + emailIsCanonical: map['emailIsCanonical'], + 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(), + impersonator: map['impersonator'], + impersonatorUserId: map['impersonatorUserId']?.toString(), + ); + } + + @override + 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, + "emailCanonical": emailCanonical, + "emailIsFree": emailIsFree, + "emailIsDisposable": emailIsDisposable, + "emailIsCorporate": emailIsCorporate, + "emailIsCanonical": emailIsCanonical, + "phoneVerification": phoneVerification, + "mfa": mfa, + "prefs": prefs.toMap(), + "targets": targets.map((p) => p.toMap()).toList(), + "accessedAt": accessedAt, + "impersonator": impersonator, + "impersonatorUserId": impersonatorUserId, + }; + } } diff --git a/lib/src/realtime.dart b/lib/src/realtime.dart index 7a5e6303..28e4c43d 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(); /// ``` - /// + /// /// You can also use Channel builders: /// ```dart /// final subscription = realtime.subscribe([ diff --git a/lib/src/realtime_io.dart b/lib/src/realtime_io.dart index 83f01b4c..0ed367a6 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 6cebb5b1..72edf5ee 100644 --- a/lib/src/realtime_mixin.dart +++ b/lib/src/realtime_mixin.dart @@ -58,9 +58,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"})); } }); } @@ -140,9 +138,11 @@ mixin RealtimeMixin { case 'event': final messageData = data.data as Map; final message = RealtimeMessage.fromMap(messageData); - final subscriptions = (messageData['subscriptions'] as List?) - ?.map((x) => x.toString()) - .toList() ?? []; + final subscriptions = + (messageData['subscriptions'] as List?) + ?.map((x) => x.toString()) + .toList() ?? + []; if (subscriptions.isEmpty) { break; @@ -209,13 +209,15 @@ mixin RealtimeMixin { "Please set endPointRealtime to connect to realtime server"); } var uri = Uri.parse(client.endPointRealtime!); - - var queryParams = "project=${Uri.encodeComponent(client.config['project']!)}"; + + var queryParams = + "project=${Uri.encodeComponent(client.config['project']!)}"; final portPart = (uri.hasPort && uri.port != 80 && uri.port != 443) ? ':${uri.port}' : ''; - return Uri.parse("${uri.scheme}://${uri.host}$portPart${uri.path}/realtime?$queryParams"); + return Uri.parse( + "${uri.scheme}://${uri.host}$portPart${uri.path}/realtime?$queryParams"); } void _sendUnsubscribeMessage(List subscriptionIds) { @@ -310,9 +312,11 @@ mixin RealtimeMixin { return channel is String ? channel : channel.toString(); } - RealtimeSubscription subscribeTo(List channels, [List queries = const []]) { + RealtimeSubscription subscribeTo(List channels, + [List queries = const []]) { StreamController controller = StreamController.broadcast(); - final channelStrings = channels.map((ch) => _channelToString(ch)).toList().cast(); + final channelStrings = + channels.map((ch) => _channelToString(ch)).toList().cast(); final queryStrings = List.from(queries); final subscriptionId = _generateUniqueSubscriptionId(); @@ -329,8 +333,7 @@ mixin RealtimeMixin { _sendUnsubscribeMessage([subscriptionId]); } - Future update( - {List? channels, List? queries}) async { + Future update({List? channels, List? queries}) async { final current = _subscriptions[subscriptionId]; if (current == null) { return; @@ -417,4 +420,4 @@ mixin RealtimeMixin { // until the application-level handshake completes. _flushPendingPresence(); } -} \ 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 diff --git a/lib/src/realtime_stub.dart b/lib/src/realtime_stub.dart index ce0b7e95..3aab4e03 100644 --- a/lib/src/realtime_stub.dart +++ b/lib/src/realtime_stub.dart @@ -3,5 +3,5 @@ import 'client.dart'; /// Implemented in `realtime_browser.dart` and `realtime_io.dart`. RealtimeBase createRealtime(Client client) => throw UnsupportedError( - 'Cannot create a client without dart:html or dart:io.', -); + 'Cannot create a client without dart:html or dart:io.', + ); diff --git a/test/channel_test.dart b/test/channel_test.dart index 62031aec..9e0e11d3 100644 --- a/test/channel_test.dart +++ b/test/channel_test.dart @@ -13,12 +13,22 @@ void main() { }); test('returns database channel with action', () { - expect(Channel.database('db1').collection('col1').document('doc1').create().toString(), + expect( + Channel.database('db1') + .collection('col1') + .document('doc1') + .create() + .toString(), 'databases.db1.collections.col1.documents.doc1.create'); }); test('returns database channel with upsert action', () { - expect(Channel.database('db1').collection('col1').document('doc1').upsert().toString(), + expect( + Channel.database('db1') + .collection('col1') + .document('doc1') + .upsert() + .toString(), 'databases.db1.collections.col1.documents.doc1.upsert'); }); }); @@ -34,7 +44,12 @@ void main() { }); test('returns tablesdb channel with action', () { - expect(Channel.tablesdb('db1').table('table1').row('row1').update().toString(), + expect( + Channel.tablesdb('db1') + .table('table1') + .row('row1') + .update() + .toString(), 'tablesdb.db1.tables.table1.rows.row1.update'); }); }); @@ -47,16 +62,16 @@ void main() { group('bucket()', () { test('throws when bucket id is missing', () { - expect(() => Channel.bucket(''), throwsArgumentError); + expect(() => Channel.bucket(''), throwsArgumentError); }); test('returns buckets channel with specific IDs', () { - expect(Channel.bucket('bucket1').file().toString(), - 'buckets.bucket1.files'); + expect( + Channel.bucket('bucket1').file().toString(), 'buckets.bucket1.files'); }); test('returns buckets channel with action', () { - expect(Channel.bucket('bucket1').file('file1').delete().toString(), + expect(Channel.bucket('bucket1').file('file1').delete().toString(), 'buckets.bucket1.files.file1.delete'); }); }); @@ -83,29 +98,30 @@ void main() { group('teams()', () { test('throws when team id is missing', () { - expect(() => Channel.team(''), throwsArgumentError); + expect(() => Channel.team(''), throwsArgumentError); }); test('returns teams channel with specific team ID', () { - expect(Channel.team('team1').toString(), 'teams.team1'); + expect(Channel.team('team1').toString(), 'teams.team1'); }); test('returns teams channel with action', () { - expect(Channel.team('team1').create().toString(), 'teams.team1.create'); + expect(Channel.team('team1').create().toString(), 'teams.team1.create'); }); }); group('memberships()', () { test('throws when membership id is missing', () { - expect(() => Channel.membership(''), throwsArgumentError); + expect(() => Channel.membership(''), throwsArgumentError); }); test('returns memberships channel with specific membership ID', () { - expect(Channel.membership('membership1').toString(), 'memberships.membership1'); + expect(Channel.membership('membership1').toString(), + 'memberships.membership1'); }); test('returns memberships channel with action', () { - expect(Channel.membership('membership1').update().toString(), + expect(Channel.membership('membership1').update().toString(), 'memberships.membership1.update'); }); }); diff --git a/test/query_test.dart b/test/query_test.dart index 25388fad..db7b9214 100644 --- a/test/query_test.dart +++ b/test/query_test.dart @@ -354,4 +354,3 @@ void main() { expect(query['method'], 'between'); }); } - diff --git a/test/services/account_test.dart b/test/services/account_test.dart index bd65aa32..d5d61fe7 100644 --- a/test/services/account_test.dart +++ b/test/services/account_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,1540 +40,1356 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Account test', () { - late MockClient client; - late Account account; - - setUp(() { - client = MockClient(); - account = Account(client); - }); - - test('test method get()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.get( - ); - expect(response, isA()); - - }); - - test('test method create()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.create( - userId: '', - email: 'email@example.com', - password: 'password', - ); - expect(response, isA()); - - }); - - test('test method updateEmail()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateEmail( - email: 'email@example.com', - password: 'password', - ); - expect(response, isA()); - - }); - - test('test method listIdentities()', () async { - - final Map data = { - 'total': 5, - 'identities': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.listIdentities( - ); - expect(response, isA()); - - }); - - test('test method deleteIdentity()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.deleteIdentity( - identityId: '', - ); - }); - - test('test method createJWT()', () async { - - final Map data = { - 'jwt': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createJWT( - ); - expect(response, isA()); - - }); - - test('test method listLogs()', () async { - - final Map data = { - 'total': 5, - 'logs': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.listLogs( - ); - expect(response, isA()); - - }); - - test('test method updateMFA()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateMFA( - mfa: true, - ); - expect(response, isA()); - - }); - - test('test method createMfaAuthenticator()', () async { - - final Map data = { - 'secret': '[SHARED_SECRET]', - 'uri': 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createMfaAuthenticator( - type: enums.AuthenticatorType.totp, - ); - expect(response, isA()); - - }); - - test('test method createMFAAuthenticator()', () async { - - final Map data = { - 'secret': '[SHARED_SECRET]', - 'uri': 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createMFAAuthenticator( - type: enums.AuthenticatorType.totp, - ); - expect(response, isA()); - - }); - - test('test method updateMfaAuthenticator()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateMfaAuthenticator( - type: enums.AuthenticatorType.totp, - otp: '', - ); - expect(response, isA()); - - }); - - test('test method updateMFAAuthenticator()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateMFAAuthenticator( - type: enums.AuthenticatorType.totp, - otp: '', - ); - expect(response, isA()); - - }); - - test('test method deleteMfaAuthenticator()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.deleteMfaAuthenticator( - type: enums.AuthenticatorType.totp, - ); - }); - - test('test method deleteMFAAuthenticator()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.deleteMFAAuthenticator( - type: enums.AuthenticatorType.totp, - ); - }); - - test('test method createMfaChallenge()', () async { - - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'expire': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createMfaChallenge( - factor: enums.AuthenticationFactor.email, - ); - expect(response, isA()); - - }); - - test('test method createMFAChallenge()', () async { - - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'expire': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createMFAChallenge( - factor: enums.AuthenticationFactor.email, - ); - expect(response, isA()); - - }); - - test('test method updateMfaChallenge()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateMfaChallenge( - challengeId: '', - otp: '', - ); - expect(response, isA()); - - }); - - test('test method updateMFAChallenge()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateMFAChallenge( - challengeId: '', - otp: '', - ); - expect(response, isA()); - - }); - - test('test method listMfaFactors()', () async { - - final Map data = { - 'totp': true, - 'phone': true, - 'email': true, - 'recoveryCode': true,}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.listMfaFactors( - ); - expect(response, isA()); - - }); - - test('test method listMFAFactors()', () async { - - final Map data = { - 'totp': true, - 'phone': true, - 'email': true, - 'recoveryCode': true,}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.listMFAFactors( - ); - expect(response, isA()); - - }); - - test('test method getMfaRecoveryCodes()', () async { - - final Map data = { - 'recoveryCodes': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.getMfaRecoveryCodes( - ); - expect(response, isA()); - - }); - - test('test method getMFARecoveryCodes()', () async { - - final Map data = { - 'recoveryCodes': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.getMFARecoveryCodes( - ); - expect(response, isA()); - - }); - - test('test method createMfaRecoveryCodes()', () async { - - final Map data = { - 'recoveryCodes': [],}; - + group('Account test', () { + late MockClient client; + late Account account; - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createMfaRecoveryCodes( - ); - expect(response, isA()); - - }); - - test('test method createMFARecoveryCodes()', () async { - - final Map data = { - 'recoveryCodes': [],}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createMFARecoveryCodes( - ); - expect(response, isA()); - - }); - - test('test method updateMfaRecoveryCodes()', () async { - - final Map data = { - 'recoveryCodes': [],}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateMfaRecoveryCodes( - ); - expect(response, isA()); - - }); - - test('test method updateMFARecoveryCodes()', () async { - - final Map data = { - 'recoveryCodes': [],}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateMFARecoveryCodes( - ); - expect(response, isA()); - - }); - - test('test method updateName()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateName( - name: '', - ); - expect(response, isA()); - - }); - - test('test method updatePassword()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updatePassword( - password: 'password', - ); - expect(response, isA()); - - }); - - test('test method updatePhone()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updatePhone( - phone: '+12065550100', - password: 'password', - ); - expect(response, isA()); - - }); - - test('test method getPrefs()', () async { - - final Map data = {}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.getPrefs( - ); - expect(response, isA()); - - }); - - test('test method updatePrefs()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updatePrefs( - prefs: {}, - ); - expect(response, isA()); - - }); - - test('test method createRecovery()', () async { - - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createRecovery( - email: 'email@example.com', - url: 'https://example.com', - ); - expect(response, isA()); - - }); - - test('test method updateRecovery()', () async { - - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + setUp(() { + client = MockClient(); + account = Account(client); + }); + test('test method get()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.get(); + expect(response, isA()); + }); - final response = await account.updateRecovery( - userId: '', - secret: '', - password: 'password', - ); - expect(response, isA()); + test('test method create()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.create( + userId: '', + email: 'email@example.com', + password: 'password', + ); + expect(response, isA()); + }); - }); + test('test method updateEmail()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateEmail( + email: 'email@example.com', + password: 'password', + ); + expect(response, isA()); + }); - test('test method listSessions()', () async { - - final Map data = { - 'total': 5, - 'sessions': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.listSessions( - ); - expect(response, isA()); - - }); - - test('test method deleteSessions()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.deleteSessions( - ); - }); - - test('test method createAnonymousSession()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createAnonymousSession( - ); - expect(response, isA()); - - }); - - test('test method createEmailPasswordSession()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createEmailPasswordSession( - email: 'email@example.com', - password: 'password', - ); - expect(response, isA()); - - }); - - test('test method updateMagicURLSession()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateMagicURLSession( - userId: '', - secret: '', - ); - expect(response, isA()); - - }); - - test('test method createOAuth2Session()', () async { - - - when(client.webAuth( - argThat(isNotNull), - )).thenAnswer((_) async => 'done'); - - - final response = await account.createOAuth2Session( - provider: enums.OAuthProvider.amazon, - ); - expect(response, equals('done')); - - }); - - test('test method updatePhoneSession()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updatePhoneSession( - userId: '', - secret: '', - ); - expect(response, isA()); - - }); - - test('test method createSession()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createSession( - userId: '', - secret: '', - ); - expect(response, isA()); - - }); - - test('test method getSession()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.getSession( - sessionId: '', - ); - expect(response, isA()); - - }); - - test('test method updateSession()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateSession( - sessionId: '', - ); - expect(response, isA()); - - }); - - test('test method deleteSession()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.deleteSession( - sessionId: '', - ); - }); - - test('test method updateStatus()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + test('test method listIdentities()', () async { + final Map data = { + 'total': 5, + 'identities': [], + }; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + final response = await account.listIdentities(); + expect(response, isA()); + }); + test('test method deleteIdentity()', () async { + final data = ''; - final response = await account.updateStatus( - ); - expect(response, isA()); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await account.deleteIdentity( + identityId: '', + ); + }); - test('test method createPushTarget()', () async { + test('test method createJWT()', () async { + final Map data = { + 'jwt': + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', + }; - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'Apple iPhone 12', - 'userId': '259125845563242502', - 'providerType': 'email', - 'identifier': 'token', - 'expired': true,}; + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + final response = await account.createJWT(); + expect(response, isA()); + }); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + test('test method listLogs()', () async { + final Map data = { + 'total': 5, + 'logs': [], + }; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await account.createPushTarget( - targetId: '', - identifier: '', - ); - expect(response, isA()); + final response = await account.listLogs(); + expect(response, isA()); + }); - }); + test('test method updateMFA()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateMFA( + mfa: true, + ); + expect(response, isA()); + }); - test('test method updatePushTarget()', () async { + test('test method createMfaAuthenticator()', () async { + final Map data = { + 'secret': '[SHARED_SECRET]', + 'uri': + 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createMfaAuthenticator( + type: enums.AuthenticatorType.totp, + ); + expect(response, isA()); + }); - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'Apple iPhone 12', - 'userId': '259125845563242502', - 'providerType': 'email', - 'identifier': 'token', - 'expired': true,}; + test('test method createMFAAuthenticator()', () async { + final Map data = { + 'secret': '[SHARED_SECRET]', + 'uri': + 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createMFAAuthenticator( + type: enums.AuthenticatorType.totp, + ); + expect(response, isA()); + }); + test('test method updateMfaAuthenticator()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateMfaAuthenticator( + type: enums.AuthenticatorType.totp, + otp: '', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + test('test method updateMFAAuthenticator()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateMFAAuthenticator( + type: enums.AuthenticatorType.totp, + otp: '', + ); + expect(response, isA()); + }); + test('test method deleteMfaAuthenticator()', () async { + final data = ''; - final response = await account.updatePushTarget( - targetId: '', - identifier: '', - ); - expect(response, isA()); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await account.deleteMfaAuthenticator( + type: enums.AuthenticatorType.totp, + ); + }); - test('test method deletePushTarget()', () async { + test('test method deleteMFAAuthenticator()', () async { + final data = ''; - final data = ''; + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + final response = await account.deleteMFAAuthenticator( + type: enums.AuthenticatorType.totp, + ); + }); + test('test method createMfaChallenge()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'expire': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createMfaChallenge( + factor: enums.AuthenticationFactor.email, + ); + expect(response, isA()); + }); - final response = await account.deletePushTarget( - targetId: '', - ); - }); + test('test method createMFAChallenge()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'expire': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createMFAChallenge( + factor: enums.AuthenticationFactor.email, + ); + expect(response, isA()); + }); - test('test method createEmailToken()', () async { + test('test method updateMfaChallenge()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateMfaChallenge( + challengeId: '', + otp: '', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + test('test method updateMFAChallenge()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateMFAChallenge( + challengeId: '', + otp: '', + ); + expect(response, isA()); + }); + test('test method listMfaFactors()', () async { + final Map data = { + 'totp': true, + 'phone': true, + 'email': true, + 'recoveryCode': true, + }; - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await account.listMfaFactors(); + expect(response, isA()); + }); - final response = await account.createEmailToken( - userId: '', - email: 'email@example.com', - ); - expect(response, isA()); + test('test method listMFAFactors()', () async { + final Map data = { + 'totp': true, + 'phone': true, + 'email': true, + 'recoveryCode': true, + }; - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method createMagicURLToken()', () async { + final response = await account.listMFAFactors(); + expect(response, isA()); + }); - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + test('test method getMfaRecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [], + }; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + final response = await account.getMfaRecoveryCodes(); + expect(response, isA()); + }); + test('test method getMFARecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [], + }; - final response = await account.createMagicURLToken( - userId: '', - email: 'email@example.com', - ); - expect(response, isA()); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await account.getMFARecoveryCodes(); + expect(response, isA()); + }); - test('test method createOAuth2Token()', () async { + test('test method createMfaRecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [], + }; + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - when(client.webAuth( - argThat(isNotNull), - )).thenAnswer((_) async => 'done'); + final response = await account.createMfaRecoveryCodes(); + expect(response, isA()); + }); + test('test method createMFARecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [], + }; - final response = await account.createOAuth2Token( - provider: enums.OAuthProvider.amazon, - ); - expect(response, equals('done')); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await account.createMFARecoveryCodes(); + expect(response, isA()); + }); - test('test method createPhoneToken()', () async { + test('test method updateMfaRecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [], + }; - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + final response = await account.updateMfaRecoveryCodes(); + expect(response, isA()); + }); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + test('test method updateMFARecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [], + }; + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); - final response = await account.createPhoneToken( - userId: '', - phone: '+12065550100', - ); - expect(response, isA()); + final response = await account.updateMFARecoveryCodes(); + expect(response, isA()); + }); - }); + test('test method updateName()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateName( + name: '', + ); + expect(response, isA()); + }); - test('test method createEmailVerification()', () async { + test('test method updatePassword()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updatePassword( + password: 'password', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + test('test method updatePhone()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updatePhone( + phone: '+12065550100', + password: 'password', + ); + expect(response, isA()); + }); + test('test method getPrefs()', () async { + final Map data = {}; - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await account.getPrefs(); + expect(response, isA()); + }); - final response = await account.createEmailVerification( - url: 'https://example.com', - ); - expect(response, isA()); + test('test method updatePrefs()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updatePrefs( + prefs: {}, + ); + expect(response, isA()); + }); - }); + test('test method createRecovery()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createRecovery( + email: 'email@example.com', + url: 'https://example.com', + ); + expect(response, isA()); + }); - test('test method createVerification()', () async { + test('test method updateRecovery()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateRecovery( + userId: '', + secret: '', + password: 'password', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + test('test method listSessions()', () async { + final Map data = { + 'total': 5, + 'sessions': [], + }; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + final response = await account.listSessions(); + expect(response, isA()); + }); + test('test method deleteSessions()', () async { + final data = ''; - final response = await account.createVerification( - url: 'https://example.com', - ); - expect(response, isA()); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await account.deleteSessions(); + }); - test('test method updateEmailVerification()', () async { + test('test method createAnonymousSession()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createAnonymousSession(); + expect(response, isA()); + }); - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + test('test method createEmailPasswordSession()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createEmailPasswordSession( + email: 'email@example.com', + password: 'password', + ); + expect(response, isA()); + }); + test('test method updateMagicURLSession()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateMagicURLSession( + userId: '', + secret: '', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + test('test method createOAuth2Session()', () async { + when(client.webAuth( + argThat(isNotNull), + )).thenAnswer((_) async => 'done'); + final response = await account.createOAuth2Session( + provider: enums.OAuthProvider.amazon, + ); + expect(response, equals('done')); + }); - final response = await account.updateEmailVerification( - userId: '', - secret: '', - ); - expect(response, isA()); + test('test method updatePhoneSession()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updatePhoneSession( + userId: '', + secret: '', + ); + expect(response, isA()); + }); - }); + test('test method createSession()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createSession( + userId: '', + secret: '', + ); + expect(response, isA()); + }); - test('test method updateVerification()', () async { + test('test method getSession()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.getSession( + sessionId: '', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + test('test method updateSession()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateSession( + sessionId: '', + ); + expect(response, isA()); + }); + test('test method deleteSession()', () async { + final data = ''; - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + final response = await account.deleteSession( + sessionId: '', + ); + }); - final response = await account.updateVerification( - userId: '', - secret: '', - ); - expect(response, isA()); + test('test method updateStatus()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateStatus(); + expect(response, isA()); + }); - }); + test('test method createPushTarget()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Apple iPhone 12', + 'userId': '259125845563242502', + 'providerType': 'email', + 'identifier': 'token', + 'expired': true, + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createPushTarget( + targetId: '', + identifier: '', + ); + expect(response, isA()); + }); - test('test method createPhoneVerification()', () async { + test('test method updatePushTarget()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Apple iPhone 12', + 'userId': '259125845563242502', + 'providerType': 'email', + 'identifier': 'token', + 'expired': true, + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updatePushTarget( + targetId: '', + identifier: '', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + test('test method deletePushTarget()', () async { + final data = ''; + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + final response = await account.deletePushTarget( + targetId: '', + ); + }); + test('test method createEmailToken()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createEmailToken( + userId: '', + email: 'email@example.com', + ); + expect(response, isA()); + }); - final response = await account.createPhoneVerification( - ); - expect(response, isA()); + test('test method createMagicURLToken()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createMagicURLToken( + userId: '', + email: 'email@example.com', + ); + expect(response, isA()); + }); - }); + test('test method createOAuth2Token()', () async { + when(client.webAuth( + argThat(isNotNull), + )).thenAnswer((_) async => 'done'); - test('test method updatePhoneVerification()', () async { + final response = await account.createOAuth2Token( + provider: enums.OAuthProvider.amazon, + ); + expect(response, equals('done')); + }); - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + test('test method createPhoneToken()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createPhoneToken( + userId: '', + phone: '+12065550100', + ); + expect(response, isA()); + }); + test('test method createEmailVerification()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createEmailVerification( + url: 'https://example.com', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + test('test method createVerification()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createVerification( + url: 'https://example.com', + ); + expect(response, isA()); + }); + test('test method updateEmailVerification()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateEmailVerification( + userId: '', + secret: '', + ); + expect(response, isA()); + }); - final response = await account.updatePhoneVerification( - userId: '', - secret: '', - ); - expect(response, isA()); + test('test method updateVerification()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateVerification( + userId: '', + secret: '', + ); + expect(response, isA()); + }); - }); + test('test method createPhoneVerification()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createPhoneVerification(); + expect(response, isA()); + }); + test('test method updatePhoneVerification()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updatePhoneVerification( + userId: '', + secret: '', + ); + expect(response, isA()); }); + }); } diff --git a/test/services/avatars_test.dart b/test/services/avatars_test.dart index 4bdb434d..8d2c48fb 100644 --- a/test/services/avatars_test.dart +++ b/test/services/avatars_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,138 +40,123 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Avatars test', () { - late MockClient client; - late Avatars avatars; - - setUp(() { - client = MockClient(); - avatars = Avatars(client); - }); - - test('test method getBrowser()', () async { -final Uint8List data = Uint8List.fromList([]); - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await avatars.getBrowser( - code: enums.Browser.avantBrowser, - ); - expect(response, isA()); - - }); - - test('test method getCreditCard()', () async { -final Uint8List data = Uint8List.fromList([]); - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await avatars.getCreditCard( - code: enums.CreditCard.americanExpress, - ); - expect(response, isA()); - - }); - - test('test method getFavicon()', () async { -final Uint8List data = Uint8List.fromList([]); + group('Avatars test', () { + late MockClient client; + late Avatars avatars; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await avatars.getFavicon( - url: 'https://example.com', - ); - expect(response, isA()); - - }); - - test('test method getFlag()', () async { -final Uint8List data = Uint8List.fromList([]); - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + setUp(() { + client = MockClient(); + avatars = Avatars(client); + }); + test('test method getBrowser()', () async { + final Uint8List data = Uint8List.fromList([]); - final response = await avatars.getFlag( - code: enums.Flag.afghanistan, - ); - expect(response, isA()); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await avatars.getBrowser( + code: enums.Browser.avantBrowser, + ); + expect(response, isA()); + }); - test('test method getImage()', () async { -final Uint8List data = Uint8List.fromList([]); + test('test method getCreditCard()', () async { + final Uint8List data = Uint8List.fromList([]); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await avatars.getCreditCard( + code: enums.CreditCard.americanExpress, + ); + expect(response, isA()); + }); - final response = await avatars.getImage( - url: 'https://example.com', - ); - expect(response, isA()); + test('test method getFavicon()', () async { + final Uint8List data = Uint8List.fromList([]); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method getInitials()', () async { -final Uint8List data = Uint8List.fromList([]); + final response = await avatars.getFavicon( + url: 'https://example.com', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + test('test method getFlag()', () async { + final Uint8List data = Uint8List.fromList([]); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await avatars.getInitials( - ); - expect(response, isA()); + final response = await avatars.getFlag( + code: enums.Flag.afghanistan, + ); + expect(response, isA()); + }); - }); + test('test method getImage()', () async { + final Uint8List data = Uint8List.fromList([]); - test('test method getQR()', () async { -final Uint8List data = Uint8List.fromList([]); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final response = await avatars.getImage( + url: 'https://example.com', + ); + expect(response, isA()); + }); + test('test method getInitials()', () async { + final Uint8List data = Uint8List.fromList([]); - final response = await avatars.getQR( - text: '', - ); - expect(response, isA()); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await avatars.getInitials(); + expect(response, isA()); + }); - test('test method getScreenshot()', () async { -final Uint8List data = Uint8List.fromList([]); + test('test method getQR()', () async { + final Uint8List data = Uint8List.fromList([]); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await avatars.getQR( + text: '', + ); + expect(response, isA()); + }); - final response = await avatars.getScreenshot( - url: 'https://example.com', - ); - expect(response, isA()); + test('test method getScreenshot()', () async { + final Uint8List data = Uint8List.fromList([]); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await avatars.getScreenshot( + url: 'https://example.com', + ); + expect(response, isA()); }); + }); } diff --git a/test/services/databases_test.dart b/test/services/databases_test.dart index a4b0a6cc..a3807093 100644 --- a/test/services/databases_test.dart +++ b/test/services/databases_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,337 +40,297 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Databases test', () { - late MockClient client; - late Databases databases; - - setUp(() { - client = MockClient(); - databases = Databases(client); - }); - - test('test method listTransactions()', () async { - - final Map data = { - 'total': 5, - 'transactions': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.listTransactions( - ); - expect(response, isA()); - - }); - - test('test method createTransaction()', () async { - - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.createTransaction( - ); - expect(response, isA()); - - }); - - test('test method getTransaction()', () async { - - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.getTransaction( - transactionId: '', - ); - expect(response, isA()); - - }); - - test('test method updateTransaction()', () async { - - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.updateTransaction( - transactionId: '', - ); - expect(response, isA()); - - }); - - test('test method deleteTransaction()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.deleteTransaction( - transactionId: '', - ); - }); - - test('test method createOperations()', () async { - - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.createOperations( - transactionId: '', - ); - expect(response, isA()); - - }); - - test('test method listDocuments()', () async { - - final Map data = { - 'total': 5, - 'documents': [],}; - + group('Databases test', () { + late MockClient client; + late Databases databases; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.listDocuments( - databaseId: '', - collectionId: '', - ); - expect(response, isA()); - - }); - - test('test method createDocument()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.createDocument( - databaseId: '', - collectionId: '', - documentId: '', - data: {}, - ); - expect(response, isA()); - - }); - - test('test method getDocument()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.getDocument( - databaseId: '', - collectionId: '', - documentId: '', - ); - expect(response, isA()); - - }); - - test('test method upsertDocument()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.upsertDocument( - databaseId: '', - collectionId: '', - documentId: '', - ); - expect(response, isA()); - - }); - - test('test method updateDocument()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.updateDocument( - databaseId: '', - collectionId: '', - documentId: '', - ); - expect(response, isA()); - - }); + setUp(() { + client = MockClient(); + databases = Databases(client); + }); - test('test method deleteDocument()', () async { + test('test method listTransactions()', () async { + final Map data = { + 'total': 5, + 'transactions': [], + }; - final data = ''; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + final response = await databases.listTransactions(); + expect(response, isA()); + }); + test('test method createTransaction()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.createTransaction(); + expect(response, isA()); + }); - final response = await databases.deleteDocument( - databaseId: '', - collectionId: '', - documentId: '', - ); - }); + test('test method getTransaction()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.getTransaction( + transactionId: '', + ); + expect(response, isA()); + }); - test('test method decrementDocumentAttribute()', () async { + test('test method updateTransaction()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.updateTransaction( + transactionId: '', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; + test('test method deleteTransaction()', () async { + final data = ''; + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + final response = await databases.deleteTransaction( + transactionId: '', + ); + }); + test('test method createOperations()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.createOperations( + transactionId: '', + ); + expect(response, isA()); + }); - final response = await databases.decrementDocumentAttribute( - databaseId: '', - collectionId: '', - documentId: '', - attribute: '', - ); - expect(response, isA()); + test('test method listDocuments()', () async { + final Map data = { + 'total': 5, + 'documents': [], + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.listDocuments( + databaseId: '', + collectionId: '', + ); + expect(response, isA()); + }); - }); + test('test method createDocument()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.createDocument( + databaseId: '', + collectionId: '', + documentId: '', + data: {}, + ); + expect(response, isA()); + }); - test('test method incrementDocumentAttribute()', () async { + test('test method getDocument()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.getDocument( + databaseId: '', + collectionId: '', + documentId: '', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; + test('test method upsertDocument()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.upsertDocument( + databaseId: '', + collectionId: '', + documentId: '', + ); + expect(response, isA()); + }); + test('test method updateDocument()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.updateDocument( + databaseId: '', + collectionId: '', + documentId: '', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + test('test method deleteDocument()', () async { + final data = ''; + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - final response = await databases.incrementDocumentAttribute( - databaseId: '', - collectionId: '', - documentId: '', - attribute: '', - ); - expect(response, isA()); + final response = await databases.deleteDocument( + databaseId: '', + collectionId: '', + documentId: '', + ); + }); - }); + test('test method decrementDocumentAttribute()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.decrementDocumentAttribute( + databaseId: '', + collectionId: '', + documentId: '', + attribute: '', + ); + expect(response, isA()); + }); + test('test method incrementDocumentAttribute()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.incrementDocumentAttribute( + databaseId: '', + collectionId: '', + documentId: '', + attribute: '', + ); + expect(response, isA()); }); + }); } diff --git a/test/services/functions_test.dart b/test/services/functions_test.dart index 9b0d046f..c6e50a50 100644 --- a/test/services/functions_test.dart +++ b/test/services/functions_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,107 +40,100 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Functions test', () { - late MockClient client; - late Functions functions; - - setUp(() { - client = MockClient(); - functions = Functions(client); - }); - - test('test method listExecutions()', () async { - - final Map data = { - 'total': 5, - 'executions': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await functions.listExecutions( - functionId: '', - ); - expect(response, isA()); - - }); - - test('test method createExecution()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'functionId': '5e5ea6g16897e', - 'deploymentId': '5e5ea5c16897e', - 'trigger': 'http', - 'status': 'processing', - 'requestMethod': 'GET', - 'requestPath': '/articles?id=5', - 'requestHeaders': [], - 'responseStatusCode': 200, - 'responseBody': '', - 'responseHeaders': [], - 'logs': '', - 'errors': '', - 'duration': 0.4,}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await functions.createExecution( - functionId: '', - ); - expect(response, isA()); - - }); - - test('test method getExecution()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'functionId': '5e5ea6g16897e', - 'deploymentId': '5e5ea5c16897e', - 'trigger': 'http', - 'status': 'processing', - 'requestMethod': 'GET', - 'requestPath': '/articles?id=5', - 'requestHeaders': [], - 'responseStatusCode': 200, - 'responseBody': '', - 'responseHeaders': [], - 'logs': '', - 'errors': '', - 'duration': 0.4,}; + group('Functions test', () { + late MockClient client; + late Functions functions; + setUp(() { + client = MockClient(); + functions = Functions(client); + }); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + test('test method listExecutions()', () async { + final Map data = { + 'total': 5, + 'executions': [], + }; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await functions.getExecution( - functionId: '', - executionId: '', - ); - expect(response, isA()); + final response = await functions.listExecutions( + functionId: '', + ); + expect(response, isA()); + }); - }); + test('test method createExecution()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'functionId': '5e5ea6g16897e', + 'deploymentId': '5e5ea5c16897e', + 'trigger': 'http', + 'status': 'processing', + 'requestMethod': 'GET', + 'requestPath': '/articles?id=5', + 'requestHeaders': [], + 'responseStatusCode': 200, + 'responseBody': '', + 'responseHeaders': [], + 'logs': '', + 'errors': '', + 'duration': 0.4, + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await functions.createExecution( + functionId: '', + ); + expect(response, isA()); + }); + test('test method getExecution()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'functionId': '5e5ea6g16897e', + 'deploymentId': '5e5ea5c16897e', + 'trigger': 'http', + 'status': 'processing', + 'requestMethod': 'GET', + 'requestPath': '/articles?id=5', + 'requestHeaders': [], + 'responseStatusCode': 200, + 'responseBody': '', + 'responseHeaders': [], + 'logs': '', + 'errors': '', + 'duration': 0.4, + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await functions.getExecution( + functionId: '', + executionId: '', + ); + expect(response, isA()); }); + }); } diff --git a/test/services/graphql_test.dart b/test/services/graphql_test.dart index c548e414..84b7de1c 100644 --- a/test/services/graphql_test.dart +++ b/test/services/graphql_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,47 +40,45 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Graphql test', () { - late MockClient client; - late Graphql graphql; - - setUp(() { - client = MockClient(); - graphql = Graphql(client); - }); - - test('test method query()', () async { - - final data = ''; + group('Graphql test', () { + late MockClient client; + late Graphql graphql; - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await graphql.query( - query: {}, - ); - }); + setUp(() { + client = MockClient(); + graphql = Graphql(client); + }); - test('test method mutation()', () async { + test('test method query()', () async { + final data = ''; - final data = ''; + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + final response = await graphql.query( + query: {}, + ); + }); + test('test method mutation()', () async { + final data = ''; - final response = await graphql.mutation( - query: {}, - ); - }); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + final response = await graphql.mutation( + query: {}, + ); }); + }); } diff --git a/test/services/locale_test.dart b/test/services/locale_test.dart index 42faaf72..f9f6489d 100644 --- a/test/services/locale_test.dart +++ b/test/services/locale_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,168 +40,138 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Locale test', () { - late MockClient client; - late Locale locale; - - setUp(() { - client = MockClient(); - locale = Locale(client); - }); - - test('test method get()', () async { - - final Map data = { - 'ip': '127.0.0.1', - 'countryCode': 'US', - 'country': 'United States', - 'continentCode': 'NA', - 'continent': 'North America', - 'eu': true, - 'currency': 'USD',}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await locale.get( - ); - expect(response, isA()); - - }); - - test('test method listCodes()', () async { - - final Map data = { - 'total': 5, - 'localeCodes': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await locale.listCodes( - ); - expect(response, isA()); - - }); - - test('test method listContinents()', () async { - - final Map data = { - 'total': 5, - 'continents': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await locale.listContinents( - ); - expect(response, isA()); + group('Locale test', () { + late MockClient client; + late Locale locale; - }); - - test('test method listCountries()', () async { - - final Map data = { - 'total': 5, - 'countries': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await locale.listCountries( - ); - expect(response, isA()); - - }); - - test('test method listCountriesEU()', () async { - - final Map data = { - 'total': 5, - 'countries': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await locale.listCountriesEU( - ); - expect(response, isA()); - - }); + setUp(() { + client = MockClient(); + locale = Locale(client); + }); - test('test method listCountriesPhones()', () async { + test('test method get()', () async { + final Map data = { + 'ip': '127.0.0.1', + 'countryCode': 'US', + 'country': 'United States', + 'continentCode': 'NA', + 'continent': 'North America', + 'eu': true, + 'currency': 'USD', + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await locale.get(); + expect(response, isA()); + }); - final Map data = { - 'total': 5, - 'phones': [],}; + test('test method listCodes()', () async { + final Map data = { + 'total': 5, + 'localeCodes': [], + }; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final response = await locale.listCodes(); + expect(response, isA()); + }); + test('test method listContinents()', () async { + final Map data = { + 'total': 5, + 'continents': [], + }; - final response = await locale.listCountriesPhones( - ); - expect(response, isA()); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await locale.listContinents(); + expect(response, isA()); + }); - test('test method listCurrencies()', () async { + test('test method listCountries()', () async { + final Map data = { + 'total': 5, + 'countries': [], + }; - final Map data = { - 'total': 5, - 'currencies': [],}; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await locale.listCountries(); + expect(response, isA()); + }); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + test('test method listCountriesEU()', () async { + final Map data = { + 'total': 5, + 'countries': [], + }; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await locale.listCurrencies( - ); - expect(response, isA()); + final response = await locale.listCountriesEU(); + expect(response, isA()); + }); - }); + test('test method listCountriesPhones()', () async { + final Map data = { + 'total': 5, + 'phones': [], + }; - test('test method listLanguages()', () async { + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final Map data = { - 'total': 5, - 'languages': [],}; + final response = await locale.listCountriesPhones(); + expect(response, isA()); + }); + test('test method listCurrencies()', () async { + final Map data = { + 'total': 5, + 'currencies': [], + }; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await locale.listCurrencies(); + expect(response, isA()); + }); - final response = await locale.listLanguages( - ); - expect(response, isA()); + test('test method listLanguages()', () async { + final Map data = { + 'total': 5, + 'languages': [], + }; - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await locale.listLanguages(); + expect(response, isA()); }); + }); } diff --git a/test/services/messaging_test.dart b/test/services/messaging_test.dart index 5899ace3..0c938eff 100644 --- a/test/services/messaging_test.dart +++ b/test/services/messaging_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,71 +40,68 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Messaging test', () { - late MockClient client; - late Messaging messaging; - - setUp(() { - client = MockClient(); - messaging = Messaging(client); - }); - - test('test method createSubscriber()', () async { - - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'targetId': '259125845563242502', - 'target': { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'Apple iPhone 12', - 'userId': '259125845563242502', - 'providerType': 'email', - 'identifier': 'token', - 'expired': true, - }, - 'userId': '5e5ea5c16897e', - 'userName': 'Aegon Targaryen', - 'topicId': '259125845563242502', - 'providerType': 'email',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + group('Messaging test', () { + late MockClient client; + late Messaging messaging; + setUp(() { + client = MockClient(); + messaging = Messaging(client); + }); - final response = await messaging.createSubscriber( - topicId: '', - subscriberId: '', - targetId: '', - ); - expect(response, isA()); - - }); - - test('test method deleteSubscriber()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + test('test method createSubscriber()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'targetId': '259125845563242502', + 'target': { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Apple iPhone 12', + 'userId': '259125845563242502', + 'providerType': 'email', + 'identifier': 'token', + 'expired': true, + }, + 'userId': '5e5ea5c16897e', + 'userName': 'Aegon Targaryen', + 'topicId': '259125845563242502', + 'providerType': 'email', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await messaging.createSubscriber( + topicId: '', + subscriberId: '', + targetId: '', + ); + expect(response, isA()); + }); + test('test method deleteSubscriber()', () async { + final data = ''; - final response = await messaging.deleteSubscriber( - topicId: '', - subscriberId: '', - ); - }); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + final response = await messaging.deleteSubscriber( + topicId: '', + subscriberId: '', + ); }); + }); } diff --git a/test/services/presences_test.dart b/test/services/presences_test.dart index 7b99675f..7fed0439 100644 --- a/test/services/presences_test.dart +++ b/test/services/presences_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,121 +40,108 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Presences test', () { - late MockClient client; - late Presences presences; - - setUp(() { - client = MockClient(); - presences = Presences(client); - }); - - test('test method list()', () async { - - final Map data = { - 'total': 5, - 'presences': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await presences.list( - ); - expect(response, isA()); - - }); - - test('test method get()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'userId': '674af8f3e12a5f9ac0be', - 'source': 'HTTP',}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await presences.get( - presenceId: '', - ); - expect(response, isA()); - - }); + group('Presences test', () { + late MockClient client; + late Presences presences; - test('test method upsert()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'userId': '674af8f3e12a5f9ac0be', - 'source': 'HTTP',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await presences.upsert( - presenceId: '', - status: '', - ); - expect(response, isA()); - - }); - - test('test method update()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'userId': '674af8f3e12a5f9ac0be', - 'source': 'HTTP',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + setUp(() { + client = MockClient(); + presences = Presences(client); + }); + test('test method list()', () async { + final Map data = { + 'total': 5, + 'presences': [], + }; - final response = await presences.update( - presenceId: '', - ); - expect(response, isA()); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await presences.list(); + expect(response, isA()); + }); - test('test method delete()', () async { + test('test method get()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'userId': '674af8f3e12a5f9ac0be', + 'source': 'HTTP', + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await presences.get( + presenceId: '', + ); + expect(response, isA()); + }); - final data = ''; + test('test method upsert()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'userId': '674af8f3e12a5f9ac0be', + 'source': 'HTTP', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await presences.upsert( + presenceId: '', + status: '', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + test('test method update()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'userId': '674af8f3e12a5f9ac0be', + 'source': 'HTTP', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await presences.update( + presenceId: '', + ); + expect(response, isA()); + }); + test('test method delete()', () async { + final data = ''; - final response = await presences.delete( - presenceId: '', - ); - }); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + final response = await presences.delete( + presenceId: '', + ); }); + }); } diff --git a/test/services/storage_test.dart b/test/services/storage_test.dart index 2390bfdd..55a42f94 100644 --- a/test/services/storage_test.dart +++ b/test/services/storage_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,202 +40,184 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Storage test', () { - late MockClient client; - late Storage storage; - - setUp(() { - client = MockClient(); - storage = Storage(client); - }); - - test('test method listFiles()', () async { - - final Map data = { - 'total': 5, - 'files': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await storage.listFiles( - bucketId: '', - ); - expect(response, isA()); - - }); - - test('test method createFile()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - 'bucketId': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'name': 'Pink.png', - 'signature': '5d529fd02b544198ae075bd57c1762bb', - 'mimeType': 'image/png', - 'sizeOriginal': 17890, - 'sizeActual': 12345, - 'chunksTotal': 17890, - 'chunksUploaded': 17890, - 'encryption': true, - 'compression': 'gzip',}; - - - when(client.chunkedUpload( - path: argThat(isNotNull), - params: argThat(isNotNull), - paramName: argThat(isNotNull), - idParamName: argThat(isNotNull), - headers: argThat(isNotNull), - )).thenAnswer((_) async => Response(data: data)); - - - final response = await storage.createFile( - bucketId: '', - fileId: '', - file: InputFile.fromPath(path: './image.png'), - ); - expect(response, isA()); - - }); - - test('test method getFile()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - 'bucketId': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'name': 'Pink.png', - 'signature': '5d529fd02b544198ae075bd57c1762bb', - 'mimeType': 'image/png', - 'sizeOriginal': 17890, - 'sizeActual': 12345, - 'chunksTotal': 17890, - 'chunksUploaded': 17890, - 'encryption': true, - 'compression': 'gzip',}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await storage.getFile( - bucketId: '', - fileId: '', - ); - expect(response, isA()); - - }); - - test('test method updateFile()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - 'bucketId': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'name': 'Pink.png', - 'signature': '5d529fd02b544198ae075bd57c1762bb', - 'mimeType': 'image/png', - 'sizeOriginal': 17890, - 'sizeActual': 12345, - 'chunksTotal': 17890, - 'chunksUploaded': 17890, - 'encryption': true, - 'compression': 'gzip',}; - + group('Storage test', () { + late MockClient client; + late Storage storage; - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await storage.updateFile( - bucketId: '', - fileId: '', - ); - expect(response, isA()); - - }); - - test('test method deleteFile()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + setUp(() { + client = MockClient(); + storage = Storage(client); + }); + test('test method listFiles()', () async { + final Map data = { + 'total': 5, + 'files': [], + }; - final response = await storage.deleteFile( - bucketId: '', - fileId: '', - ); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method getFileDownload()', () async { -final Uint8List data = Uint8List.fromList([]); + final response = await storage.listFiles( + bucketId: '', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + test('test method createFile()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + 'bucketId': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'name': 'Pink.png', + 'signature': '5d529fd02b544198ae075bd57c1762bb', + 'mimeType': 'image/png', + 'sizeOriginal': 17890, + 'sizeActual': 12345, + 'chunksTotal': 17890, + 'chunksUploaded': 17890, + 'encryption': true, + 'compression': 'gzip', + }; + + when(client.chunkedUpload( + path: argThat(isNotNull), + params: argThat(isNotNull), + paramName: argThat(isNotNull), + idParamName: argThat(isNotNull), + headers: argThat(isNotNull), + )).thenAnswer((_) async => Response(data: data)); + + final response = await storage.createFile( + bucketId: '', + fileId: '', + file: InputFile.fromPath(path: './image.png'), + ); + expect(response, isA()); + }); + test('test method getFile()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + 'bucketId': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'name': 'Pink.png', + 'signature': '5d529fd02b544198ae075bd57c1762bb', + 'mimeType': 'image/png', + 'sizeOriginal': 17890, + 'sizeActual': 12345, + 'chunksTotal': 17890, + 'chunksUploaded': 17890, + 'encryption': true, + 'compression': 'gzip', + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await storage.getFile( + bucketId: '', + fileId: '', + ); + expect(response, isA()); + }); - final response = await storage.getFileDownload( - bucketId: '', - fileId: '', - ); - expect(response, isA()); + test('test method updateFile()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + 'bucketId': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'name': 'Pink.png', + 'signature': '5d529fd02b544198ae075bd57c1762bb', + 'mimeType': 'image/png', + 'sizeOriginal': 17890, + 'sizeActual': 12345, + 'chunksTotal': 17890, + 'chunksUploaded': 17890, + 'encryption': true, + 'compression': 'gzip', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await storage.updateFile( + bucketId: '', + fileId: '', + ); + expect(response, isA()); + }); - }); + test('test method deleteFile()', () async { + final data = ''; - test('test method getFilePreview()', () async { -final Uint8List data = Uint8List.fromList([]); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final response = await storage.deleteFile( + bucketId: '', + fileId: '', + ); + }); + test('test method getFileDownload()', () async { + final Uint8List data = Uint8List.fromList([]); - final response = await storage.getFilePreview( - bucketId: '', - fileId: '', - ); - expect(response, isA()); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await storage.getFileDownload( + bucketId: '', + fileId: '', + ); + expect(response, isA()); + }); - test('test method getFileView()', () async { -final Uint8List data = Uint8List.fromList([]); + test('test method getFilePreview()', () async { + final Uint8List data = Uint8List.fromList([]); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await storage.getFilePreview( + bucketId: '', + fileId: '', + ); + expect(response, isA()); + }); - final response = await storage.getFileView( - bucketId: '', - fileId: '', - ); - expect(response, isA()); + test('test method getFileView()', () async { + final Uint8List data = Uint8List.fromList([]); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await storage.getFileView( + bucketId: '', + fileId: '', + ); + expect(response, isA()); }); + }); } diff --git a/test/services/tables_db_test.dart b/test/services/tables_db_test.dart index 5219d2bf..f318cad2 100644 --- a/test/services/tables_db_test.dart +++ b/test/services/tables_db_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,337 +40,297 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('TablesDB test', () { - late MockClient client; - late TablesDB tablesDB; - - setUp(() { - client = MockClient(); - tablesDB = TablesDB(client); - }); - - test('test method listTransactions()', () async { - - final Map data = { - 'total': 5, - 'transactions': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.listTransactions( - ); - expect(response, isA()); - - }); - - test('test method createTransaction()', () async { - - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.createTransaction( - ); - expect(response, isA()); - - }); - - test('test method getTransaction()', () async { - - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.getTransaction( - transactionId: '', - ); - expect(response, isA()); - - }); - - test('test method updateTransaction()', () async { - - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.updateTransaction( - transactionId: '', - ); - expect(response, isA()); - - }); - - test('test method deleteTransaction()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.deleteTransaction( - transactionId: '', - ); - }); - - test('test method createOperations()', () async { - - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.createOperations( - transactionId: '', - ); - expect(response, isA()); - - }); - - test('test method listRows()', () async { - - final Map data = { - 'total': 5, - 'rows': [],}; - + group('TablesDB test', () { + late MockClient client; + late TablesDB tablesDB; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.listRows( - databaseId: '', - tableId: '', - ); - expect(response, isA()); - - }); - - test('test method createRow()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.createRow( - databaseId: '', - tableId: '', - rowId: '', - data: {}, - ); - expect(response, isA()); - - }); - - test('test method getRow()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.getRow( - databaseId: '', - tableId: '', - rowId: '', - ); - expect(response, isA()); - - }); - - test('test method upsertRow()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.upsertRow( - databaseId: '', - tableId: '', - rowId: '', - ); - expect(response, isA()); - - }); - - test('test method updateRow()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.updateRow( - databaseId: '', - tableId: '', - rowId: '', - ); - expect(response, isA()); - - }); + setUp(() { + client = MockClient(); + tablesDB = TablesDB(client); + }); - test('test method deleteRow()', () async { + test('test method listTransactions()', () async { + final Map data = { + 'total': 5, + 'transactions': [], + }; - final data = ''; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + final response = await tablesDB.listTransactions(); + expect(response, isA()); + }); + test('test method createTransaction()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.createTransaction(); + expect(response, isA()); + }); - final response = await tablesDB.deleteRow( - databaseId: '', - tableId: '', - rowId: '', - ); - }); + test('test method getTransaction()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.getTransaction( + transactionId: '', + ); + expect(response, isA()); + }); - test('test method decrementRowColumn()', () async { + test('test method updateTransaction()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.updateTransaction( + transactionId: '', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; + test('test method deleteTransaction()', () async { + final data = ''; + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + final response = await tablesDB.deleteTransaction( + transactionId: '', + ); + }); + test('test method createOperations()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.createOperations( + transactionId: '', + ); + expect(response, isA()); + }); - final response = await tablesDB.decrementRowColumn( - databaseId: '', - tableId: '', - rowId: '', - column: '', - ); - expect(response, isA()); + test('test method listRows()', () async { + final Map data = { + 'total': 5, + 'rows': [], + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.listRows( + databaseId: '', + tableId: '', + ); + expect(response, isA()); + }); - }); + test('test method createRow()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.createRow( + databaseId: '', + tableId: '', + rowId: '', + data: {}, + ); + expect(response, isA()); + }); - test('test method incrementRowColumn()', () async { + test('test method getRow()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.getRow( + databaseId: '', + tableId: '', + rowId: '', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; + test('test method upsertRow()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.upsertRow( + databaseId: '', + tableId: '', + rowId: '', + ); + expect(response, isA()); + }); + test('test method updateRow()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.updateRow( + databaseId: '', + tableId: '', + rowId: '', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + test('test method deleteRow()', () async { + final data = ''; + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - final response = await tablesDB.incrementRowColumn( - databaseId: '', - tableId: '', - rowId: '', - column: '', - ); - expect(response, isA()); + final response = await tablesDB.deleteRow( + databaseId: '', + tableId: '', + rowId: '', + ); + }); - }); + test('test method decrementRowColumn()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.decrementRowColumn( + databaseId: '', + tableId: '', + rowId: '', + column: '', + ); + expect(response, isA()); + }); + test('test method incrementRowColumn()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.incrementRowColumn( + databaseId: '', + tableId: '', + rowId: '', + column: '', + ); + expect(response, isA()); }); + }); } diff --git a/test/services/teams_test.dart b/test/services/teams_test.dart index ea72a432..83f2667b 100644 --- a/test/services/teams_test.dart +++ b/test/services/teams_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,326 +40,288 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Teams test', () { - late MockClient client; - late Teams teams; - - setUp(() { - client = MockClient(); - teams = Teams(client); - }); - - test('test method list()', () async { - - final Map data = { - 'total': 5, - 'teams': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.list( - ); - expect(response, isA()); - - }); - - test('test method create()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'VIP', - 'total': 7, - 'prefs': {},}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.create( - teamId: '', - name: '', - ); - expect(response, isA()); - - }); - - test('test method get()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'VIP', - 'total': 7, - 'prefs': {},}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.get( - teamId: '', - ); - expect(response, isA()); - - }); - - test('test method updateName()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'VIP', - 'total': 7, - 'prefs': {},}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.updateName( - teamId: '', - name: '', - ); - expect(response, isA()); - - }); - - test('test method delete()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.delete( - teamId: '', - ); - }); - - test('test method listMemberships()', () async { - - final Map data = { - 'total': 5, - 'memberships': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + group('Teams test', () { + late MockClient client; + late Teams teams; + setUp(() { + client = MockClient(); + teams = Teams(client); + }); - final response = await teams.listMemberships( - teamId: '', - ); - expect(response, isA()); - - }); - - test('test method createMembership()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [],}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.createMembership( - teamId: '', - roles: [], - ); - expect(response, isA()); - - }); - - test('test method getMembership()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.getMembership( - teamId: '', - membershipId: '', - ); - expect(response, isA()); - - }); - - test('test method updateMembership()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [],}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.updateMembership( - teamId: '', - membershipId: '', - roles: [], - ); - expect(response, isA()); - - }); - - test('test method deleteMembership()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + test('test method list()', () async { + final Map data = { + 'total': 5, + 'teams': [], + }; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await teams.deleteMembership( - teamId: '', - membershipId: '', - ); - }); + final response = await teams.list(); + expect(response, isA()); + }); - test('test method updateMembershipStatus()', () async { + test('test method create()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'VIP', + 'total': 7, + 'prefs': {}, + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await teams.create( + teamId: '', + name: '', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [],}; + test('test method get()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'VIP', + 'total': 7, + 'prefs': {}, + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await teams.get( + teamId: '', + ); + expect(response, isA()); + }); + test('test method updateName()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'VIP', + 'total': 7, + 'prefs': {}, + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await teams.updateName( + teamId: '', + name: '', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + test('test method delete()', () async { + final data = ''; + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - final response = await teams.updateMembershipStatus( - teamId: '', - membershipId: '', - userId: '', - secret: '', - ); - expect(response, isA()); + final response = await teams.delete( + teamId: '', + ); + }); - }); + test('test method listMemberships()', () async { + final Map data = { + 'total': 5, + 'memberships': [], + }; - test('test method getPrefs()', () async { + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final Map data = {}; + final response = await teams.listMemberships( + teamId: '', + ); + expect(response, isA()); + }); + test('test method createMembership()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'userPhone': '+1 555 555 5555', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'roles': [], + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await teams.createMembership( + teamId: '', + roles: [], + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + test('test method getMembership()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'userPhone': '+1 555 555 5555', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'roles': [], + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await teams.getMembership( + teamId: '', + membershipId: '', + ); + expect(response, isA()); + }); + test('test method updateMembership()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'userPhone': '+1 555 555 5555', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'roles': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await teams.updateMembership( + teamId: '', + membershipId: '', + roles: [], + ); + expect(response, isA()); + }); - final response = await teams.getPrefs( - teamId: '', - ); - expect(response, isA()); + test('test method deleteMembership()', () async { + final data = ''; - }); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - test('test method updatePrefs()', () async { + final response = await teams.deleteMembership( + teamId: '', + membershipId: '', + ); + }); - final Map data = {}; + test('test method updateMembershipStatus()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'userPhone': '+1 555 555 5555', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'roles': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await teams.updateMembershipStatus( + teamId: '', + membershipId: '', + userId: '', + secret: '', + ); + expect(response, isA()); + }); + test('test method getPrefs()', () async { + final Map data = {}; - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await teams.getPrefs( + teamId: '', + ); + expect(response, isA()); + }); - final response = await teams.updatePrefs( - teamId: '', - prefs: {}, - ); - expect(response, isA()); + test('test method updatePrefs()', () async { + final Map data = {}; - }); + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + final response = await teams.updatePrefs( + teamId: '', + prefs: {}, + ); + expect(response, isA()); }); + }); } diff --git a/test/src/models/algo_argon2_test.dart b/test/src/models/algo_argon2_test.dart index 15e85f5a..261daa46 100644 --- a/test/src/models/algo_argon2_test.dart +++ b/test/src/models/algo_argon2_test.dart @@ -14,10 +14,10 @@ void main() { final map = model.toMap(); final result = AlgoArgon2.fromMap(map); - expect(result.type, 'argon2'); - expect(result.memoryCost, 65536); - expect(result.timeCost, 4); - expect(result.threads, 3); - }); + expect(result.type, 'argon2'); + expect(result.memoryCost, 65536); + expect(result.timeCost, 4); + expect(result.threads, 3); + }); }); } diff --git a/test/src/models/algo_bcrypt_test.dart b/test/src/models/algo_bcrypt_test.dart index 87a3ca3c..3da36624 100644 --- a/test/src/models/algo_bcrypt_test.dart +++ b/test/src/models/algo_bcrypt_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = AlgoBcrypt.fromMap(map); - expect(result.type, 'bcrypt'); - }); + expect(result.type, 'bcrypt'); + }); }); } diff --git a/test/src/models/algo_md5_test.dart b/test/src/models/algo_md5_test.dart index 3b842e6c..e58fa5b5 100644 --- a/test/src/models/algo_md5_test.dart +++ b/test/src/models/algo_md5_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = AlgoMd5.fromMap(map); - expect(result.type, 'md5'); - }); + expect(result.type, 'md5'); + }); }); } diff --git a/test/src/models/algo_phpass_test.dart b/test/src/models/algo_phpass_test.dart index 49b1e22c..3bcbb488 100644 --- a/test/src/models/algo_phpass_test.dart +++ b/test/src/models/algo_phpass_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = AlgoPhpass.fromMap(map); - expect(result.type, 'phpass'); - }); + expect(result.type, 'phpass'); + }); }); } diff --git a/test/src/models/algo_scrypt_modified_test.dart b/test/src/models/algo_scrypt_modified_test.dart index dd7fa8c3..b2084927 100644 --- a/test/src/models/algo_scrypt_modified_test.dart +++ b/test/src/models/algo_scrypt_modified_test.dart @@ -8,16 +8,18 @@ void main() { type: 'scryptMod', salt: 'UxLMreBr6tYyjQ==', saltSeparator: 'Bw==', - signerKey: 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ==', + signerKey: + 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ==', ); final map = model.toMap(); final result = AlgoScryptModified.fromMap(map); - expect(result.type, 'scryptMod'); - expect(result.salt, 'UxLMreBr6tYyjQ=='); - expect(result.saltSeparator, 'Bw=='); - expect(result.signerKey, 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ=='); - }); + expect(result.type, 'scryptMod'); + expect(result.salt, 'UxLMreBr6tYyjQ=='); + expect(result.saltSeparator, 'Bw=='); + expect(result.signerKey, + 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ=='); + }); }); } diff --git a/test/src/models/algo_scrypt_test.dart b/test/src/models/algo_scrypt_test.dart index c7d9cdbf..8c131568 100644 --- a/test/src/models/algo_scrypt_test.dart +++ b/test/src/models/algo_scrypt_test.dart @@ -15,11 +15,11 @@ void main() { final map = model.toMap(); final result = AlgoScrypt.fromMap(map); - expect(result.type, 'scrypt'); - expect(result.costCpu, 8); - expect(result.costMemory, 14); - expect(result.costParallel, 1); - expect(result.length, 64); - }); + expect(result.type, 'scrypt'); + expect(result.costCpu, 8); + expect(result.costMemory, 14); + expect(result.costParallel, 1); + expect(result.length, 64); + }); }); } diff --git a/test/src/models/algo_sha_test.dart b/test/src/models/algo_sha_test.dart index ae58b57e..d080569c 100644 --- a/test/src/models/algo_sha_test.dart +++ b/test/src/models/algo_sha_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = AlgoSha.fromMap(map); - expect(result.type, 'sha'); - }); + expect(result.type, 'sha'); + }); }); } diff --git a/test/src/models/continent_list_test.dart b/test/src/models/continent_list_test.dart index 8de695b0..e71dcae1 100644 --- a/test/src/models/continent_list_test.dart +++ b/test/src/models/continent_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = ContinentList.fromMap(map); - expect(result.total, 5); - expect(result.continents, []); - }); + expect(result.total, 5); + expect(result.continents, []); + }); }); } diff --git a/test/src/models/continent_test.dart b/test/src/models/continent_test.dart index d5242a4e..85e559f5 100644 --- a/test/src/models/continent_test.dart +++ b/test/src/models/continent_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = Continent.fromMap(map); - expect(result.name, 'Europe'); - expect(result.code, 'EU'); - }); + expect(result.name, 'Europe'); + expect(result.code, 'EU'); + }); }); } diff --git a/test/src/models/country_list_test.dart b/test/src/models/country_list_test.dart index 869f5db6..6df5c584 100644 --- a/test/src/models/country_list_test.dart +++ b/test/src/models/country_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = CountryList.fromMap(map); - expect(result.total, 5); - expect(result.countries, []); - }); + expect(result.total, 5); + expect(result.countries, []); + }); }); } diff --git a/test/src/models/country_test.dart b/test/src/models/country_test.dart index bc66ab7b..d5404a7f 100644 --- a/test/src/models/country_test.dart +++ b/test/src/models/country_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = Country.fromMap(map); - expect(result.name, 'United States'); - expect(result.code, 'US'); - }); + expect(result.name, 'United States'); + expect(result.code, 'US'); + }); }); } diff --git a/test/src/models/currency_list_test.dart b/test/src/models/currency_list_test.dart index 09da675c..d7410db8 100644 --- a/test/src/models/currency_list_test.dart +++ b/test/src/models/currency_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = CurrencyList.fromMap(map); - expect(result.total, 5); - expect(result.currencies, []); - }); + expect(result.total, 5); + expect(result.currencies, []); + }); }); } diff --git a/test/src/models/currency_test.dart b/test/src/models/currency_test.dart index 29890008..00e046c7 100644 --- a/test/src/models/currency_test.dart +++ b/test/src/models/currency_test.dart @@ -17,13 +17,13 @@ void main() { final map = model.toMap(); final result = Currency.fromMap(map); - expect(result.symbol, '\$'); - expect(result.name, 'US dollar'); - expect(result.symbolNative, '\$'); - expect(result.decimalDigits, 2); - expect(result.rounding, 0); - expect(result.code, 'USD'); - expect(result.namePlural, 'US dollars'); - }); + expect(result.symbol, '\$'); + expect(result.name, 'US dollar'); + expect(result.symbolNative, '\$'); + expect(result.decimalDigits, 2); + expect(result.rounding, 0); + expect(result.code, 'USD'); + expect(result.namePlural, 'US dollars'); + }); }); } diff --git a/test/src/models/document_list_test.dart b/test/src/models/document_list_test.dart index f1a5b3cc..217d37e8 100644 --- a/test/src/models/document_list_test.dart +++ b/test/src/models/document_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = DocumentList.fromMap(map); - expect(result.total, 5); - expect(result.documents, []); - }); + expect(result.total, 5); + expect(result.documents, []); + }); }); } diff --git a/test/src/models/document_test.dart b/test/src/models/document_test.dart index 6c1fbb77..397b5fab 100644 --- a/test/src/models/document_test.dart +++ b/test/src/models/document_test.dart @@ -18,13 +18,13 @@ void main() { final map = model.toMap(); final result = Document.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$sequence, '1'); - expect(result.$collectionId, '5e5ea5c15117e'); - expect(result.$databaseId, '5e5ea5c15117e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$sequence, '1'); + expect(result.$collectionId, '5e5ea5c15117e'); + expect(result.$databaseId, '5e5ea5c15117e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + }); }); } diff --git a/test/src/models/execution_list_test.dart b/test/src/models/execution_list_test.dart index fe74af58..a3305e55 100644 --- a/test/src/models/execution_list_test.dart +++ b/test/src/models/execution_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = ExecutionList.fromMap(map); - expect(result.total, 5); - expect(result.executions, []); - }); + expect(result.total, 5); + expect(result.executions, []); + }); }); } diff --git a/test/src/models/execution_test.dart b/test/src/models/execution_test.dart index 6d9bf33c..80ef508a 100644 --- a/test/src/models/execution_test.dart +++ b/test/src/models/execution_test.dart @@ -28,23 +28,23 @@ void main() { final map = model.toMap(); final result = Execution.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - expect(result.functionId, '5e5ea6g16897e'); - expect(result.deploymentId, '5e5ea5c16897e'); - expect(result.trigger, ExecutionTrigger.http); - expect(result.status, ExecutionStatus.waiting); - expect(result.requestMethod, 'GET'); - expect(result.requestPath, '/articles?id=5'); - expect(result.requestHeaders, []); - expect(result.responseStatusCode, 200); - expect(result.responseBody, ''); - expect(result.responseHeaders, []); - expect(result.logs, ''); - expect(result.errors, ''); - expect(result.duration, 0.4); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + expect(result.functionId, '5e5ea6g16897e'); + expect(result.deploymentId, '5e5ea5c16897e'); + expect(result.trigger, ExecutionTrigger.http); + expect(result.status, ExecutionStatus.waiting); + expect(result.requestMethod, 'GET'); + expect(result.requestPath, '/articles?id=5'); + expect(result.requestHeaders, []); + expect(result.responseStatusCode, 200); + expect(result.responseBody, ''); + expect(result.responseHeaders, []); + expect(result.logs, ''); + expect(result.errors, ''); + expect(result.duration, 0.4); + }); }); } diff --git a/test/src/models/file_list_test.dart b/test/src/models/file_list_test.dart index d8e6c95c..8e02f65e 100644 --- a/test/src/models/file_list_test.dart +++ b/test/src/models/file_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = FileList.fromMap(map); - expect(result.total, 5); - expect(result.files, []); - }); + expect(result.total, 5); + expect(result.files, []); + }); }); } diff --git a/test/src/models/file_test.dart b/test/src/models/file_test.dart index 8a734a08..7f132646 100644 --- a/test/src/models/file_test.dart +++ b/test/src/models/file_test.dart @@ -24,20 +24,20 @@ void main() { final map = model.toMap(); final result = File.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.bucketId, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - expect(result.name, 'Pink.png'); - expect(result.signature, '5d529fd02b544198ae075bd57c1762bb'); - expect(result.mimeType, 'image/png'); - expect(result.sizeOriginal, 17890); - expect(result.sizeActual, 12345); - expect(result.chunksTotal, 17890); - expect(result.chunksUploaded, 17890); - expect(result.encryption, true); - expect(result.compression, 'gzip'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.bucketId, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + expect(result.name, 'Pink.png'); + expect(result.signature, '5d529fd02b544198ae075bd57c1762bb'); + expect(result.mimeType, 'image/png'); + expect(result.sizeOriginal, 17890); + expect(result.sizeActual, 12345); + expect(result.chunksTotal, 17890); + expect(result.chunksUploaded, 17890); + expect(result.encryption, true); + expect(result.compression, 'gzip'); + }); }); } diff --git a/test/src/models/headers_test.dart b/test/src/models/headers_test.dart index 489891d4..9252b469 100644 --- a/test/src/models/headers_test.dart +++ b/test/src/models/headers_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = Headers.fromMap(map); - expect(result.name, 'Content-Type'); - expect(result.value, 'application/json'); - }); + expect(result.name, 'Content-Type'); + expect(result.value, 'application/json'); + }); }); } diff --git a/test/src/models/identity_list_test.dart b/test/src/models/identity_list_test.dart index 65f562a7..8c35afec 100644 --- a/test/src/models/identity_list_test.dart +++ b/test/src/models/identity_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = IdentityList.fromMap(map); - expect(result.total, 5); - expect(result.identities, []); - }); + expect(result.total, 5); + expect(result.identities, []); + }); }); } diff --git a/test/src/models/identity_test.dart b/test/src/models/identity_test.dart index 708c8c60..525af4ea 100644 --- a/test/src/models/identity_test.dart +++ b/test/src/models/identity_test.dart @@ -20,16 +20,16 @@ void main() { final map = model.toMap(); final result = Identity.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5bb8c16897e'); - expect(result.provider, 'email'); - expect(result.providerUid, '5e5bb8c16897e'); - expect(result.providerEmail, 'user@example.com'); - expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); - expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5bb8c16897e'); + expect(result.provider, 'email'); + expect(result.providerUid, '5e5bb8c16897e'); + expect(result.providerEmail, 'user@example.com'); + expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); + expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + }); }); } diff --git a/test/src/models/jwt_test.dart b/test/src/models/jwt_test.dart index e616a956..93376af1 100644 --- a/test/src/models/jwt_test.dart +++ b/test/src/models/jwt_test.dart @@ -5,13 +5,15 @@ void main() { group('Jwt', () { test('model', () { final model = Jwt( - jwt: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', + jwt: + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', ); final map = model.toMap(); final result = Jwt.fromMap(map); - expect(result.jwt, 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'); - }); + expect(result.jwt, + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'); + }); }); } diff --git a/test/src/models/language_list_test.dart b/test/src/models/language_list_test.dart index 94c1e33f..a07c0b5f 100644 --- a/test/src/models/language_list_test.dart +++ b/test/src/models/language_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = LanguageList.fromMap(map); - expect(result.total, 5); - expect(result.languages, []); - }); + expect(result.total, 5); + expect(result.languages, []); + }); }); } diff --git a/test/src/models/language_test.dart b/test/src/models/language_test.dart index d4087d5e..4a6c96c1 100644 --- a/test/src/models/language_test.dart +++ b/test/src/models/language_test.dart @@ -13,9 +13,9 @@ void main() { final map = model.toMap(); final result = Language.fromMap(map); - expect(result.name, 'Italian'); - expect(result.code, 'it'); - expect(result.nativeName, 'Italiano'); - }); + expect(result.name, 'Italian'); + expect(result.code, 'it'); + expect(result.nativeName, 'Italiano'); + }); }); } diff --git a/test/src/models/locale_code_list_test.dart b/test/src/models/locale_code_list_test.dart index b6de5137..65b44ad1 100644 --- a/test/src/models/locale_code_list_test.dart +++ b/test/src/models/locale_code_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = LocaleCodeList.fromMap(map); - expect(result.total, 5); - expect(result.localeCodes, []); - }); + expect(result.total, 5); + expect(result.localeCodes, []); + }); }); } diff --git a/test/src/models/locale_code_test.dart b/test/src/models/locale_code_test.dart index f0fcdbce..88cf157b 100644 --- a/test/src/models/locale_code_test.dart +++ b/test/src/models/locale_code_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = LocaleCode.fromMap(map); - expect(result.code, 'en-us'); - expect(result.name, 'US'); - }); + expect(result.code, 'en-us'); + expect(result.name, 'US'); + }); }); } diff --git a/test/src/models/locale_test.dart b/test/src/models/locale_test.dart index 72102045..49cb1fc9 100644 --- a/test/src/models/locale_test.dart +++ b/test/src/models/locale_test.dart @@ -17,13 +17,13 @@ void main() { final map = model.toMap(); final result = Locale.fromMap(map); - expect(result.ip, '127.0.0.1'); - expect(result.countryCode, 'US'); - expect(result.country, 'United States'); - expect(result.continentCode, 'NA'); - expect(result.continent, 'North America'); - expect(result.eu, true); - expect(result.currency, 'USD'); - }); + expect(result.ip, '127.0.0.1'); + expect(result.countryCode, 'US'); + expect(result.country, 'United States'); + expect(result.continentCode, 'NA'); + expect(result.continent, 'North America'); + expect(result.eu, true); + expect(result.currency, 'USD'); + }); }); } diff --git a/test/src/models/log_list_test.dart b/test/src/models/log_list_test.dart index 84c560c8..b07ca8ee 100644 --- a/test/src/models/log_list_test.dart +++ b/test/src/models/log_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = LogList.fromMap(map); - expect(result.total, 5); - expect(result.logs, []); - }); + expect(result.total, 5); + expect(result.logs, []); + }); }); } diff --git a/test/src/models/log_test.dart b/test/src/models/log_test.dart index 1b463633..c8211d3b 100644 --- a/test/src/models/log_test.dart +++ b/test/src/models/log_test.dart @@ -32,28 +32,28 @@ void main() { final map = model.toMap(); final result = Log.fromMap(map); - expect(result.event, 'account.sessions.create'); - expect(result.userId, '610fc2f985ee0'); - expect(result.userEmail, 'john@appwrite.io'); - expect(result.userName, 'John Doe'); - expect(result.mode, 'admin'); - expect(result.userType, 'user'); - expect(result.ip, '127.0.0.1'); - expect(result.time, '2020-10-15T06:38:00.000+00:00'); - expect(result.osCode, 'Mac'); - expect(result.osName, 'Mac'); - expect(result.osVersion, 'Mac'); - expect(result.clientType, 'browser'); - expect(result.clientCode, 'CM'); - expect(result.clientName, 'Chrome Mobile iOS'); - expect(result.clientVersion, '84.0'); - expect(result.clientEngine, 'WebKit'); - expect(result.clientEngineVersion, '605.1.15'); - expect(result.deviceName, 'smartphone'); - expect(result.deviceBrand, 'Google'); - expect(result.deviceModel, 'Nexus 5'); - expect(result.countryCode, 'US'); - expect(result.countryName, 'United States'); - }); + expect(result.event, 'account.sessions.create'); + expect(result.userId, '610fc2f985ee0'); + expect(result.userEmail, 'john@appwrite.io'); + expect(result.userName, 'John Doe'); + expect(result.mode, 'admin'); + expect(result.userType, 'user'); + expect(result.ip, '127.0.0.1'); + expect(result.time, '2020-10-15T06:38:00.000+00:00'); + expect(result.osCode, 'Mac'); + expect(result.osName, 'Mac'); + expect(result.osVersion, 'Mac'); + expect(result.clientType, 'browser'); + expect(result.clientCode, 'CM'); + expect(result.clientName, 'Chrome Mobile iOS'); + expect(result.clientVersion, '84.0'); + expect(result.clientEngine, 'WebKit'); + expect(result.clientEngineVersion, '605.1.15'); + expect(result.deviceName, 'smartphone'); + expect(result.deviceBrand, 'Google'); + expect(result.deviceModel, 'Nexus 5'); + expect(result.countryCode, 'US'); + expect(result.countryName, 'United States'); + }); }); } diff --git a/test/src/models/membership_list_test.dart b/test/src/models/membership_list_test.dart index bb1f0946..4f30c48e 100644 --- a/test/src/models/membership_list_test.dart +++ b/test/src/models/membership_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = MembershipList.fromMap(map); - expect(result.total, 5); - expect(result.memberships, []); - }); + expect(result.total, 5); + expect(result.memberships, []); + }); }); } diff --git a/test/src/models/membership_test.dart b/test/src/models/membership_test.dart index ab136c24..b2b8bd3d 100644 --- a/test/src/models/membership_test.dart +++ b/test/src/models/membership_test.dart @@ -25,21 +25,21 @@ void main() { final map = model.toMap(); final result = Membership.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5ea5c16897e'); - expect(result.userName, 'John Doe'); - expect(result.userEmail, 'john@appwrite.io'); - expect(result.userPhone, '+1 555 555 5555'); - expect(result.teamId, '5e5ea5c16897e'); - expect(result.teamName, 'VIP'); - expect(result.invited, '2020-10-15T06:38:00.000+00:00'); - expect(result.joined, '2020-10-15T06:38:00.000+00:00'); - expect(result.confirm, true); - expect(result.mfa, true); - expect(result.userAccessedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.roles, []); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5ea5c16897e'); + expect(result.userName, 'John Doe'); + expect(result.userEmail, 'john@appwrite.io'); + expect(result.userPhone, '+1 555 555 5555'); + expect(result.teamId, '5e5ea5c16897e'); + expect(result.teamName, 'VIP'); + expect(result.invited, '2020-10-15T06:38:00.000+00:00'); + expect(result.joined, '2020-10-15T06:38:00.000+00:00'); + expect(result.confirm, true); + expect(result.mfa, true); + expect(result.userAccessedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.roles, []); + }); }); } diff --git a/test/src/models/mfa_challenge_test.dart b/test/src/models/mfa_challenge_test.dart index 9410baa3..5d3febca 100644 --- a/test/src/models/mfa_challenge_test.dart +++ b/test/src/models/mfa_challenge_test.dart @@ -14,10 +14,10 @@ void main() { final map = model.toMap(); final result = MfaChallenge.fromMap(map); - expect(result.$id, 'bb8ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5ea5c168bb8'); - expect(result.expire, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, 'bb8ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5ea5c168bb8'); + expect(result.expire, '2020-10-15T06:38:00.000+00:00'); + }); }); } diff --git a/test/src/models/mfa_factors_test.dart b/test/src/models/mfa_factors_test.dart index ed6467d3..64cc55e4 100644 --- a/test/src/models/mfa_factors_test.dart +++ b/test/src/models/mfa_factors_test.dart @@ -14,10 +14,10 @@ void main() { final map = model.toMap(); final result = MfaFactors.fromMap(map); - expect(result.totp, true); - expect(result.phone, true); - expect(result.email, true); - expect(result.recoveryCode, true); - }); + expect(result.totp, true); + expect(result.phone, true); + expect(result.email, true); + expect(result.recoveryCode, true); + }); }); } diff --git a/test/src/models/mfa_recovery_codes_test.dart b/test/src/models/mfa_recovery_codes_test.dart index fa097a49..500913c8 100644 --- a/test/src/models/mfa_recovery_codes_test.dart +++ b/test/src/models/mfa_recovery_codes_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = MfaRecoveryCodes.fromMap(map); - expect(result.recoveryCodes, []); - }); + expect(result.recoveryCodes, []); + }); }); } diff --git a/test/src/models/mfa_type_test.dart b/test/src/models/mfa_type_test.dart index 3f45d288..81657394 100644 --- a/test/src/models/mfa_type_test.dart +++ b/test/src/models/mfa_type_test.dart @@ -6,14 +6,16 @@ void main() { test('model', () { final model = MfaType( secret: '[SHARED_SECRET]', - uri: 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', + uri: + 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', ); final map = model.toMap(); final result = MfaType.fromMap(map); - expect(result.secret, '[SHARED_SECRET]'); - expect(result.uri, 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite'); - }); + expect(result.secret, '[SHARED_SECRET]'); + expect(result.uri, + 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite'); + }); }); } diff --git a/test/src/models/phone_list_test.dart b/test/src/models/phone_list_test.dart index 6ca46a63..bf22a5c7 100644 --- a/test/src/models/phone_list_test.dart +++ b/test/src/models/phone_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = PhoneList.fromMap(map); - expect(result.total, 5); - expect(result.phones, []); - }); + expect(result.total, 5); + expect(result.phones, []); + }); }); } diff --git a/test/src/models/phone_test.dart b/test/src/models/phone_test.dart index d0e5333b..f70db0e3 100644 --- a/test/src/models/phone_test.dart +++ b/test/src/models/phone_test.dart @@ -13,9 +13,9 @@ void main() { final map = model.toMap(); final result = Phone.fromMap(map); - expect(result.code, '+1'); - expect(result.countryCode, 'US'); - expect(result.countryName, 'United States'); - }); + expect(result.code, '+1'); + expect(result.countryCode, 'US'); + expect(result.countryName, 'United States'); + }); }); } diff --git a/test/src/models/preferences_test.dart b/test/src/models/preferences_test.dart index acde349c..9db30b03 100644 --- a/test/src/models/preferences_test.dart +++ b/test/src/models/preferences_test.dart @@ -10,7 +10,6 @@ void main() { final map = model.toMap(); final result = Preferences.fromMap(map); - }); }); } diff --git a/test/src/models/presence_list_test.dart b/test/src/models/presence_list_test.dart index 57a86348..46f69af6 100644 --- a/test/src/models/presence_list_test.dart +++ b/test/src/models/presence_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = PresenceList.fromMap(map); - expect(result.total, 5); - expect(result.presences, []); - }); + expect(result.total, 5); + expect(result.presences, []); + }); }); } diff --git a/test/src/models/presence_test.dart b/test/src/models/presence_test.dart index edcfe5f5..ef2ebe31 100644 --- a/test/src/models/presence_test.dart +++ b/test/src/models/presence_test.dart @@ -16,12 +16,12 @@ void main() { final map = model.toMap(); final result = Presence.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - expect(result.userId, '674af8f3e12a5f9ac0be'); - expect(result.source, 'HTTP'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + expect(result.userId, '674af8f3e12a5f9ac0be'); + expect(result.source, 'HTTP'); + }); }); } diff --git a/test/src/models/row_list_test.dart b/test/src/models/row_list_test.dart index d4900dd4..12693926 100644 --- a/test/src/models/row_list_test.dart +++ b/test/src/models/row_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = RowList.fromMap(map); - expect(result.total, 5); - expect(result.rows, []); - }); + expect(result.total, 5); + expect(result.rows, []); + }); }); } diff --git a/test/src/models/row_test.dart b/test/src/models/row_test.dart index 4e72a449..564bf303 100644 --- a/test/src/models/row_test.dart +++ b/test/src/models/row_test.dart @@ -18,13 +18,13 @@ void main() { final map = model.toMap(); final result = Row.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$sequence, '1'); - expect(result.$tableId, '5e5ea5c15117e'); - expect(result.$databaseId, '5e5ea5c15117e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$sequence, '1'); + expect(result.$tableId, '5e5ea5c15117e'); + expect(result.$databaseId, '5e5ea5c15117e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + }); }); } diff --git a/test/src/models/session_list_test.dart b/test/src/models/session_list_test.dart index eaab249e..708e0583 100644 --- a/test/src/models/session_list_test.dart +++ b/test/src/models/session_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = SessionList.fromMap(map); - expect(result.total, 5); - expect(result.sessions, []); - }); + expect(result.total, 5); + expect(result.sessions, []); + }); }); } diff --git a/test/src/models/session_test.dart b/test/src/models/session_test.dart index 0177e477..689e6048 100644 --- a/test/src/models/session_test.dart +++ b/test/src/models/session_test.dart @@ -39,35 +39,35 @@ void main() { final map = model.toMap(); final result = Session.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5bb8c16897e'); - expect(result.expire, '2020-10-15T06:38:00.000+00:00'); - expect(result.provider, 'email'); - expect(result.providerUid, 'user@example.com'); - expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); - expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - expect(result.ip, '127.0.0.1'); - expect(result.osCode, 'Mac'); - expect(result.osName, 'Mac'); - expect(result.osVersion, 'Mac'); - expect(result.clientType, 'browser'); - expect(result.clientCode, 'CM'); - expect(result.clientName, 'Chrome Mobile iOS'); - expect(result.clientVersion, '84.0'); - expect(result.clientEngine, 'WebKit'); - expect(result.clientEngineVersion, '605.1.15'); - expect(result.deviceName, 'smartphone'); - expect(result.deviceBrand, 'Google'); - expect(result.deviceModel, 'Nexus 5'); - expect(result.countryCode, 'US'); - expect(result.countryName, 'United States'); - expect(result.current, true); - expect(result.factors, []); - expect(result.secret, '5e5bb8c16897e'); - expect(result.mfaUpdatedAt, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5bb8c16897e'); + expect(result.expire, '2020-10-15T06:38:00.000+00:00'); + expect(result.provider, 'email'); + expect(result.providerUid, 'user@example.com'); + expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); + expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + expect(result.ip, '127.0.0.1'); + expect(result.osCode, 'Mac'); + expect(result.osName, 'Mac'); + expect(result.osVersion, 'Mac'); + expect(result.clientType, 'browser'); + expect(result.clientCode, 'CM'); + expect(result.clientName, 'Chrome Mobile iOS'); + expect(result.clientVersion, '84.0'); + expect(result.clientEngine, 'WebKit'); + expect(result.clientEngineVersion, '605.1.15'); + expect(result.deviceName, 'smartphone'); + expect(result.deviceBrand, 'Google'); + expect(result.deviceModel, 'Nexus 5'); + expect(result.countryCode, 'US'); + expect(result.countryName, 'United States'); + expect(result.current, true); + expect(result.factors, []); + expect(result.secret, '5e5bb8c16897e'); + expect(result.mfaUpdatedAt, '2020-10-15T06:38:00.000+00:00'); + }); }); } diff --git a/test/src/models/subscriber_test.dart b/test/src/models/subscriber_test.dart index 94c6a502..7445514c 100644 --- a/test/src/models/subscriber_test.dart +++ b/test/src/models/subscriber_test.dart @@ -10,15 +10,15 @@ void main() { $updatedAt: '2020-10-15T06:38:00.000+00:00', targetId: '259125845563242502', target: Target( - $id: '259125845563242502', - $createdAt: '2020-10-15T06:38:00.000+00:00', - $updatedAt: '2020-10-15T06:38:00.000+00:00', - name: 'Apple iPhone 12', - userId: '259125845563242502', - providerType: 'email', - identifier: 'token', - expired: true, - ), + $id: '259125845563242502', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Apple iPhone 12', + userId: '259125845563242502', + providerType: 'email', + identifier: 'token', + expired: true, + ), userId: '5e5ea5c16897e', userName: 'Aegon Targaryen', topicId: '259125845563242502', @@ -28,14 +28,14 @@ void main() { final map = model.toMap(); final result = Subscriber.fromMap(map); - expect(result.$id, '259125845563242502'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.targetId, '259125845563242502'); - expect(result.userId, '5e5ea5c16897e'); - expect(result.userName, 'Aegon Targaryen'); - expect(result.topicId, '259125845563242502'); - expect(result.providerType, 'email'); - }); + expect(result.$id, '259125845563242502'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.targetId, '259125845563242502'); + expect(result.userId, '5e5ea5c16897e'); + expect(result.userName, 'Aegon Targaryen'); + expect(result.topicId, '259125845563242502'); + expect(result.providerType, 'email'); + }); }); } diff --git a/test/src/models/target_test.dart b/test/src/models/target_test.dart index a49f3def..49f1e75e 100644 --- a/test/src/models/target_test.dart +++ b/test/src/models/target_test.dart @@ -18,14 +18,14 @@ void main() { final map = model.toMap(); final result = Target.fromMap(map); - expect(result.$id, '259125845563242502'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.name, 'Apple iPhone 12'); - expect(result.userId, '259125845563242502'); - expect(result.providerType, 'email'); - expect(result.identifier, 'token'); - expect(result.expired, true); - }); + expect(result.$id, '259125845563242502'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.name, 'Apple iPhone 12'); + expect(result.userId, '259125845563242502'); + expect(result.providerType, 'email'); + expect(result.identifier, 'token'); + expect(result.expired, true); + }); }); } diff --git a/test/src/models/team_list_test.dart b/test/src/models/team_list_test.dart index a19b667d..fe2f4a85 100644 --- a/test/src/models/team_list_test.dart +++ b/test/src/models/team_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = TeamList.fromMap(map); - expect(result.total, 5); - expect(result.teams, []); - }); + expect(result.total, 5); + expect(result.teams, []); + }); }); } diff --git a/test/src/models/team_test.dart b/test/src/models/team_test.dart index 43b2e45c..f652f2c1 100644 --- a/test/src/models/team_test.dart +++ b/test/src/models/team_test.dart @@ -16,11 +16,11 @@ void main() { final map = model.toMap(); final result = Team.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.name, 'VIP'); - expect(result.total, 7); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.name, 'VIP'); + expect(result.total, 7); + }); }); } diff --git a/test/src/models/token_test.dart b/test/src/models/token_test.dart index 7ee4b268..8f0957c9 100644 --- a/test/src/models/token_test.dart +++ b/test/src/models/token_test.dart @@ -16,12 +16,12 @@ void main() { final map = model.toMap(); final result = Token.fromMap(map); - expect(result.$id, 'bb8ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5ea5c168bb8'); - expect(result.secret, ''); - expect(result.expire, '2020-10-15T06:38:00.000+00:00'); - expect(result.phrase, 'Golden Fox'); - }); + expect(result.$id, 'bb8ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5ea5c168bb8'); + expect(result.secret, ''); + expect(result.expire, '2020-10-15T06:38:00.000+00:00'); + expect(result.phrase, 'Golden Fox'); + }); }); } diff --git a/test/src/models/transaction_list_test.dart b/test/src/models/transaction_list_test.dart index 68023e18..a524ef71 100644 --- a/test/src/models/transaction_list_test.dart +++ b/test/src/models/transaction_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = TransactionList.fromMap(map); - expect(result.total, 5); - expect(result.transactions, []); - }); + expect(result.total, 5); + expect(result.transactions, []); + }); }); } diff --git a/test/src/models/transaction_test.dart b/test/src/models/transaction_test.dart index 723ebac2..0169427f 100644 --- a/test/src/models/transaction_test.dart +++ b/test/src/models/transaction_test.dart @@ -16,12 +16,12 @@ void main() { final map = model.toMap(); final result = Transaction.fromMap(map); - expect(result.$id, '259125845563242502'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.status, 'pending'); - expect(result.operations, 5); - expect(result.expiresAt, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, '259125845563242502'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.status, 'pending'); + expect(result.operations, 5); + expect(result.expiresAt, '2020-10-15T06:38:00.000+00:00'); + }); }); } diff --git a/test/src/models/user_test.dart b/test/src/models/user_test.dart index c058ea26..77c7dd97 100644 --- a/test/src/models/user_test.dart +++ b/test/src/models/user_test.dart @@ -26,21 +26,21 @@ void main() { final map = model.toMap(); final result = User.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.name, 'John Doe'); - expect(result.registration, '2020-10-15T06:38:00.000+00:00'); - expect(result.status, true); - expect(result.labels, []); - expect(result.passwordUpdate, '2020-10-15T06:38:00.000+00:00'); - expect(result.email, 'john@appwrite.io'); - expect(result.phone, '+4930901820'); - expect(result.emailVerification, true); - expect(result.phoneVerification, true); - expect(result.mfa, true); - expect(result.targets, []); - expect(result.accessedAt, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.name, 'John Doe'); + expect(result.registration, '2020-10-15T06:38:00.000+00:00'); + expect(result.status, true); + expect(result.labels, []); + expect(result.passwordUpdate, '2020-10-15T06:38:00.000+00:00'); + expect(result.email, 'john@appwrite.io'); + expect(result.phone, '+4930901820'); + expect(result.emailVerification, true); + expect(result.phoneVerification, true); + expect(result.mfa, true); + expect(result.targets, []); + expect(result.accessedAt, '2020-10-15T06:38:00.000+00:00'); + }); }); } From a5c35a584985b21698f905f59e7640b3b4b1270c Mon Sep 17 00:00:00 2001 From: root Date: Thu, 25 Jun 2026 04:49:30 +0000 Subject: [PATCH 5/8] chore: update Flutter SDK to 25.2.0 --- CHANGELOG.md | 1 + lib/appwrite.dart | 2 +- lib/channel.dart | 20 +- lib/client_browser.dart | 2 +- lib/client_io.dart | 2 +- lib/operator.dart | 11 +- lib/query.dart | 91 +- lib/realtime_browser.dart | 2 +- lib/realtime_io.dart | 2 +- lib/role.dart | 2 +- lib/services/account.dart | 1560 +++++----- lib/services/avatars.dart | 351 +-- lib/services/databases.dart | 603 ++-- lib/services/functions.dart | 115 +- lib/services/graphql.dart | 50 +- lib/services/locale.dart | 142 +- lib/services/messaging.dart | 70 +- lib/services/presences.dart | 182 +- lib/services/storage.dart | 342 +-- lib/services/tables_db.dart | 547 ++-- lib/services/teams.dart | 421 ++- lib/src/client.dart | 4 +- lib/src/client_base.dart | 7 - lib/src/client_browser.dart | 15 +- lib/src/client_io.dart | 15 +- lib/src/client_mixin.dart | 9 +- lib/src/enums/authentication_factor.dart | 18 +- lib/src/enums/authenticator_type.dart | 12 +- lib/src/enums/browser.dart | 38 +- lib/src/enums/browser_permission.dart | 50 +- lib/src/enums/browser_theme.dart | 14 +- lib/src/enums/credit_card.dart | 44 +- lib/src/enums/execution_method.dart | 24 +- lib/src/enums/execution_status.dart | 20 +- lib/src/enums/execution_trigger.dart | 16 +- 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 | 96 +- lib/src/enums/timezone.dart | 848 +++--- lib/src/exception.dart | 2 +- lib/src/models/algo_argon2.dart | 62 +- lib/src/models/algo_bcrypt.dart | 32 +- lib/src/models/algo_md5.dart | 32 +- lib/src/models/algo_phpass.dart | 32 +- lib/src/models/algo_scrypt.dart | 86 +- lib/src/models/algo_scrypt_modified.dart | 62 +- lib/src/models/algo_sha.dart | 32 +- lib/src/models/continent.dart | 42 +- lib/src/models/continent_list.dart | 43 +- lib/src/models/country.dart | 42 +- lib/src/models/country_list.dart | 43 +- lib/src/models/currency.dart | 110 +- lib/src/models/currency_list.dart | 43 +- lib/src/models/document.dart | 102 +- lib/src/models/document_list.dart | 47 +- lib/src/models/execution.dart | 246 +- lib/src/models/execution_list.dart | 43 +- lib/src/models/file.dart | 194 +- lib/src/models/file_list.dart | 42 +- lib/src/models/headers.dart | 42 +- lib/src/models/identity.dart | 122 +- lib/src/models/identity_list.dart | 43 +- lib/src/models/jwt.dart | 32 +- lib/src/models/language.dart | 52 +- lib/src/models/language_list.dart | 43 +- lib/src/models/locale.dart | 110 +- lib/src/models/locale_code.dart | 42 +- lib/src/models/locale_code_list.dart | 43 +- lib/src/models/log.dart | 290 +- lib/src/models/log_list.dart | 42 +- lib/src/models/membership.dart | 206 +- lib/src/models/membership_list.dart | 43 +- lib/src/models/mfa_challenge.dart | 62 +- lib/src/models/mfa_factors.dart | 62 +- lib/src/models/mfa_recovery_codes.dart | 32 +- lib/src/models/mfa_type.dart | 42 +- lib/src/models/model.dart | 2 +- lib/src/models/phone.dart | 52 +- lib/src/models/phone_list.dart | 42 +- lib/src/models/preferences.dart | 32 +- lib/src/models/presence.dart | 112 +- lib/src/models/presence_list.dart | 43 +- lib/src/models/row.dart | 102 +- lib/src/models/row_list.dart | 46 +- lib/src/models/session.dart | 360 +-- lib/src/models/session_list.dart | 43 +- lib/src/models/subscriber.dart | 112 +- lib/src/models/target.dart | 112 +- lib/src/models/team.dart | 98 +- lib/src/models/team_list.dart | 42 +- lib/src/models/token.dart | 98 +- lib/src/models/transaction.dart | 98 +- lib/src/models/transaction_list.dart | 43 +- lib/src/models/user.dart | 332 +- lib/src/realtime.dart | 6 +- lib/src/realtime_io.dart | 4 +- lib/src/realtime_message.dart | 2 +- lib/src/realtime_mixin.dart | 31 +- lib/src/realtime_response.dart | 10 +- lib/src/realtime_stub.dart | 4 +- test/channel_test.dart | 42 +- test/query_test.dart | 1 + test/services/account_test.dart | 2691 +++++++++-------- test/services/avatars_test.dart | 204 +- test/services/databases_test.dart | 585 ++-- test/services/functions_test.dart | 188 +- test/services/graphql_test.dart | 71 +- test/services/locale_test.dart | 253 +- test/services/messaging_test.dart | 122 +- test/services/presences_test.dart | 202 +- test/services/storage_test.dart | 341 ++- test/services/tables_db_test.dart | 585 ++-- test/services/teams_test.dart | 555 ++-- test/src/models/algo_argon2_test.dart | 10 +- test/src/models/algo_bcrypt_test.dart | 4 +- test/src/models/algo_md5_test.dart | 4 +- test/src/models/algo_phpass_test.dart | 4 +- .../src/models/algo_scrypt_modified_test.dart | 14 +- test/src/models/algo_scrypt_test.dart | 12 +- test/src/models/algo_sha_test.dart | 4 +- test/src/models/continent_list_test.dart | 6 +- test/src/models/continent_test.dart | 6 +- test/src/models/country_list_test.dart | 6 +- test/src/models/country_test.dart | 6 +- test/src/models/currency_list_test.dart | 6 +- test/src/models/currency_test.dart | 16 +- test/src/models/document_list_test.dart | 6 +- test/src/models/document_test.dart | 16 +- test/src/models/execution_list_test.dart | 6 +- test/src/models/execution_test.dart | 36 +- test/src/models/file_list_test.dart | 6 +- test/src/models/file_test.dart | 30 +- test/src/models/headers_test.dart | 6 +- test/src/models/identity_list_test.dart | 6 +- test/src/models/identity_test.dart | 22 +- test/src/models/jwt_test.dart | 8 +- test/src/models/language_list_test.dart | 6 +- test/src/models/language_test.dart | 8 +- test/src/models/locale_code_list_test.dart | 6 +- test/src/models/locale_code_test.dart | 6 +- test/src/models/locale_test.dart | 16 +- test/src/models/log_list_test.dart | 6 +- test/src/models/log_test.dart | 46 +- test/src/models/membership_list_test.dart | 6 +- test/src/models/membership_test.dart | 32 +- test/src/models/mfa_challenge_test.dart | 10 +- test/src/models/mfa_factors_test.dart | 10 +- test/src/models/mfa_recovery_codes_test.dart | 4 +- test/src/models/mfa_type_test.dart | 10 +- test/src/models/phone_list_test.dart | 6 +- test/src/models/phone_test.dart | 8 +- test/src/models/preferences_test.dart | 1 + test/src/models/presence_list_test.dart | 6 +- test/src/models/presence_test.dart | 14 +- test/src/models/row_list_test.dart | 6 +- test/src/models/row_test.dart | 16 +- test/src/models/session_list_test.dart | 6 +- test/src/models/session_test.dart | 60 +- test/src/models/subscriber_test.dart | 36 +- test/src/models/target_test.dart | 18 +- test/src/models/team_list_test.dart | 6 +- test/src/models/team_test.dart | 12 +- test/src/models/token_test.dart | 14 +- test/src/models/transaction_list_test.dart | 6 +- test/src/models/transaction_test.dart | 14 +- test/src/models/user_test.dart | 32 +- 167 files changed, 8662 insertions(+), 8516 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d611a0a1..77556eae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## 25.2.0 +* Added: Realtime connections now authenticate with the configured JWT. * Added: Forwarded `impersonateUserId` on `avatars` and `storage` file requests. * Deprecated: `databases` transaction and document methods in favor of `TablesDB`. diff --git a/lib/appwrite.dart b/lib/appwrite.dart index ae51be5e..6615de8a 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.9.x. +/// This SDK is compatible with Appwrite server version 1.9.x. /// For older versions, please check /// [previous releases](https://github.com/appwrite/sdk-for-flutter/releases). library appwrite; diff --git a/lib/channel.dart b/lib/channel.dart index afc68efa..d511f5a4 100644 --- a/lib/channel.dart +++ b/lib/channel.dart @@ -2,33 +2,19 @@ part of appwrite; // Marker classes for type safety class _Root {} - class _Database {} - class _Collection {} - class _Document {} - class _TablesDB {} - class _Table {} - class _Row {} - class _Bucket {} - class _File {} - class _Func {} - class _Execution {} - class _Team {} - class _Membership {} - class _Presence {} - class _Resolved {} // Helper function for normalizing ID @@ -113,15 +99,15 @@ extension DatabaseChannel on Channel<_Database> { /// Only available on Channel<_Collection> extension CollectionChannel on Channel<_Collection> { - Channel<_Document> document([String? id]) => - _next<_Document>('documents', id); + Channel<_Document> document([String? id]) => _next<_Document>('documents', id); } // --- TABLESDB ROUTE --- /// Only available on Channel<_TablesDB> extension TablesDBChannel on Channel<_TablesDB> { - Channel<_Table> table(String id) => _next<_Table>('tables', id); + Channel<_Table> table(String id) => + _next<_Table>('tables', id); } /// Only available on Channel<_Table> 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/operator.dart b/lib/operator.dart index 337dda30..9dd7f4c7 100644 --- a/lib/operator.dart +++ b/lib/operator.dart @@ -31,7 +31,7 @@ class Operator { result['method'] = method; - if (values != null) { + if(values != null) { result['values'] = values is List ? values : [values]; } @@ -147,7 +147,8 @@ class Operator { Operator._('arrayRemove', [value]).toString(); /// Remove duplicate values from an array attribute. - static String arrayUnique() => Operator._('arrayUnique', []).toString(); + static String arrayUnique() => + Operator._('arrayUnique', []).toString(); /// Keep only values that exist in both the current array and the provided array. static String arrayIntersect(List values) => @@ -172,7 +173,8 @@ class Operator { Operator._('stringReplace', [search, replace]).toString(); /// Toggle a boolean attribute. - static String toggle() => Operator._('toggle', []).toString(); + static String toggle() => + Operator._('toggle', []).toString(); /// Add days to a date attribute. static String dateAddDays(int days) => @@ -183,5 +185,6 @@ class Operator { Operator._('dateSubDays', [days]).toString(); /// Set a date attribute to the current date and time. - static String dateSetNow() => Operator._('dateSetNow', []).toString(); + static String dateSetNow() => + Operator._('dateSetNow', []).toString(); } diff --git a/lib/query.dart b/lib/query.dart index 3693dce6..95365bf7 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. @@ -140,46 +140,50 @@ class Query { Query._('notEndsWith', attribute, value).toString(); /// Filter resources where document was created before [value]. - static String createdBefore(String value) => lessThan('\$createdAt', value); + static String createdBefore(String value) => + lessThan('\$createdAt', value); /// Filter resources where document was created after [value]. - static String createdAfter(String value) => greaterThan('\$createdAt', value); + static String createdAfter(String value) => + greaterThan('\$createdAt', value); /// Filter resources where document was created between [start] and [end] (inclusive). static String createdBetween(String start, String end) => between('\$createdAt', start, end); /// Filter resources where document was updated before [value]. - static String updatedBefore(String value) => lessThan('\$updatedAt', value); + static String updatedBefore(String value) => + lessThan('\$updatedAt', value); /// Filter resources where document was updated after [value]. - static String updatedAfter(String value) => greaterThan('\$updatedAt', value); + static String updatedAfter(String value) => + greaterThan('\$updatedAt', value); /// Filter resources where document was updated between [start] and [end] (inclusive). static String updatedBetween(String start, String end) => between('\$updatedAt', start, end); static String or(List queries) => Query._( - 'or', - null, - queries.map((query) => jsonDecode(query)).toList(), - ).toString(); + 'or', + null, + queries.map((query) => jsonDecode(query)).toList(), + ).toString(); static String and(List queries) => Query._( - 'and', - null, - queries.map((query) => jsonDecode(query)).toList(), - ).toString(); + 'and', + null, + queries.map((query) => jsonDecode(query)).toList(), + ).toString(); /// Filter array elements where at least one element matches all the specified queries. /// /// [attribute] The attribute containing the array to filter on. /// [queries] The list of query strings to match against array elements. static String elemMatch(String attribute, List queries) => Query._( - 'elemMatch', - attribute, - queries.map((query) => jsonDecode(query)).toList(), - ).toString(); + 'elemMatch', + attribute, + queries.map((query) => jsonDecode(query)).toList(), + ).toString(); /// Specify which attributes should be returned by the API call. static String select(List attributes) => @@ -194,17 +198,18 @@ class Query { Query._('orderDesc', attribute).toString(); /// Sort results randomly. - static String orderRandom() => Query._('orderRandom').toString(); + static String orderRandom() => + Query._('orderRandom').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) => @@ -214,43 +219,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, 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) => @@ -283,4 +272,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 48b60041..9c021e93 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 { final String apiPath = '/account'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -29,30 +30,29 @@ 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 { final String apiPath = '/account'; - final Map apiParams = { - 'userId': userId, - 'email': email, - 'password': password, - if (name != null) 'name': name, - }; + final Map apiParams = { + 'userId': userId, + + 'email': email, + + 'password': password, + + if (name != null) 'name': name, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 @@ -62,65 +62,66 @@ 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 { final String apiPath = '/account/email'; - final Map apiParams = { - 'email': email, - 'password': password, - }; + final Map apiParams = { + 'email': email, + + 'password': password, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, bool? total}) async { + Future listIdentities({List? queries, bool? total}) async { final String apiPath = '/account/identities'; - final Map apiParams = { - if (queries != null) 'queries': queries, - if (total != null) 'total': total, - }; + final Map apiParams = { + if (queries != null) 'queries': queries, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + if (total != null) 'total': total, - final res = await client.call(HttpMethod.get, - path: apiPath, params: apiParams, headers: apiHeaders); + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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 @@ -131,20 +132,20 @@ class Account extends Service { Future createJWT({int? duration}) async { final String apiPath = '/account/jwts'; - final Map apiParams = { - if (duration != null) 'duration': duration, - }; + final Map apiParams = { + if (duration != null) 'duration': duration, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + }; - final res = await client.call(HttpMethod.post, - path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 @@ -152,224 +153,212 @@ class Account extends Service { Future listLogs({List? queries, bool? total}) async { final String apiPath = '/account/logs'; - final Map apiParams = { - if (queries != null) 'queries': queries, - if (total != null) 'total': total, - }; + final Map apiParams = { + if (queries != null) 'queries': queries, + + if (total != null) 'total': total, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 { final String apiPath = '/account/mfa'; - final Map apiParams = { - 'mfa': mfa, - }; + final Map apiParams = { + 'mfa': mfa, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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); + @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 apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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.MfaType.fromMap(res.data); - 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); + Future createMFAAuthenticator({required enums.AuthenticatorType type}) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + + final Map apiParams = { + }; - final Map apiParams = {}; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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.MfaType.fromMap(res.data); - 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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); + 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 apiParams = { - 'otp': otp, - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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.User.fromMap(res.data); - 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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 { final String apiPath = '/account/mfa/challenges'; - final Map apiParams = { - 'factor': factor.value, - }; + final Map apiParams = { + 'factor': factor.value, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 { final String apiPath = '/account/mfa/challenges'; - final Map apiParams = { - 'factor': factor.value, - }; + final Map apiParams = { + 'factor': factor.value, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + }; - final res = await client.call(HttpMethod.post, - path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 @@ -377,27 +366,26 @@ 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 { final String apiPath = '/account/mfa/challenges'; - final Map apiParams = { - 'challengeId': challengeId, - 'otp': otp, - }; + final Map apiParams = { + 'challengeId': challengeId, + + 'otp': otp, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 @@ -405,83 +393,84 @@ 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 { final String apiPath = '/account/mfa/challenges'; - final Map apiParams = { - 'challengeId': challengeId, - 'otp': otp, - }; + final Map apiParams = { + 'challengeId': challengeId, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + 'otp': otp, - final res = await client.call(HttpMethod.put, - path: apiPath, params: apiParams, headers: apiHeaders); + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 { final String apiPath = '/account/mfa/factors'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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 { final String apiPath = '/account/mfa/factors'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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 @@ -491,17 +480,18 @@ class Account extends Service { Future getMFARecoveryCodes() async { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -509,23 +499,22 @@ 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 { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 @@ -536,41 +525,40 @@ class Account extends Service { Future createMFARecoveryCodes() async { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 @@ -580,62 +568,62 @@ class Account extends Service { Future updateMFARecoveryCodes() async { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 { final String apiPath = '/account/name'; - final Map apiParams = { - 'name': name, - }; + final Map apiParams = { + 'name': name, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 { final String apiPath = '/account/password'; - final Map apiParams = { - 'password': password, - if (oldPassword != null) 'oldPassword': oldPassword, - }; + final Map apiParams = { + 'password': password, + + if (oldPassword != null) 'oldPassword': oldPassword, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 @@ -643,42 +631,43 @@ 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 { final String apiPath = '/account/phone'; - final Map apiParams = { - 'phone': phone, - 'password': password, - }; + final Map apiParams = { + 'phone': phone, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + 'password': password, - final res = await client.call(HttpMethod.patch, - path: apiPath, params: apiParams, headers: apiHeaders); + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 { final String apiPath = '/account/prefs'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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 @@ -687,20 +676,20 @@ class Account extends Service { Future updatePrefs({required Map prefs}) async { final String apiPath = '/account/prefs'; - final Map apiParams = { - 'prefs': prefs, - }; + final Map apiParams = { + 'prefs': prefs, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + }; - final res = await client.call(HttpMethod.patch, - path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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. @@ -711,25 +700,25 @@ 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 { final String apiPath = '/account/recovery'; - final Map apiParams = { - 'email': email, - 'url': url, - }; + final Map apiParams = { + 'email': email, + + 'url': url, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 @@ -737,33 +726,32 @@ 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 { final 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 @@ -771,17 +759,18 @@ class Account extends Service { Future listSessions() async { final String apiPath = '/account/sessions'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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 @@ -789,17 +778,18 @@ class Account extends Service { Future deleteSessions() async { final String apiPath = '/account/sessions'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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 @@ -812,216 +802,213 @@ class Account extends Service { Future createAnonymousSession() async { final String apiPath = '/account/sessions/anonymous'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 { final String apiPath = '/account/sessions/email'; - final Map apiParams = { - 'email': email, - 'password': password, - }; + final Map apiParams = { + 'email': email, + + 'password': password, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + }; - final res = await client.call(HttpMethod.post, - path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 { final String apiPath = '/account/sessions/magic-url'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; + final Map apiParams = { + 'userId': userId, + + 'secret': secret, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 = { - if (success != null) 'success': success, - if (failure != null) 'failure': failure, - if (scopes != null) 'scopes': scopes, - 'project': client.config['project'], - }; - - final List query = []; - - params.forEach((key, value) { - if (value is List) { - for (var item in value) { - query.add( + /// + 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 = { + + if (success != null) 'success': success, + + if (failure != null) 'failure': failure, + + if (scopes != null) '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); + } + } 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 { final String apiPath = '/account/sessions/phone'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; + final Map apiParams = { + 'userId': userId, + + 'secret': secret, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + }; - final res = await client.call(HttpMethod.put, - path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 { final String apiPath = '/account/sessions/token'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; + final Map apiParams = { + 'userId': userId, + + 'secret': secret, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 apiParams = {}; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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, @@ -1030,20 +1017,20 @@ 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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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 @@ -1052,18 +1039,18 @@ class Account extends Service { Future updateStatus() async { final String apiPath = '/account/status'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 @@ -1071,28 +1058,27 @@ 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 { final String apiPath = '/account/targets/push'; - final Map apiParams = { - 'targetId': targetId, - 'identifier': identifier, - if (providerId != null) 'providerId': providerId, - }; + final Map apiParams = { + 'targetId': targetId, + + 'identifier': identifier, + + if (providerId != null) 'providerId': providerId, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 @@ -1100,45 +1086,43 @@ 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); + 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 apiParams = { - 'identifier': identifier, - }; + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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.Target.fromMap(res.data); - 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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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 @@ -1150,31 +1134,32 @@ 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 { final String apiPath = '/account/tokens/email'; - final Map apiParams = { - 'userId': userId, - 'email': email, - if (phrase != null) 'phrase': phrase, - }; + final Map apiParams = { + 'userId': userId, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + 'email': email, - final res = await client.call(HttpMethod.post, - path: apiPath, params: apiParams, headers: apiHeaders); + if (phrase != null) 'phrase': phrase, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 @@ -1186,88 +1171,87 @@ 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 { final String apiPath = '/account/tokens/magic-url'; - final Map apiParams = { - 'userId': userId, - 'email': email, - if (url != null) 'url': url, - if (phrase != null) 'phrase': phrase, - }; + final Map apiParams = { + 'userId': userId, + + 'email': email, + + if (url != null) 'url': url, + + if (phrase != null) 'phrase': phrase, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 = { - if (success != null) 'success': success, - if (failure != null) 'failure': failure, - if (scopes != null) 'scopes': scopes, - 'project': client.config['project'], - }; - - final List query = []; - - params.forEach((key, value) { - if (value is List) { - for (var item in value) { - query.add( + 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 = { + + if (success != null) 'success': success, + + if (failure != null) 'failure': failure, + + if (scopes != null) '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); + } + } 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 @@ -1276,29 +1260,29 @@ 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 { final String apiPath = '/account/tokens/phone'; - final Map apiParams = { - 'userId': userId, - 'phone': phone, - }; + final Map apiParams = { + 'userId': userId, + + 'phone': phone, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + }; - final res = await client.call(HttpMethod.post, - path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 @@ -1310,29 +1294,29 @@ 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 createEmailVerification({required String url}) async { final String apiPath = '/account/verifications/email'; - final Map apiParams = { - 'url': url, - }; + final Map apiParams = { + 'url': url, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 @@ -1344,83 +1328,81 @@ 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. - /// - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.createEmailVerification` instead.') + /// + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.createEmailVerification` instead.') Future createVerification({required String url}) async { final String apiPath = '/account/verifications/email'; - final Map apiParams = { - 'url': url, - }; + final Map apiParams = { + 'url': url, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + }; - final res = await client.call(HttpMethod.post, - path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 updateEmailVerification( - {required String userId, required String secret}) async { + Future updateEmailVerification({required String userId, required String secret}) async { final String apiPath = '/account/verifications/email'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; + final Map apiParams = { + 'userId': userId, + + 'secret': secret, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 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. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.updateEmailVerification` instead.') - Future updateVerification( - {required String userId, required String secret}) async { + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.updateEmailVerification` instead.') + Future updateVerification({required String userId, required String secret}) async { final String apiPath = '/account/verifications/email'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; + final Map apiParams = { + 'userId': userId, + + 'secret': secret, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 @@ -1434,42 +1416,42 @@ class Account extends Service { Future createPhoneVerification() async { final String apiPath = '/account/verifications/phone'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 { final String apiPath = '/account/verifications/phone'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; + final Map apiParams = { + 'userId': userId, + + 'secret': secret, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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); } } diff --git a/lib/services/avatars.dart b/lib/services/avatars.dart index cdd93e6e..4dca3b16 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,134 +11,139 @@ 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 = { - if (width != null) 'width': width, - if (height != null) 'height': height, - if (quality != null) 'quality': quality, - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + + if (width != null) 'width': width, + + if (height != null) 'height': height, + + if (quality != null) 'quality': quality, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 = { - if (width != null) 'width': width, - if (height != null) 'height': height, - if (quality != null) 'quality': quality, - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + + if (width != null) 'width': width, + + if (height != null) 'height': height, + + if (quality != null) 'quality': quality, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 { final String apiPath = '/avatars/favicon'; - final Map params = { - 'url': url, - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; + 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'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 = { - if (width != null) 'width': width, - if (height != null) 'height': height, - if (quality != null) 'quality': quality, - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + + if (width != null) 'width': width, + + if (height != null) 'height': height, + + if (quality != null) 'quality': quality, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 { final String apiPath = '/avatars/image'; - final Map params = { - 'url': url, - if (width != null) 'width': width, - if (height != null) 'height': height, - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - final res = await client.call(HttpMethod.get, - path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + + 'url': url, + + if (width != null) 'width': width, + + if (height != null) 'height': height, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 @@ -146,117 +151,125 @@ 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 { final String apiPath = '/avatars/initials'; - final Map params = { - if (name != null) 'name': name, - if (width != null) 'width': width, - if (height != null) 'height': height, - if (background != null) 'background': background, - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - final res = await client.call(HttpMethod.get, - path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + + if (name != null) 'name': name, + + if (width != null) 'width': width, + + if (height != null) 'height': height, + + if (background != null) 'background': background, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 { final String apiPath = '/avatars/qr'; - final Map params = { - 'text': text, - if (size != null) 'size': size, - if (margin != null) 'margin': margin, - if (download != null) 'download': download, - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - final res = await client.call(HttpMethod.get, - path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + + 'text': text, + + if (size != null) 'size': size, + + if (margin != null) 'margin': margin, + + if (download != null) 'download': download, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// Use this endpoint to capture a screenshot of any website URL. This endpoint /// uses a headless browser to render the webpage and capture it as an image. - /// + /// /// You can configure the browser viewport size, theme, user agent, /// geolocation, permissions, and more. Capture either just the viewport or the /// full page scroll. - /// + /// /// When width and height are specified, the image is resized accordingly. If /// both dimensions are 0, the API provides an image at original size. If /// dimensions are not specified, the default viewport size is 1280x720px. - Future getScreenshot( - {required String url, - Map? headers, - int? viewportWidth, - int? viewportHeight, - double? scale, - enums.BrowserTheme? theme, - String? userAgent, - bool? fullpage, - String? locale, - enums.Timezone? timezone, - double? latitude, - double? longitude, - double? accuracy, - bool? touch, - List? permissions, - int? sleep, - int? width, - int? height, - int? quality, - enums.ImageFormat? output}) async { + Future getScreenshot({required String url, Map? headers, int? viewportWidth, int? viewportHeight, double? scale, enums.BrowserTheme? theme, String? userAgent, bool? fullpage, String? locale, enums.Timezone? timezone, double? latitude, double? longitude, double? accuracy, bool? touch, List? permissions, int? sleep, int? width, int? height, int? quality, enums.ImageFormat? output}) async { final String apiPath = '/avatars/screenshots'; - final Map params = { - 'url': url, - if (headers != null) 'headers': headers, - if (viewportWidth != null) 'viewportWidth': viewportWidth, - if (viewportHeight != null) 'viewportHeight': viewportHeight, - if (scale != null) 'scale': scale, - if (theme != null) 'theme': theme.value, - if (userAgent != null) 'userAgent': userAgent, - if (fullpage != null) 'fullpage': fullpage, - if (locale != null) 'locale': locale, - if (timezone != null) 'timezone': timezone.value, - if (latitude != null) 'latitude': latitude, - if (longitude != null) 'longitude': longitude, - if (accuracy != null) 'accuracy': accuracy, - if (touch != null) 'touch': touch, - if (permissions != null) - 'permissions': permissions.map((e) => e.value).toList(), - if (sleep != null) 'sleep': sleep, - if (width != null) 'width': width, - if (height != null) 'height': height, - if (quality != null) 'quality': quality, - if (output != null) 'output': output.value, - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - final res = await client.call(HttpMethod.get, - path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + + 'url': url, + + if (headers != null) 'headers': headers, + + if (viewportWidth != null) 'viewportWidth': viewportWidth, + + if (viewportHeight != null) 'viewportHeight': viewportHeight, + + if (scale != null) 'scale': scale, + + if (theme != null) 'theme': theme.value, + + if (userAgent != null) 'userAgent': userAgent, + + if (fullpage != null) 'fullpage': fullpage, + + if (locale != null) 'locale': locale, + + if (timezone != null) 'timezone': timezone.value, + + if (latitude != null) 'latitude': latitude, + + if (longitude != null) 'longitude': longitude, + + if (accuracy != null) 'accuracy': accuracy, + + if (touch != null) 'touch': touch, + + if (permissions != null) 'permissions': permissions.map((e) => e.value).toList(), + + if (sleep != null) 'sleep': sleep, + + if (width != null) 'width': width, + + if (height != null) 'height': height, + + if (quality != null) 'quality': quality, + + if (output != null) 'output': output.value, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } } diff --git a/lib/services/databases.dart b/lib/services/databases.dart index 0ff3fb72..0bfd935a 100644 --- a/lib/services/databases.dart +++ b/lib/services/databases.dart @@ -1,418 +1,339 @@ 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); /// List transactions across all databases. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.listTransactions` instead.') - Future listTransactions( - {List? queries}) async { + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.listTransactions` instead.') + Future listTransactions({List? queries}) async { final String apiPath = '/databases/transactions'; - final Map apiParams = { - if (queries != null) 'queries': queries, - }; + final Map apiParams = { + if (queries != null) 'queries': queries, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + }; - final res = await client.call(HttpMethod.get, - path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.TransactionList.fromMap(res.data); - return models.TransactionList.fromMap(res.data); } /// Create a new transaction. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.createTransaction` instead.') + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.createTransaction` instead.') Future createTransaction({int? ttl}) async { final String apiPath = '/databases/transactions'; - final Map apiParams = { - if (ttl != null) 'ttl': ttl, - }; + final Map apiParams = { + if (ttl != null) 'ttl': ttl, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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.Transaction.fromMap(res.data); - return models.Transaction.fromMap(res.data); } /// Get a transaction by its unique ID. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.getTransaction` instead.') - Future getTransaction( - {required String transactionId}) async { - final String apiPath = '/databases/transactions/{transactionId}' - .replaceAll('{transactionId}', transactionId); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.getTransaction` instead.') + Future getTransaction({required String transactionId}) async { + final String apiPath = '/databases/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + }; - final Map apiParams = {}; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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.Transaction.fromMap(res.data); - return models.Transaction.fromMap(res.data); } /// Update a transaction, to either commit or roll back its operations. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.updateTransaction` instead.') - Future updateTransaction( - {required String transactionId, bool? commit, bool? rollback}) async { - final String apiPath = '/databases/transactions/{transactionId}' - .replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - if (commit != null) 'commit': commit, - if (rollback != null) 'rollback': rollback, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, - path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Transaction.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.updateTransaction` instead.') + Future updateTransaction({required String transactionId, bool? commit, bool? rollback}) async { + final String apiPath = '/databases/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + if (commit != null) 'commit': commit, + + if (rollback != null) 'rollback': rollback, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Transaction.fromMap(res.data); + } /// Delete a transaction by its unique ID. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.deleteTransaction` instead.') + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.deleteTransaction` instead.') Future deleteTransaction({required String transactionId}) async { - final String apiPath = '/databases/transactions/{transactionId}' - .replaceAll('{transactionId}', transactionId); + final String apiPath = '/databases/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + }; - final Map apiParams = {}; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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; } /// Create multiple operations in a single transaction. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.createOperations` instead.') - Future createOperations( - {required String transactionId, List? operations}) async { - final String apiPath = '/databases/transactions/{transactionId}/operations' - .replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - if (operations != null) 'operations': operations, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.post, - path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Transaction.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.createOperations` instead.') + Future createOperations({required String transactionId, List? operations}) async { + final String apiPath = '/databases/transactions/{transactionId}/operations'.replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + if (operations != null) 'operations': operations, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Transaction.fromMap(res.data); + } /// 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, - String? transactionId, - bool? total, - int? ttl}) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - if (transactionId != null) 'transactionId': transactionId, - if (total != null) 'total': total, - if (ttl != null) 'ttl': ttl, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, String? transactionId, bool? total, int? ttl}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + + if (transactionId != null) 'transactionId': transactionId, + + if (total != null) 'total': total, + + if (ttl != null) 'ttl': ttl, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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, - String? transactionId}) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId); - - final Map apiParams = { - 'documentId': documentId, - 'data': data, - 'permissions': permissions, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, String? transactionId}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); + + final Map apiParams = { + 'documentId': documentId, + + 'data': data, + + 'permissions': permissions, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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, - String? transactionId}) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - if (transactionId != null) 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, String? transactionId}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + + if (transactionId != null) 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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, - Map? data, - List? permissions, - String? transactionId}) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); - - final Map apiParams = { - if (data != null) 'data': data, - 'permissions': permissions, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, Map? data, List? permissions, String? transactionId}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + + final Map apiParams = { + if (data != null) 'data': data, + + 'permissions': permissions, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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, - String? transactionId}) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); - - final Map apiParams = { - if (data != null) 'data': data, - 'permissions': permissions, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, String? transactionId}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + + final Map apiParams = { + if (data != null) 'data': data, + + 'permissions': permissions, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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, - String? transactionId}) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); - - final Map apiParams = { - if (transactionId != null) 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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, String? transactionId}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + + final Map apiParams = { + if (transactionId != null) 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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, - String? transactionId}) 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 = { - if (value != null) 'value': value, - 'min': min, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, String? transactionId}) 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 = { + if (value != null) 'value': value, + + 'min': min, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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, - String? transactionId}) 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 = { - if (value != null) 'value': value, - 'max': max, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, String? transactionId}) 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 = { + if (value != null) 'value': value, + + 'max': max, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); + } } diff --git a/lib/services/functions.dart b/lib/services/functions.dart index ed97921b..0640f80f 100644 --- a/lib/services/functions.dart +++ b/lib/services/functions.dart @@ -1,87 +1,82 @@ 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, bool? total}) async { - final String apiPath = '/functions/{functionId}/executions' - .replaceAll('{functionId}', functionId); + Future listExecutions({required String functionId, List? queries, bool? total}) async { + final String apiPath = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); - final Map apiParams = { - if (queries != null) 'queries': queries, - if (total != null) 'total': total, - }; + final Map apiParams = { + if (queries != null) 'queries': queries, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + if (total != null) 'total': total, - final res = await client.call(HttpMethod.get, - path: apiPath, params: apiParams, headers: apiHeaders); + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.ExecutionList.fromMap(res.data); - 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 = { - if (body != null) 'body': body, - if (xasync != null) 'async': xasync, - if (path != null) 'path': path, - if (method != null) 'method': method.value, - if (headers != null) 'headers': headers, - 'scheduledAt': scheduledAt, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 = { + if (body != null) 'body': body, + + if (xasync != null) 'async': xasync, + + if (path != null) 'path': path, + + if (method != null) 'method': method.value, + + if (headers != null) 'headers': headers, + + 'scheduledAt': scheduledAt, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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); + 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 apiParams = {}; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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.Execution.fromMap(res.data); - return models.Execution.fromMap(res.data); } } diff --git a/lib/services/graphql.dart b/lib/services/graphql.dart index c86f3719..978331fa 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,39 @@ class Graphql extends Service { Future query({required Map query}) async { final String apiPath = '/graphql'; - final Map apiParams = { - 'query': query, - }; + final Map apiParams = { + 'query': query, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'x-sdk-graphql': 'true', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + }; - final res = await client.call(HttpMethod.post, - path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'x-sdk-graphql': 'true', 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 { final String apiPath = '/graphql/mutation'; - final Map apiParams = { - 'query': query, - }; + final Map apiParams = { + 'query': query, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'x-sdk-graphql': 'true', 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'x-sdk-graphql': 'true', - 'content-type': 'application/json', - 'accept': '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; } } diff --git a/lib/services/locale.dart b/lib/services/locale.dart index 87ea162e..c45a1269 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 { final String apiPath = '/locale'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -33,17 +34,18 @@ class Locale extends Service { Future listCodes() async { final String apiPath = '/locale/codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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 @@ -51,17 +53,18 @@ class Locale extends Service { Future listContinents() async { final String apiPath = '/locale/continents'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -69,17 +72,18 @@ class Locale extends Service { Future listCountries() async { final String apiPath = '/locale/countries'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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 @@ -87,17 +91,18 @@ class Locale extends Service { Future listCountriesEU() async { final String apiPath = '/locale/countries/eu'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -105,17 +110,18 @@ class Locale extends Service { Future listCountriesPhones() async { final String apiPath = '/locale/countries/phones'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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 @@ -124,17 +130,18 @@ class Locale extends Service { Future listCurrencies() async { final String apiPath = '/locale/currencies'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -142,16 +149,17 @@ class Locale extends Service { Future listLanguages() async { final String apiPath = '/locale/languages'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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); } } diff --git a/lib/services/messaging.dart b/lib/services/messaging.dart index 61ecefee..3dffe41b 100644 --- a/lib/services/messaging.dart +++ b/lib/services/messaging.dart @@ -1,54 +1,48 @@ 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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); + 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 apiParams = {}; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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; } } diff --git a/lib/services/presences.dart b/lib/services/presences.dart index 1c9b651b..088700cb 100644 --- a/lib/services/presences.dart +++ b/lib/services/presences.dart @@ -5,127 +5,123 @@ class Presences extends Service { Presences(super.client); /// List presence logs. Expired entries are filtered out automatically. - /// - Future list( - {List? queries, bool? total, int? ttl}) async { + /// + Future list({List? queries, bool? total, int? ttl}) async { final String apiPath = '/presences'; - final Map apiParams = { - if (queries != null) 'queries': queries, - if (total != null) 'total': total, - if (ttl != null) 'ttl': ttl, - }; + final Map apiParams = { + if (queries != null) 'queries': queries, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + if (total != null) 'total': total, - final res = await client.call(HttpMethod.get, - path: apiPath, params: apiParams, headers: apiHeaders); + if (ttl != null) 'ttl': ttl, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.PresenceList.fromMap(res.data); - return models.PresenceList.fromMap(res.data); } /// Get a presence log by its unique ID. Entries whose `expiresAt` is in the /// past are treated as not found. - /// + /// Future get({required String presenceId}) async { - final String apiPath = - '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); + final String apiPath = '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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.Presence.fromMap(res.data); - return models.Presence.fromMap(res.data); } /// Create or update a presence log by its user ID. - /// - Future upsert( - {required String presenceId, - required String status, - List? permissions, - String? expiresAt, - Map? metadata}) async { - final String apiPath = - '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); - - final Map apiParams = { - 'status': status, - if (permissions != null) 'permissions': permissions, - if (expiresAt != null) 'expiresAt': expiresAt, - if (metadata != null) 'metadata': metadata, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.put, - path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Presence.fromMap(res.data); + /// + Future upsert({required String presenceId, required String status, List? permissions, String? expiresAt, Map? metadata}) async { + final String apiPath = '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); + + final Map apiParams = { + 'status': status, + + if (permissions != null) 'permissions': permissions, + + if (expiresAt != null) 'expiresAt': expiresAt, + + if (metadata != null) 'metadata': metadata, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Presence.fromMap(res.data); + } /// Update a presence log by its unique ID. Using the patch method you can pass /// only specific fields that will get updated. - /// - Future update( - {required String presenceId, - String? status, - String? expiresAt, - Map? metadata, - List? permissions, - bool? purge}) async { - final String apiPath = - '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); - - final Map apiParams = { - if (status != null) 'status': status, - if (expiresAt != null) 'expiresAt': expiresAt, - if (metadata != null) 'metadata': metadata, - if (permissions != null) 'permissions': permissions, - if (purge != null) 'purge': purge, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, - path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Presence.fromMap(res.data); + /// + Future update({required String presenceId, String? status, String? expiresAt, Map? metadata, List? permissions, bool? purge}) async { + final String apiPath = '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); + + final Map apiParams = { + if (status != null) 'status': status, + + if (expiresAt != null) 'expiresAt': expiresAt, + + if (metadata != null) 'metadata': metadata, + + if (permissions != null) 'permissions': permissions, + + if (purge != null) 'purge': purge, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Presence.fromMap(res.data); + } /// Delete a presence log by its unique ID. - /// + /// Future delete({required String presenceId}) async { - final String apiPath = - '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); + final String apiPath = '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); + + final Map apiParams = { + }; - final Map apiParams = {}; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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; } } diff --git a/lib/services/storage.dart b/lib/services/storage.dart index cdb626de..c9499a99 100644 --- a/lib/services/storage.dart +++ b/lib/services/storage.dart @@ -1,178 +1,166 @@ 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, - bool? total}) async { - final String apiPath = - '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - if (search != null) 'search': search, - if (total != null) 'total': total, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, bool? total}) async { + final String apiPath = '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + + if (search != null) 'search': search, + + if (total != null) 'total': total, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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, - if (permissions != null) 'permissions': permissions, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'multipart/form-data', - 'accept': 'application/json', - }; - - 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, + + if (permissions != null) 'permissions': permissions, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'multipart/form-data', 'accept': 'application/json', + }; + + 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); + 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 apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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.File.fromMap(res.data); - 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 = { - if (name != null) 'name': name, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 = { + if (name != null) 'name': name, + + 'permissions': permissions, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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 = { - if (token != null) 'token': token, - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + + if (token != null) 'token': token, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 @@ -180,64 +168,60 @@ 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 = { - if (width != null) 'width': width, - if (height != null) 'height': height, - if (gravity != null) 'gravity': gravity.value, - if (quality != null) 'quality': quality, - if (borderWidth != null) 'borderWidth': borderWidth, - if (borderColor != null) 'borderColor': borderColor, - if (borderRadius != null) 'borderRadius': borderRadius, - if (opacity != null) 'opacity': opacity, - if (rotation != null) 'rotation': rotation, - if (background != null) 'background': background, - if (output != null) 'output': output.value, - if (token != null) 'token': token, - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + + if (width != null) 'width': width, + + if (height != null) 'height': height, + + if (gravity != null) 'gravity': gravity.value, + + if (quality != null) 'quality': quality, + + if (borderWidth != null) 'borderWidth': borderWidth, + + if (borderColor != null) 'borderColor': borderColor, + + if (borderRadius != null) 'borderRadius': borderRadius, + + if (opacity != null) 'opacity': opacity, + + if (rotation != null) 'rotation': rotation, + + if (background != null) 'background': background, + + if (output != null) 'output': output.value, + + if (token != null) 'token': token, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 = { - if (token != null) 'token': token, - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + + if (token != null) 'token': token, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } } diff --git a/lib/services/tables_db.dart b/lib/services/tables_db.dart index 8b6284b3..42572021 100644 --- a/lib/services/tables_db.dart +++ b/lib/services/tables_db.dart @@ -5,382 +5,319 @@ class TablesDB extends Service { TablesDB(super.client); /// List transactions across all databases. - Future listTransactions( - {List? queries}) async { + Future listTransactions({List? queries}) async { final String apiPath = '/tablesdb/transactions'; - final Map apiParams = { - if (queries != null) 'queries': queries, - }; + final Map apiParams = { + if (queries != null) 'queries': queries, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + }; - final res = await client.call(HttpMethod.get, - path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.TransactionList.fromMap(res.data); - return models.TransactionList.fromMap(res.data); } /// Create a new transaction. Future createTransaction({int? ttl}) async { final String apiPath = '/tablesdb/transactions'; - final Map apiParams = { - if (ttl != null) 'ttl': ttl, - }; + final Map apiParams = { + if (ttl != null) 'ttl': ttl, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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.Transaction.fromMap(res.data); - return models.Transaction.fromMap(res.data); } /// Get a transaction by its unique ID. - Future getTransaction( - {required String transactionId}) async { - final String apiPath = '/tablesdb/transactions/{transactionId}' - .replaceAll('{transactionId}', transactionId); + Future getTransaction({required String transactionId}) async { + final String apiPath = '/tablesdb/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + }; - final Map apiParams = {}; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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.Transaction.fromMap(res.data); - return models.Transaction.fromMap(res.data); } /// Update a transaction, to either commit or roll back its operations. - Future updateTransaction( - {required String transactionId, bool? commit, bool? rollback}) async { - final String apiPath = '/tablesdb/transactions/{transactionId}' - .replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - if (commit != null) 'commit': commit, - if (rollback != null) 'rollback': rollback, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, - path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Transaction.fromMap(res.data); + Future updateTransaction({required String transactionId, bool? commit, bool? rollback}) async { + final String apiPath = '/tablesdb/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + if (commit != null) 'commit': commit, + + if (rollback != null) 'rollback': rollback, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Transaction.fromMap(res.data); + } /// Delete a transaction by its unique ID. Future deleteTransaction({required String transactionId}) async { - final String apiPath = '/tablesdb/transactions/{transactionId}' - .replaceAll('{transactionId}', transactionId); + final String apiPath = '/tablesdb/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + }; - final Map apiParams = {}; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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; } /// Create multiple operations in a single transaction. - Future createOperations( - {required String transactionId, List? operations}) async { - final String apiPath = '/tablesdb/transactions/{transactionId}/operations' - .replaceAll('{transactionId}', transactionId); + Future createOperations({required String transactionId, List? operations}) async { + final String apiPath = '/tablesdb/transactions/{transactionId}/operations'.replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + if (operations != null) 'operations': operations, + + }; - final Map apiParams = { - if (operations != null) 'operations': operations, - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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.Transaction.fromMap(res.data); - return models.Transaction.fromMap(res.data); } /// 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, - String? transactionId, - bool? total, - int? ttl}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - if (transactionId != null) 'transactionId': transactionId, - if (total != null) 'total': total, - if (ttl != null) 'ttl': ttl, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, String? transactionId, bool? total, int? ttl}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + + if (transactionId != null) 'transactionId': transactionId, + + if (total != null) 'total': total, + + if (ttl != null) 'ttl': ttl, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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/references/cloud/server-dart/tablesDB#createTable) /// API or directly from your database console. - Future createRow( - {required String databaseId, - required String tableId, - required String rowId, - required Map data, - List? permissions, - String? transactionId}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId); - - final Map apiParams = { - 'rowId': rowId, - 'data': data, - 'permissions': permissions, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, String? transactionId}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); + + final Map apiParams = { + 'rowId': rowId, + + 'data': data, + + 'permissions': permissions, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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, - String? transactionId}) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - if (transactionId != null) 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, String? transactionId}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + + if (transactionId != null) 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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/references/cloud/server-dart/tablesDB#createTable) /// API or directly from your database console. - Future upsertRow( - {required String databaseId, - required String tableId, - required String rowId, - Map? data, - List? permissions, - String? transactionId}) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); - - final Map apiParams = { - if (data != null) 'data': data, - 'permissions': permissions, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, String? transactionId}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); + + final Map apiParams = { + if (data != null) 'data': data, + + 'permissions': permissions, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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, - String? transactionId}) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); - - final Map apiParams = { - if (data != null) 'data': data, - 'permissions': permissions, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, String? transactionId}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); + + final Map apiParams = { + if (data != null) 'data': data, + + 'permissions': permissions, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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, - String? transactionId}) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); - - final Map apiParams = { - if (transactionId != null) 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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, String? transactionId}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); + + final Map apiParams = { + if (transactionId != null) 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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, - String? transactionId}) 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 = { - if (value != null) 'value': value, - 'min': min, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, String? transactionId}) 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 = { + if (value != null) 'value': value, + + 'min': min, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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, - String? transactionId}) 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 = { - if (value != null) 'value': value, - 'max': max, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, String? transactionId}) 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 = { + if (value != null) 'value': value, + + 'max': max, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); + } } diff --git a/lib/services/teams.dart b/lib/services/teams.dart index 1f4022f6..27bc561e 100644 --- a/lib/services/teams.dart +++ b/lib/services/teams.dart @@ -1,97 +1,98 @@ 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); /// Get a list of all the teams in which the current user is a member. You can /// use the parameters to filter your results. - Future list( - {List? queries, String? search, bool? total}) async { + Future list({List? queries, String? search, bool? total}) async { final String apiPath = '/teams'; - final Map apiParams = { - if (queries != null) 'queries': queries, - if (search != null) 'search': search, - if (total != null) 'total': total, - }; + final Map apiParams = { + if (queries != null) 'queries': queries, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + if (search != null) 'search': search, - final res = await client.call(HttpMethod.get, - path: apiPath, params: apiParams, headers: apiHeaders); + if (total != null) 'total': total, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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 { final String apiPath = '/teams'; - final Map apiParams = { - 'teamId': teamId, - 'name': name, - if (roles != null) 'roles': roles, - }; + final Map apiParams = { + 'teamId': teamId, + + 'name': name, + + if (roles != null) 'roles': roles, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 @@ -99,45 +100,44 @@ 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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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, - bool? total}) async { - final String apiPath = - '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - if (search != null) 'search': search, - if (total != null) 'total': total, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, bool? total}) async { + final String apiPath = '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + + if (search != null) 'search': search, + + if (total != null) 'total': total, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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 @@ -146,199 +146,180 @@ 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 = { - if (email != null) 'email': email, - if (userId != null) 'userId': userId, - if (phone != null) 'phone': phone, - 'roles': roles, - if (url != null) 'url': url, - if (name != null) 'name': name, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 = { + if (email != null) 'email': email, + + if (userId != null) 'userId': userId, + + if (phone != null) 'phone': phone, + + 'roles': roles, + + if (url != null) 'url': url, + + if (name != null) 'name': name, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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); + 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 apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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.Membership.fromMap(res.data); - 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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); + 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 apiParams = { - 'prefs': prefs, - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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.Preferences.fromMap(res.data); - return models.Preferences.fromMap(res.data); } } diff --git a/lib/src/client.dart b/lib/src/client.dart index cc077e56..65b2f044 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -27,8 +27,7 @@ abstract class Client { factory Client({ String endPoint = 'https://cloud.appwrite.io/v1', bool selfSigned = false, - }) => - createClient(endPoint: endPoint, selfSigned: selfSigned); + }) => createClient(endPoint: endPoint, selfSigned: selfSigned); /// Handle OAuth2 session creation. Future webAuth(Uri url, {String? callbackUrlScheme}); @@ -108,6 +107,7 @@ abstract class Client { /// Send a ping to project as part of onboarding. Future ping(); + /// Send the API request. Future call( HttpMethod method, { diff --git a/lib/src/client_base.dart b/lib/src/client_base.dart index da1a5225..9e964a79 100644 --- a/lib/src/client_base.dart +++ b/lib/src/client_base.dart @@ -6,33 +6,26 @@ 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); - /// The user cookie to authenticate with. Used by SDKs that forward an incoming Cookie header in server-side runtimes. @override ClientBase setCookie(value); - /// Impersonate a user by ID @override ClientBase setImpersonateUserId(value); - /// Impersonate a user by email @override ClientBase setImpersonateUserEmail(value); - /// Impersonate a user by phone @override ClientBase setImpersonateUserPhone(value); diff --git a/lib/src/client_browser.dart b/lib/src/client_browser.dart index 32945efd..2f4c7b48 100644 --- a/lib/src/client_browser.dart +++ b/lib/src/client_browser.dart @@ -62,7 +62,6 @@ class ClientBrowser extends ClientBase with ClientMixin { config['project'] = value; return this; } - /// Your secret JSON Web Token @override ClientBrowser setJWT(value) { @@ -70,14 +69,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) { @@ -85,7 +82,6 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Session', value); return this; } - /// Your secret dev API key @override ClientBrowser setDevKey(value) { @@ -93,7 +89,6 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Dev-Key', value); return this; } - /// The user cookie to authenticate with. Used by SDKs that forward an incoming Cookie header in server-side runtimes. @override ClientBrowser setCookie(value) { @@ -101,7 +96,6 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('Cookie', value); return this; } - /// Impersonate a user by ID @override ClientBrowser setImpersonateUserId(value) { @@ -109,7 +103,6 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Impersonate-User-Id', value); return this; } - /// Impersonate a user by email @override ClientBrowser setImpersonateUserEmail(value) { @@ -117,7 +110,6 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Impersonate-User-Email', value); return this; } - /// Impersonate a user by phone @override ClientBrowser setImpersonateUserPhone(value) { @@ -227,8 +219,7 @@ class ClientBrowser extends ClientBase with ClientMixin { final totalChunks = (size / chunkSize).ceil(); - Future uploadChunk( - int index, int start, int end, String? id) async { + Future uploadChunk(int index, int start, int end, String? id) async { List chunk = []; chunk = file.bytes!.getRange(start, end).toList(); @@ -266,9 +257,7 @@ class ClientBrowser extends ClientBase with ClientMixin { bool isUploadComplete(Response response) { final chunksUploaded = response.data['chunksUploaded']; final chunksTotal = response.data['chunksTotal'] ?? totalChunks; - return chunksUploaded is num && - chunksTotal is num && - chunksUploaded >= chunksTotal; + return chunksUploaded is num && chunksTotal is num && chunksUploaded >= chunksTotal; } final progress = UploadProgress( diff --git a/lib/src/client_io.dart b/lib/src/client_io.dart index 78a368ae..6e6e2ee8 100644 --- a/lib/src/client_io.dart +++ b/lib/src/client_io.dart @@ -88,7 +88,6 @@ class ClientIO extends ClientBase with ClientMixin { config['project'] = value; return this; } - /// Your secret JSON Web Token @override ClientIO setJWT(value) { @@ -96,14 +95,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) { @@ -111,7 +108,6 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Session', value); return this; } - /// Your secret dev API key @override ClientIO setDevKey(value) { @@ -119,7 +115,6 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Dev-Key', value); return this; } - /// The user cookie to authenticate with. Used by SDKs that forward an incoming Cookie header in server-side runtimes. @override ClientIO setCookie(value) { @@ -127,7 +122,6 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('Cookie', value); return this; } - /// Impersonate a user by ID @override ClientIO setImpersonateUserId(value) { @@ -135,7 +129,6 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Impersonate-User-Id', value); return this; } - /// Impersonate a user by email @override ClientIO setImpersonateUserEmail(value) { @@ -143,7 +136,6 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Impersonate-User-Email', value); return this; } - /// Impersonate a user by phone @override ClientIO setImpersonateUserPhone(value) { @@ -402,9 +394,7 @@ class ClientIO extends ClientBase with ClientMixin { bool isUploadComplete(Response response) { final chunksUploaded = response.data['chunksUploaded']; final chunksTotal = response.data['chunksTotal'] ?? totalChunks; - return chunksUploaded is num && - chunksTotal is num && - chunksUploaded >= chunksTotal; + return chunksUploaded is num && chunksTotal is num && chunksUploaded >= chunksTotal; } final progress = UploadProgress( @@ -428,8 +418,7 @@ class ClientIO extends ClientBase with ClientMixin { var nextChunk = 0; Future uploadNext() async { - final raf = - file.bytes == null ? await iofile!.open(mode: FileMode.read) : null; + final raf = file.bytes == null ? await iofile!.open(mode: FileMode.read) : null; try { while (nextChunk < chunks.length) { final chunk = chunks[nextChunk++]; diff --git a/lib/src/client_mixin.dart b/lib/src/client_mixin.dart index 89aad359..40484946 100644 --- a/lib/src/client_mixin.dart +++ b/lib/src/client_mixin.dart @@ -12,6 +12,7 @@ mixin ClientMixin { required Map headers, required Map params, }) { + http.BaseRequest request = http.Request(method.name(), uri); if (headers['content-type'] == 'multipart/form-data') { request = http.MultipartRequest(method.name(), uri); @@ -127,13 +128,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/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/browser_permission.dart b/lib/src/enums/browser_permission.dart index fb4983db..765b3e0c 100644 --- a/lib/src/enums/browser_permission.dart +++ b/lib/src/enums/browser_permission.dart @@ -1,30 +1,32 @@ part of '../../enums.dart'; enum BrowserPermission { - geolocation(value: 'geolocation'), - camera(value: 'camera'), - microphone(value: 'microphone'), - notifications(value: 'notifications'), - midi(value: 'midi'), - push(value: 'push'), - clipboardRead(value: 'clipboard-read'), - clipboardWrite(value: 'clipboard-write'), - paymentHandler(value: 'payment-handler'), - usb(value: 'usb'), - bluetooth(value: 'bluetooth'), - accelerometer(value: 'accelerometer'), - gyroscope(value: 'gyroscope'), - magnetometer(value: 'magnetometer'), - ambientLightSensor(value: 'ambient-light-sensor'), - backgroundSync(value: 'background-sync'), - persistentStorage(value: 'persistent-storage'), - screenWakeLock(value: 'screen-wake-lock'), - webShare(value: 'web-share'), - xrSpatialTracking(value: 'xr-spatial-tracking'); + geolocation(value: 'geolocation'), + camera(value: 'camera'), + microphone(value: 'microphone'), + notifications(value: 'notifications'), + midi(value: 'midi'), + push(value: 'push'), + clipboardRead(value: 'clipboard-read'), + clipboardWrite(value: 'clipboard-write'), + paymentHandler(value: 'payment-handler'), + usb(value: 'usb'), + bluetooth(value: 'bluetooth'), + accelerometer(value: 'accelerometer'), + gyroscope(value: 'gyroscope'), + magnetometer(value: 'magnetometer'), + ambientLightSensor(value: 'ambient-light-sensor'), + backgroundSync(value: 'background-sync'), + persistentStorage(value: 'persistent-storage'), + screenWakeLock(value: 'screen-wake-lock'), + webShare(value: 'web-share'), + xrSpatialTracking(value: 'xr-spatial-tracking'); - const BrowserPermission({required this.value}); + const BrowserPermission({ + 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_theme.dart b/lib/src/enums/browser_theme.dart index 1e059c2c..e81a0f68 100644 --- a/lib/src/enums/browser_theme.dart +++ b/lib/src/enums/browser_theme.dart @@ -1,12 +1,14 @@ part of '../../enums.dart'; enum BrowserTheme { - light(value: 'light'), - dark(value: 'dark'); + light(value: 'light'), + dark(value: 'dark'); - const BrowserTheme({required this.value}); + const BrowserTheme({ + 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/execution_status.dart b/lib/src/enums/execution_status.dart index 7ea9865e..f54859c9 100644 --- a/lib/src/enums/execution_status.dart +++ b/lib/src/enums/execution_status.dart @@ -1,15 +1,17 @@ part of '../../enums.dart'; enum ExecutionStatus { - waiting(value: 'waiting'), - processing(value: 'processing'), - completed(value: 'completed'), - failed(value: 'failed'), - scheduled(value: 'scheduled'); + waiting(value: 'waiting'), + processing(value: 'processing'), + completed(value: 'completed'), + failed(value: 'failed'), + scheduled(value: 'scheduled'); - const ExecutionStatus({required this.value}); + const ExecutionStatus({ + 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_trigger.dart b/lib/src/enums/execution_trigger.dart index fb05eb7d..8a14ae60 100644 --- a/lib/src/enums/execution_trigger.dart +++ b/lib/src/enums/execution_trigger.dart @@ -1,13 +1,15 @@ part of '../../enums.dart'; enum ExecutionTrigger { - http(value: 'http'), - schedule(value: 'schedule'), - event(value: 'event'); + http(value: 'http'), + schedule(value: 'schedule'), + event(value: 'event'); - const ExecutionTrigger({required this.value}); + const ExecutionTrigger({ + 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 b88e0a55..8ed7ecff 100644 --- a/lib/src/enums/o_auth_provider.dart +++ b/lib/src/enums/o_auth_provider.dart @@ -1,53 +1,55 @@ 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'), - fusionauth(value: 'fusionauth'), - github(value: 'github'), - gitlab(value: 'gitlab'), - google(value: 'google'), - keycloak(value: 'keycloak'), - kick(value: 'kick'), - 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'), - x(value: 'x'), - yahoo(value: 'yahoo'), - yammer(value: 'yammer'), - yandex(value: 'yandex'), - zoho(value: 'zoho'), - zoom(value: 'zoom'); + 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'), + fusionauth(value: 'fusionauth'), + github(value: 'github'), + gitlab(value: 'gitlab'), + google(value: 'google'), + keycloak(value: 'keycloak'), + kick(value: 'kick'), + 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'), + x(value: 'x'), + yahoo(value: 'yahoo'), + yammer(value: 'yammer'), + yandex(value: 'yandex'), + zoho(value: 'zoho'), + zoom(value: 'zoom'); - 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/enums/timezone.dart b/lib/src/enums/timezone.dart index d5d8d94a..4a8de1ce 100644 --- a/lib/src/enums/timezone.dart +++ b/lib/src/enums/timezone.dart @@ -1,429 +1,431 @@ part of '../../enums.dart'; enum Timezone { - africaAbidjan(value: 'africa/abidjan'), - africaAccra(value: 'africa/accra'), - africaAddisAbaba(value: 'africa/addis_ababa'), - africaAlgiers(value: 'africa/algiers'), - africaAsmara(value: 'africa/asmara'), - africaBamako(value: 'africa/bamako'), - africaBangui(value: 'africa/bangui'), - africaBanjul(value: 'africa/banjul'), - africaBissau(value: 'africa/bissau'), - africaBlantyre(value: 'africa/blantyre'), - africaBrazzaville(value: 'africa/brazzaville'), - africaBujumbura(value: 'africa/bujumbura'), - africaCairo(value: 'africa/cairo'), - africaCasablanca(value: 'africa/casablanca'), - africaCeuta(value: 'africa/ceuta'), - africaConakry(value: 'africa/conakry'), - africaDakar(value: 'africa/dakar'), - africaDarEsSalaam(value: 'africa/dar_es_salaam'), - africaDjibouti(value: 'africa/djibouti'), - africaDouala(value: 'africa/douala'), - africaElAaiun(value: 'africa/el_aaiun'), - africaFreetown(value: 'africa/freetown'), - africaGaborone(value: 'africa/gaborone'), - africaHarare(value: 'africa/harare'), - africaJohannesburg(value: 'africa/johannesburg'), - africaJuba(value: 'africa/juba'), - africaKampala(value: 'africa/kampala'), - africaKhartoum(value: 'africa/khartoum'), - africaKigali(value: 'africa/kigali'), - africaKinshasa(value: 'africa/kinshasa'), - africaLagos(value: 'africa/lagos'), - africaLibreville(value: 'africa/libreville'), - africaLome(value: 'africa/lome'), - africaLuanda(value: 'africa/luanda'), - africaLubumbashi(value: 'africa/lubumbashi'), - africaLusaka(value: 'africa/lusaka'), - africaMalabo(value: 'africa/malabo'), - africaMaputo(value: 'africa/maputo'), - africaMaseru(value: 'africa/maseru'), - africaMbabane(value: 'africa/mbabane'), - africaMogadishu(value: 'africa/mogadishu'), - africaMonrovia(value: 'africa/monrovia'), - africaNairobi(value: 'africa/nairobi'), - africaNdjamena(value: 'africa/ndjamena'), - africaNiamey(value: 'africa/niamey'), - africaNouakchott(value: 'africa/nouakchott'), - africaOuagadougou(value: 'africa/ouagadougou'), - africaPortoNovo(value: 'africa/porto-novo'), - africaSaoTome(value: 'africa/sao_tome'), - africaTripoli(value: 'africa/tripoli'), - africaTunis(value: 'africa/tunis'), - africaWindhoek(value: 'africa/windhoek'), - americaAdak(value: 'america/adak'), - americaAnchorage(value: 'america/anchorage'), - americaAnguilla(value: 'america/anguilla'), - americaAntigua(value: 'america/antigua'), - americaAraguaina(value: 'america/araguaina'), - americaArgentinaBuenosAires(value: 'america/argentina/buenos_aires'), - americaArgentinaCatamarca(value: 'america/argentina/catamarca'), - americaArgentinaCordoba(value: 'america/argentina/cordoba'), - americaArgentinaJujuy(value: 'america/argentina/jujuy'), - americaArgentinaLaRioja(value: 'america/argentina/la_rioja'), - americaArgentinaMendoza(value: 'america/argentina/mendoza'), - americaArgentinaRioGallegos(value: 'america/argentina/rio_gallegos'), - americaArgentinaSalta(value: 'america/argentina/salta'), - americaArgentinaSanJuan(value: 'america/argentina/san_juan'), - americaArgentinaSanLuis(value: 'america/argentina/san_luis'), - americaArgentinaTucuman(value: 'america/argentina/tucuman'), - americaArgentinaUshuaia(value: 'america/argentina/ushuaia'), - americaAruba(value: 'america/aruba'), - americaAsuncion(value: 'america/asuncion'), - americaAtikokan(value: 'america/atikokan'), - americaBahia(value: 'america/bahia'), - americaBahiaBanderas(value: 'america/bahia_banderas'), - americaBarbados(value: 'america/barbados'), - americaBelem(value: 'america/belem'), - americaBelize(value: 'america/belize'), - americaBlancSablon(value: 'america/blanc-sablon'), - americaBoaVista(value: 'america/boa_vista'), - americaBogota(value: 'america/bogota'), - americaBoise(value: 'america/boise'), - americaCambridgeBay(value: 'america/cambridge_bay'), - americaCampoGrande(value: 'america/campo_grande'), - americaCancun(value: 'america/cancun'), - americaCaracas(value: 'america/caracas'), - americaCayenne(value: 'america/cayenne'), - americaCayman(value: 'america/cayman'), - americaChicago(value: 'america/chicago'), - americaChihuahua(value: 'america/chihuahua'), - americaCiudadJuarez(value: 'america/ciudad_juarez'), - americaCostaRica(value: 'america/costa_rica'), - americaCoyhaique(value: 'america/coyhaique'), - americaCreston(value: 'america/creston'), - americaCuiaba(value: 'america/cuiaba'), - americaCuracao(value: 'america/curacao'), - americaDanmarkshavn(value: 'america/danmarkshavn'), - americaDawson(value: 'america/dawson'), - americaDawsonCreek(value: 'america/dawson_creek'), - americaDenver(value: 'america/denver'), - americaDetroit(value: 'america/detroit'), - americaDominica(value: 'america/dominica'), - americaEdmonton(value: 'america/edmonton'), - americaEirunepe(value: 'america/eirunepe'), - americaElSalvador(value: 'america/el_salvador'), - americaFortNelson(value: 'america/fort_nelson'), - americaFortaleza(value: 'america/fortaleza'), - americaGlaceBay(value: 'america/glace_bay'), - americaGooseBay(value: 'america/goose_bay'), - americaGrandTurk(value: 'america/grand_turk'), - americaGrenada(value: 'america/grenada'), - americaGuadeloupe(value: 'america/guadeloupe'), - americaGuatemala(value: 'america/guatemala'), - americaGuayaquil(value: 'america/guayaquil'), - americaGuyana(value: 'america/guyana'), - americaHalifax(value: 'america/halifax'), - americaHavana(value: 'america/havana'), - americaHermosillo(value: 'america/hermosillo'), - americaIndianaIndianapolis(value: 'america/indiana/indianapolis'), - americaIndianaKnox(value: 'america/indiana/knox'), - americaIndianaMarengo(value: 'america/indiana/marengo'), - americaIndianaPetersburg(value: 'america/indiana/petersburg'), - americaIndianaTellCity(value: 'america/indiana/tell_city'), - americaIndianaVevay(value: 'america/indiana/vevay'), - americaIndianaVincennes(value: 'america/indiana/vincennes'), - americaIndianaWinamac(value: 'america/indiana/winamac'), - americaInuvik(value: 'america/inuvik'), - americaIqaluit(value: 'america/iqaluit'), - americaJamaica(value: 'america/jamaica'), - americaJuneau(value: 'america/juneau'), - americaKentuckyLouisville(value: 'america/kentucky/louisville'), - americaKentuckyMonticello(value: 'america/kentucky/monticello'), - americaKralendijk(value: 'america/kralendijk'), - americaLaPaz(value: 'america/la_paz'), - americaLima(value: 'america/lima'), - americaLosAngeles(value: 'america/los_angeles'), - americaLowerPrinces(value: 'america/lower_princes'), - americaMaceio(value: 'america/maceio'), - americaManagua(value: 'america/managua'), - americaManaus(value: 'america/manaus'), - americaMarigot(value: 'america/marigot'), - americaMartinique(value: 'america/martinique'), - americaMatamoros(value: 'america/matamoros'), - americaMazatlan(value: 'america/mazatlan'), - americaMenominee(value: 'america/menominee'), - americaMerida(value: 'america/merida'), - americaMetlakatla(value: 'america/metlakatla'), - americaMexicoCity(value: 'america/mexico_city'), - americaMiquelon(value: 'america/miquelon'), - americaMoncton(value: 'america/moncton'), - americaMonterrey(value: 'america/monterrey'), - americaMontevideo(value: 'america/montevideo'), - americaMontserrat(value: 'america/montserrat'), - americaNassau(value: 'america/nassau'), - americaNewYork(value: 'america/new_york'), - americaNome(value: 'america/nome'), - americaNoronha(value: 'america/noronha'), - americaNorthDakotaBeulah(value: 'america/north_dakota/beulah'), - americaNorthDakotaCenter(value: 'america/north_dakota/center'), - americaNorthDakotaNewSalem(value: 'america/north_dakota/new_salem'), - americaNuuk(value: 'america/nuuk'), - americaOjinaga(value: 'america/ojinaga'), - americaPanama(value: 'america/panama'), - americaParamaribo(value: 'america/paramaribo'), - americaPhoenix(value: 'america/phoenix'), - americaPortAuPrince(value: 'america/port-au-prince'), - americaPortOfSpain(value: 'america/port_of_spain'), - americaPortoVelho(value: 'america/porto_velho'), - americaPuertoRico(value: 'america/puerto_rico'), - americaPuntaArenas(value: 'america/punta_arenas'), - americaRankinInlet(value: 'america/rankin_inlet'), - americaRecife(value: 'america/recife'), - americaRegina(value: 'america/regina'), - americaResolute(value: 'america/resolute'), - americaRioBranco(value: 'america/rio_branco'), - americaSantarem(value: 'america/santarem'), - americaSantiago(value: 'america/santiago'), - americaSantoDomingo(value: 'america/santo_domingo'), - americaSaoPaulo(value: 'america/sao_paulo'), - americaScoresbysund(value: 'america/scoresbysund'), - americaSitka(value: 'america/sitka'), - americaStBarthelemy(value: 'america/st_barthelemy'), - americaStJohns(value: 'america/st_johns'), - americaStKitts(value: 'america/st_kitts'), - americaStLucia(value: 'america/st_lucia'), - americaStThomas(value: 'america/st_thomas'), - americaStVincent(value: 'america/st_vincent'), - americaSwiftCurrent(value: 'america/swift_current'), - americaTegucigalpa(value: 'america/tegucigalpa'), - americaThule(value: 'america/thule'), - americaTijuana(value: 'america/tijuana'), - americaToronto(value: 'america/toronto'), - americaTortola(value: 'america/tortola'), - americaVancouver(value: 'america/vancouver'), - americaWhitehorse(value: 'america/whitehorse'), - americaWinnipeg(value: 'america/winnipeg'), - americaYakutat(value: 'america/yakutat'), - antarcticaCasey(value: 'antarctica/casey'), - antarcticaDavis(value: 'antarctica/davis'), - antarcticaDumontdurville(value: 'antarctica/dumontdurville'), - antarcticaMacquarie(value: 'antarctica/macquarie'), - antarcticaMawson(value: 'antarctica/mawson'), - antarcticaMcmurdo(value: 'antarctica/mcmurdo'), - antarcticaPalmer(value: 'antarctica/palmer'), - antarcticaRothera(value: 'antarctica/rothera'), - antarcticaSyowa(value: 'antarctica/syowa'), - antarcticaTroll(value: 'antarctica/troll'), - antarcticaVostok(value: 'antarctica/vostok'), - arcticLongyearbyen(value: 'arctic/longyearbyen'), - asiaAden(value: 'asia/aden'), - asiaAlmaty(value: 'asia/almaty'), - asiaAmman(value: 'asia/amman'), - asiaAnadyr(value: 'asia/anadyr'), - asiaAqtau(value: 'asia/aqtau'), - asiaAqtobe(value: 'asia/aqtobe'), - asiaAshgabat(value: 'asia/ashgabat'), - asiaAtyrau(value: 'asia/atyrau'), - asiaBaghdad(value: 'asia/baghdad'), - asiaBahrain(value: 'asia/bahrain'), - asiaBaku(value: 'asia/baku'), - asiaBangkok(value: 'asia/bangkok'), - asiaBarnaul(value: 'asia/barnaul'), - asiaBeirut(value: 'asia/beirut'), - asiaBishkek(value: 'asia/bishkek'), - asiaBrunei(value: 'asia/brunei'), - asiaChita(value: 'asia/chita'), - asiaColombo(value: 'asia/colombo'), - asiaDamascus(value: 'asia/damascus'), - asiaDhaka(value: 'asia/dhaka'), - asiaDili(value: 'asia/dili'), - asiaDubai(value: 'asia/dubai'), - asiaDushanbe(value: 'asia/dushanbe'), - asiaFamagusta(value: 'asia/famagusta'), - asiaGaza(value: 'asia/gaza'), - asiaHebron(value: 'asia/hebron'), - asiaHoChiMinh(value: 'asia/ho_chi_minh'), - asiaHongKong(value: 'asia/hong_kong'), - asiaHovd(value: 'asia/hovd'), - asiaIrkutsk(value: 'asia/irkutsk'), - asiaJakarta(value: 'asia/jakarta'), - asiaJayapura(value: 'asia/jayapura'), - asiaJerusalem(value: 'asia/jerusalem'), - asiaKabul(value: 'asia/kabul'), - asiaKamchatka(value: 'asia/kamchatka'), - asiaKarachi(value: 'asia/karachi'), - asiaKathmandu(value: 'asia/kathmandu'), - asiaKhandyga(value: 'asia/khandyga'), - asiaKolkata(value: 'asia/kolkata'), - asiaKrasnoyarsk(value: 'asia/krasnoyarsk'), - asiaKualaLumpur(value: 'asia/kuala_lumpur'), - asiaKuching(value: 'asia/kuching'), - asiaKuwait(value: 'asia/kuwait'), - asiaMacau(value: 'asia/macau'), - asiaMagadan(value: 'asia/magadan'), - asiaMakassar(value: 'asia/makassar'), - asiaManila(value: 'asia/manila'), - asiaMuscat(value: 'asia/muscat'), - asiaNicosia(value: 'asia/nicosia'), - asiaNovokuznetsk(value: 'asia/novokuznetsk'), - asiaNovosibirsk(value: 'asia/novosibirsk'), - asiaOmsk(value: 'asia/omsk'), - asiaOral(value: 'asia/oral'), - asiaPhnomPenh(value: 'asia/phnom_penh'), - asiaPontianak(value: 'asia/pontianak'), - asiaPyongyang(value: 'asia/pyongyang'), - asiaQatar(value: 'asia/qatar'), - asiaQostanay(value: 'asia/qostanay'), - asiaQyzylorda(value: 'asia/qyzylorda'), - asiaRiyadh(value: 'asia/riyadh'), - asiaSakhalin(value: 'asia/sakhalin'), - asiaSamarkand(value: 'asia/samarkand'), - asiaSeoul(value: 'asia/seoul'), - asiaShanghai(value: 'asia/shanghai'), - asiaSingapore(value: 'asia/singapore'), - asiaSrednekolymsk(value: 'asia/srednekolymsk'), - asiaTaipei(value: 'asia/taipei'), - asiaTashkent(value: 'asia/tashkent'), - asiaTbilisi(value: 'asia/tbilisi'), - asiaTehran(value: 'asia/tehran'), - asiaThimphu(value: 'asia/thimphu'), - asiaTokyo(value: 'asia/tokyo'), - asiaTomsk(value: 'asia/tomsk'), - asiaUlaanbaatar(value: 'asia/ulaanbaatar'), - asiaUrumqi(value: 'asia/urumqi'), - asiaUstNera(value: 'asia/ust-nera'), - asiaVientiane(value: 'asia/vientiane'), - asiaVladivostok(value: 'asia/vladivostok'), - asiaYakutsk(value: 'asia/yakutsk'), - asiaYangon(value: 'asia/yangon'), - asiaYekaterinburg(value: 'asia/yekaterinburg'), - asiaYerevan(value: 'asia/yerevan'), - atlanticAzores(value: 'atlantic/azores'), - atlanticBermuda(value: 'atlantic/bermuda'), - atlanticCanary(value: 'atlantic/canary'), - atlanticCapeVerde(value: 'atlantic/cape_verde'), - atlanticFaroe(value: 'atlantic/faroe'), - atlanticMadeira(value: 'atlantic/madeira'), - atlanticReykjavik(value: 'atlantic/reykjavik'), - atlanticSouthGeorgia(value: 'atlantic/south_georgia'), - atlanticStHelena(value: 'atlantic/st_helena'), - atlanticStanley(value: 'atlantic/stanley'), - australiaAdelaide(value: 'australia/adelaide'), - australiaBrisbane(value: 'australia/brisbane'), - australiaBrokenHill(value: 'australia/broken_hill'), - australiaDarwin(value: 'australia/darwin'), - australiaEucla(value: 'australia/eucla'), - australiaHobart(value: 'australia/hobart'), - australiaLindeman(value: 'australia/lindeman'), - australiaLordHowe(value: 'australia/lord_howe'), - australiaMelbourne(value: 'australia/melbourne'), - australiaPerth(value: 'australia/perth'), - australiaSydney(value: 'australia/sydney'), - europeAmsterdam(value: 'europe/amsterdam'), - europeAndorra(value: 'europe/andorra'), - europeAstrakhan(value: 'europe/astrakhan'), - europeAthens(value: 'europe/athens'), - europeBelgrade(value: 'europe/belgrade'), - europeBerlin(value: 'europe/berlin'), - europeBratislava(value: 'europe/bratislava'), - europeBrussels(value: 'europe/brussels'), - europeBucharest(value: 'europe/bucharest'), - europeBudapest(value: 'europe/budapest'), - europeBusingen(value: 'europe/busingen'), - europeChisinau(value: 'europe/chisinau'), - europeCopenhagen(value: 'europe/copenhagen'), - europeDublin(value: 'europe/dublin'), - europeGibraltar(value: 'europe/gibraltar'), - europeGuernsey(value: 'europe/guernsey'), - europeHelsinki(value: 'europe/helsinki'), - europeIsleOfMan(value: 'europe/isle_of_man'), - europeIstanbul(value: 'europe/istanbul'), - europeJersey(value: 'europe/jersey'), - europeKaliningrad(value: 'europe/kaliningrad'), - europeKirov(value: 'europe/kirov'), - europeKyiv(value: 'europe/kyiv'), - europeLisbon(value: 'europe/lisbon'), - europeLjubljana(value: 'europe/ljubljana'), - europeLondon(value: 'europe/london'), - europeLuxembourg(value: 'europe/luxembourg'), - europeMadrid(value: 'europe/madrid'), - europeMalta(value: 'europe/malta'), - europeMariehamn(value: 'europe/mariehamn'), - europeMinsk(value: 'europe/minsk'), - europeMonaco(value: 'europe/monaco'), - europeMoscow(value: 'europe/moscow'), - europeOslo(value: 'europe/oslo'), - europeParis(value: 'europe/paris'), - europePodgorica(value: 'europe/podgorica'), - europePrague(value: 'europe/prague'), - europeRiga(value: 'europe/riga'), - europeRome(value: 'europe/rome'), - europeSamara(value: 'europe/samara'), - europeSanMarino(value: 'europe/san_marino'), - europeSarajevo(value: 'europe/sarajevo'), - europeSaratov(value: 'europe/saratov'), - europeSimferopol(value: 'europe/simferopol'), - europeSkopje(value: 'europe/skopje'), - europeSofia(value: 'europe/sofia'), - europeStockholm(value: 'europe/stockholm'), - europeTallinn(value: 'europe/tallinn'), - europeTirane(value: 'europe/tirane'), - europeUlyanovsk(value: 'europe/ulyanovsk'), - europeVaduz(value: 'europe/vaduz'), - europeVatican(value: 'europe/vatican'), - europeVienna(value: 'europe/vienna'), - europeVilnius(value: 'europe/vilnius'), - europeVolgograd(value: 'europe/volgograd'), - europeWarsaw(value: 'europe/warsaw'), - europeZagreb(value: 'europe/zagreb'), - europeZurich(value: 'europe/zurich'), - indianAntananarivo(value: 'indian/antananarivo'), - indianChagos(value: 'indian/chagos'), - indianChristmas(value: 'indian/christmas'), - indianCocos(value: 'indian/cocos'), - indianComoro(value: 'indian/comoro'), - indianKerguelen(value: 'indian/kerguelen'), - indianMahe(value: 'indian/mahe'), - indianMaldives(value: 'indian/maldives'), - indianMauritius(value: 'indian/mauritius'), - indianMayotte(value: 'indian/mayotte'), - indianReunion(value: 'indian/reunion'), - pacificApia(value: 'pacific/apia'), - pacificAuckland(value: 'pacific/auckland'), - pacificBougainville(value: 'pacific/bougainville'), - pacificChatham(value: 'pacific/chatham'), - pacificChuuk(value: 'pacific/chuuk'), - pacificEaster(value: 'pacific/easter'), - pacificEfate(value: 'pacific/efate'), - pacificFakaofo(value: 'pacific/fakaofo'), - pacificFiji(value: 'pacific/fiji'), - pacificFunafuti(value: 'pacific/funafuti'), - pacificGalapagos(value: 'pacific/galapagos'), - pacificGambier(value: 'pacific/gambier'), - pacificGuadalcanal(value: 'pacific/guadalcanal'), - pacificGuam(value: 'pacific/guam'), - pacificHonolulu(value: 'pacific/honolulu'), - pacificKanton(value: 'pacific/kanton'), - pacificKiritimati(value: 'pacific/kiritimati'), - pacificKosrae(value: 'pacific/kosrae'), - pacificKwajalein(value: 'pacific/kwajalein'), - pacificMajuro(value: 'pacific/majuro'), - pacificMarquesas(value: 'pacific/marquesas'), - pacificMidway(value: 'pacific/midway'), - pacificNauru(value: 'pacific/nauru'), - pacificNiue(value: 'pacific/niue'), - pacificNorfolk(value: 'pacific/norfolk'), - pacificNoumea(value: 'pacific/noumea'), - pacificPagoPago(value: 'pacific/pago_pago'), - pacificPalau(value: 'pacific/palau'), - pacificPitcairn(value: 'pacific/pitcairn'), - pacificPohnpei(value: 'pacific/pohnpei'), - pacificPortMoresby(value: 'pacific/port_moresby'), - pacificRarotonga(value: 'pacific/rarotonga'), - pacificSaipan(value: 'pacific/saipan'), - pacificTahiti(value: 'pacific/tahiti'), - pacificTarawa(value: 'pacific/tarawa'), - pacificTongatapu(value: 'pacific/tongatapu'), - pacificWake(value: 'pacific/wake'), - pacificWallis(value: 'pacific/wallis'), - utc(value: 'utc'); + africaAbidjan(value: 'africa/abidjan'), + africaAccra(value: 'africa/accra'), + africaAddisAbaba(value: 'africa/addis_ababa'), + africaAlgiers(value: 'africa/algiers'), + africaAsmara(value: 'africa/asmara'), + africaBamako(value: 'africa/bamako'), + africaBangui(value: 'africa/bangui'), + africaBanjul(value: 'africa/banjul'), + africaBissau(value: 'africa/bissau'), + africaBlantyre(value: 'africa/blantyre'), + africaBrazzaville(value: 'africa/brazzaville'), + africaBujumbura(value: 'africa/bujumbura'), + africaCairo(value: 'africa/cairo'), + africaCasablanca(value: 'africa/casablanca'), + africaCeuta(value: 'africa/ceuta'), + africaConakry(value: 'africa/conakry'), + africaDakar(value: 'africa/dakar'), + africaDarEsSalaam(value: 'africa/dar_es_salaam'), + africaDjibouti(value: 'africa/djibouti'), + africaDouala(value: 'africa/douala'), + africaElAaiun(value: 'africa/el_aaiun'), + africaFreetown(value: 'africa/freetown'), + africaGaborone(value: 'africa/gaborone'), + africaHarare(value: 'africa/harare'), + africaJohannesburg(value: 'africa/johannesburg'), + africaJuba(value: 'africa/juba'), + africaKampala(value: 'africa/kampala'), + africaKhartoum(value: 'africa/khartoum'), + africaKigali(value: 'africa/kigali'), + africaKinshasa(value: 'africa/kinshasa'), + africaLagos(value: 'africa/lagos'), + africaLibreville(value: 'africa/libreville'), + africaLome(value: 'africa/lome'), + africaLuanda(value: 'africa/luanda'), + africaLubumbashi(value: 'africa/lubumbashi'), + africaLusaka(value: 'africa/lusaka'), + africaMalabo(value: 'africa/malabo'), + africaMaputo(value: 'africa/maputo'), + africaMaseru(value: 'africa/maseru'), + africaMbabane(value: 'africa/mbabane'), + africaMogadishu(value: 'africa/mogadishu'), + africaMonrovia(value: 'africa/monrovia'), + africaNairobi(value: 'africa/nairobi'), + africaNdjamena(value: 'africa/ndjamena'), + africaNiamey(value: 'africa/niamey'), + africaNouakchott(value: 'africa/nouakchott'), + africaOuagadougou(value: 'africa/ouagadougou'), + africaPortoNovo(value: 'africa/porto-novo'), + africaSaoTome(value: 'africa/sao_tome'), + africaTripoli(value: 'africa/tripoli'), + africaTunis(value: 'africa/tunis'), + africaWindhoek(value: 'africa/windhoek'), + americaAdak(value: 'america/adak'), + americaAnchorage(value: 'america/anchorage'), + americaAnguilla(value: 'america/anguilla'), + americaAntigua(value: 'america/antigua'), + americaAraguaina(value: 'america/araguaina'), + americaArgentinaBuenosAires(value: 'america/argentina/buenos_aires'), + americaArgentinaCatamarca(value: 'america/argentina/catamarca'), + americaArgentinaCordoba(value: 'america/argentina/cordoba'), + americaArgentinaJujuy(value: 'america/argentina/jujuy'), + americaArgentinaLaRioja(value: 'america/argentina/la_rioja'), + americaArgentinaMendoza(value: 'america/argentina/mendoza'), + americaArgentinaRioGallegos(value: 'america/argentina/rio_gallegos'), + americaArgentinaSalta(value: 'america/argentina/salta'), + americaArgentinaSanJuan(value: 'america/argentina/san_juan'), + americaArgentinaSanLuis(value: 'america/argentina/san_luis'), + americaArgentinaTucuman(value: 'america/argentina/tucuman'), + americaArgentinaUshuaia(value: 'america/argentina/ushuaia'), + americaAruba(value: 'america/aruba'), + americaAsuncion(value: 'america/asuncion'), + americaAtikokan(value: 'america/atikokan'), + americaBahia(value: 'america/bahia'), + americaBahiaBanderas(value: 'america/bahia_banderas'), + americaBarbados(value: 'america/barbados'), + americaBelem(value: 'america/belem'), + americaBelize(value: 'america/belize'), + americaBlancSablon(value: 'america/blanc-sablon'), + americaBoaVista(value: 'america/boa_vista'), + americaBogota(value: 'america/bogota'), + americaBoise(value: 'america/boise'), + americaCambridgeBay(value: 'america/cambridge_bay'), + americaCampoGrande(value: 'america/campo_grande'), + americaCancun(value: 'america/cancun'), + americaCaracas(value: 'america/caracas'), + americaCayenne(value: 'america/cayenne'), + americaCayman(value: 'america/cayman'), + americaChicago(value: 'america/chicago'), + americaChihuahua(value: 'america/chihuahua'), + americaCiudadJuarez(value: 'america/ciudad_juarez'), + americaCostaRica(value: 'america/costa_rica'), + americaCoyhaique(value: 'america/coyhaique'), + americaCreston(value: 'america/creston'), + americaCuiaba(value: 'america/cuiaba'), + americaCuracao(value: 'america/curacao'), + americaDanmarkshavn(value: 'america/danmarkshavn'), + americaDawson(value: 'america/dawson'), + americaDawsonCreek(value: 'america/dawson_creek'), + americaDenver(value: 'america/denver'), + americaDetroit(value: 'america/detroit'), + americaDominica(value: 'america/dominica'), + americaEdmonton(value: 'america/edmonton'), + americaEirunepe(value: 'america/eirunepe'), + americaElSalvador(value: 'america/el_salvador'), + americaFortNelson(value: 'america/fort_nelson'), + americaFortaleza(value: 'america/fortaleza'), + americaGlaceBay(value: 'america/glace_bay'), + americaGooseBay(value: 'america/goose_bay'), + americaGrandTurk(value: 'america/grand_turk'), + americaGrenada(value: 'america/grenada'), + americaGuadeloupe(value: 'america/guadeloupe'), + americaGuatemala(value: 'america/guatemala'), + americaGuayaquil(value: 'america/guayaquil'), + americaGuyana(value: 'america/guyana'), + americaHalifax(value: 'america/halifax'), + americaHavana(value: 'america/havana'), + americaHermosillo(value: 'america/hermosillo'), + americaIndianaIndianapolis(value: 'america/indiana/indianapolis'), + americaIndianaKnox(value: 'america/indiana/knox'), + americaIndianaMarengo(value: 'america/indiana/marengo'), + americaIndianaPetersburg(value: 'america/indiana/petersburg'), + americaIndianaTellCity(value: 'america/indiana/tell_city'), + americaIndianaVevay(value: 'america/indiana/vevay'), + americaIndianaVincennes(value: 'america/indiana/vincennes'), + americaIndianaWinamac(value: 'america/indiana/winamac'), + americaInuvik(value: 'america/inuvik'), + americaIqaluit(value: 'america/iqaluit'), + americaJamaica(value: 'america/jamaica'), + americaJuneau(value: 'america/juneau'), + americaKentuckyLouisville(value: 'america/kentucky/louisville'), + americaKentuckyMonticello(value: 'america/kentucky/monticello'), + americaKralendijk(value: 'america/kralendijk'), + americaLaPaz(value: 'america/la_paz'), + americaLima(value: 'america/lima'), + americaLosAngeles(value: 'america/los_angeles'), + americaLowerPrinces(value: 'america/lower_princes'), + americaMaceio(value: 'america/maceio'), + americaManagua(value: 'america/managua'), + americaManaus(value: 'america/manaus'), + americaMarigot(value: 'america/marigot'), + americaMartinique(value: 'america/martinique'), + americaMatamoros(value: 'america/matamoros'), + americaMazatlan(value: 'america/mazatlan'), + americaMenominee(value: 'america/menominee'), + americaMerida(value: 'america/merida'), + americaMetlakatla(value: 'america/metlakatla'), + americaMexicoCity(value: 'america/mexico_city'), + americaMiquelon(value: 'america/miquelon'), + americaMoncton(value: 'america/moncton'), + americaMonterrey(value: 'america/monterrey'), + americaMontevideo(value: 'america/montevideo'), + americaMontserrat(value: 'america/montserrat'), + americaNassau(value: 'america/nassau'), + americaNewYork(value: 'america/new_york'), + americaNome(value: 'america/nome'), + americaNoronha(value: 'america/noronha'), + americaNorthDakotaBeulah(value: 'america/north_dakota/beulah'), + americaNorthDakotaCenter(value: 'america/north_dakota/center'), + americaNorthDakotaNewSalem(value: 'america/north_dakota/new_salem'), + americaNuuk(value: 'america/nuuk'), + americaOjinaga(value: 'america/ojinaga'), + americaPanama(value: 'america/panama'), + americaParamaribo(value: 'america/paramaribo'), + americaPhoenix(value: 'america/phoenix'), + americaPortAuPrince(value: 'america/port-au-prince'), + americaPortOfSpain(value: 'america/port_of_spain'), + americaPortoVelho(value: 'america/porto_velho'), + americaPuertoRico(value: 'america/puerto_rico'), + americaPuntaArenas(value: 'america/punta_arenas'), + americaRankinInlet(value: 'america/rankin_inlet'), + americaRecife(value: 'america/recife'), + americaRegina(value: 'america/regina'), + americaResolute(value: 'america/resolute'), + americaRioBranco(value: 'america/rio_branco'), + americaSantarem(value: 'america/santarem'), + americaSantiago(value: 'america/santiago'), + americaSantoDomingo(value: 'america/santo_domingo'), + americaSaoPaulo(value: 'america/sao_paulo'), + americaScoresbysund(value: 'america/scoresbysund'), + americaSitka(value: 'america/sitka'), + americaStBarthelemy(value: 'america/st_barthelemy'), + americaStJohns(value: 'america/st_johns'), + americaStKitts(value: 'america/st_kitts'), + americaStLucia(value: 'america/st_lucia'), + americaStThomas(value: 'america/st_thomas'), + americaStVincent(value: 'america/st_vincent'), + americaSwiftCurrent(value: 'america/swift_current'), + americaTegucigalpa(value: 'america/tegucigalpa'), + americaThule(value: 'america/thule'), + americaTijuana(value: 'america/tijuana'), + americaToronto(value: 'america/toronto'), + americaTortola(value: 'america/tortola'), + americaVancouver(value: 'america/vancouver'), + americaWhitehorse(value: 'america/whitehorse'), + americaWinnipeg(value: 'america/winnipeg'), + americaYakutat(value: 'america/yakutat'), + antarcticaCasey(value: 'antarctica/casey'), + antarcticaDavis(value: 'antarctica/davis'), + antarcticaDumontdurville(value: 'antarctica/dumontdurville'), + antarcticaMacquarie(value: 'antarctica/macquarie'), + antarcticaMawson(value: 'antarctica/mawson'), + antarcticaMcmurdo(value: 'antarctica/mcmurdo'), + antarcticaPalmer(value: 'antarctica/palmer'), + antarcticaRothera(value: 'antarctica/rothera'), + antarcticaSyowa(value: 'antarctica/syowa'), + antarcticaTroll(value: 'antarctica/troll'), + antarcticaVostok(value: 'antarctica/vostok'), + arcticLongyearbyen(value: 'arctic/longyearbyen'), + asiaAden(value: 'asia/aden'), + asiaAlmaty(value: 'asia/almaty'), + asiaAmman(value: 'asia/amman'), + asiaAnadyr(value: 'asia/anadyr'), + asiaAqtau(value: 'asia/aqtau'), + asiaAqtobe(value: 'asia/aqtobe'), + asiaAshgabat(value: 'asia/ashgabat'), + asiaAtyrau(value: 'asia/atyrau'), + asiaBaghdad(value: 'asia/baghdad'), + asiaBahrain(value: 'asia/bahrain'), + asiaBaku(value: 'asia/baku'), + asiaBangkok(value: 'asia/bangkok'), + asiaBarnaul(value: 'asia/barnaul'), + asiaBeirut(value: 'asia/beirut'), + asiaBishkek(value: 'asia/bishkek'), + asiaBrunei(value: 'asia/brunei'), + asiaChita(value: 'asia/chita'), + asiaColombo(value: 'asia/colombo'), + asiaDamascus(value: 'asia/damascus'), + asiaDhaka(value: 'asia/dhaka'), + asiaDili(value: 'asia/dili'), + asiaDubai(value: 'asia/dubai'), + asiaDushanbe(value: 'asia/dushanbe'), + asiaFamagusta(value: 'asia/famagusta'), + asiaGaza(value: 'asia/gaza'), + asiaHebron(value: 'asia/hebron'), + asiaHoChiMinh(value: 'asia/ho_chi_minh'), + asiaHongKong(value: 'asia/hong_kong'), + asiaHovd(value: 'asia/hovd'), + asiaIrkutsk(value: 'asia/irkutsk'), + asiaJakarta(value: 'asia/jakarta'), + asiaJayapura(value: 'asia/jayapura'), + asiaJerusalem(value: 'asia/jerusalem'), + asiaKabul(value: 'asia/kabul'), + asiaKamchatka(value: 'asia/kamchatka'), + asiaKarachi(value: 'asia/karachi'), + asiaKathmandu(value: 'asia/kathmandu'), + asiaKhandyga(value: 'asia/khandyga'), + asiaKolkata(value: 'asia/kolkata'), + asiaKrasnoyarsk(value: 'asia/krasnoyarsk'), + asiaKualaLumpur(value: 'asia/kuala_lumpur'), + asiaKuching(value: 'asia/kuching'), + asiaKuwait(value: 'asia/kuwait'), + asiaMacau(value: 'asia/macau'), + asiaMagadan(value: 'asia/magadan'), + asiaMakassar(value: 'asia/makassar'), + asiaManila(value: 'asia/manila'), + asiaMuscat(value: 'asia/muscat'), + asiaNicosia(value: 'asia/nicosia'), + asiaNovokuznetsk(value: 'asia/novokuznetsk'), + asiaNovosibirsk(value: 'asia/novosibirsk'), + asiaOmsk(value: 'asia/omsk'), + asiaOral(value: 'asia/oral'), + asiaPhnomPenh(value: 'asia/phnom_penh'), + asiaPontianak(value: 'asia/pontianak'), + asiaPyongyang(value: 'asia/pyongyang'), + asiaQatar(value: 'asia/qatar'), + asiaQostanay(value: 'asia/qostanay'), + asiaQyzylorda(value: 'asia/qyzylorda'), + asiaRiyadh(value: 'asia/riyadh'), + asiaSakhalin(value: 'asia/sakhalin'), + asiaSamarkand(value: 'asia/samarkand'), + asiaSeoul(value: 'asia/seoul'), + asiaShanghai(value: 'asia/shanghai'), + asiaSingapore(value: 'asia/singapore'), + asiaSrednekolymsk(value: 'asia/srednekolymsk'), + asiaTaipei(value: 'asia/taipei'), + asiaTashkent(value: 'asia/tashkent'), + asiaTbilisi(value: 'asia/tbilisi'), + asiaTehran(value: 'asia/tehran'), + asiaThimphu(value: 'asia/thimphu'), + asiaTokyo(value: 'asia/tokyo'), + asiaTomsk(value: 'asia/tomsk'), + asiaUlaanbaatar(value: 'asia/ulaanbaatar'), + asiaUrumqi(value: 'asia/urumqi'), + asiaUstNera(value: 'asia/ust-nera'), + asiaVientiane(value: 'asia/vientiane'), + asiaVladivostok(value: 'asia/vladivostok'), + asiaYakutsk(value: 'asia/yakutsk'), + asiaYangon(value: 'asia/yangon'), + asiaYekaterinburg(value: 'asia/yekaterinburg'), + asiaYerevan(value: 'asia/yerevan'), + atlanticAzores(value: 'atlantic/azores'), + atlanticBermuda(value: 'atlantic/bermuda'), + atlanticCanary(value: 'atlantic/canary'), + atlanticCapeVerde(value: 'atlantic/cape_verde'), + atlanticFaroe(value: 'atlantic/faroe'), + atlanticMadeira(value: 'atlantic/madeira'), + atlanticReykjavik(value: 'atlantic/reykjavik'), + atlanticSouthGeorgia(value: 'atlantic/south_georgia'), + atlanticStHelena(value: 'atlantic/st_helena'), + atlanticStanley(value: 'atlantic/stanley'), + australiaAdelaide(value: 'australia/adelaide'), + australiaBrisbane(value: 'australia/brisbane'), + australiaBrokenHill(value: 'australia/broken_hill'), + australiaDarwin(value: 'australia/darwin'), + australiaEucla(value: 'australia/eucla'), + australiaHobart(value: 'australia/hobart'), + australiaLindeman(value: 'australia/lindeman'), + australiaLordHowe(value: 'australia/lord_howe'), + australiaMelbourne(value: 'australia/melbourne'), + australiaPerth(value: 'australia/perth'), + australiaSydney(value: 'australia/sydney'), + europeAmsterdam(value: 'europe/amsterdam'), + europeAndorra(value: 'europe/andorra'), + europeAstrakhan(value: 'europe/astrakhan'), + europeAthens(value: 'europe/athens'), + europeBelgrade(value: 'europe/belgrade'), + europeBerlin(value: 'europe/berlin'), + europeBratislava(value: 'europe/bratislava'), + europeBrussels(value: 'europe/brussels'), + europeBucharest(value: 'europe/bucharest'), + europeBudapest(value: 'europe/budapest'), + europeBusingen(value: 'europe/busingen'), + europeChisinau(value: 'europe/chisinau'), + europeCopenhagen(value: 'europe/copenhagen'), + europeDublin(value: 'europe/dublin'), + europeGibraltar(value: 'europe/gibraltar'), + europeGuernsey(value: 'europe/guernsey'), + europeHelsinki(value: 'europe/helsinki'), + europeIsleOfMan(value: 'europe/isle_of_man'), + europeIstanbul(value: 'europe/istanbul'), + europeJersey(value: 'europe/jersey'), + europeKaliningrad(value: 'europe/kaliningrad'), + europeKirov(value: 'europe/kirov'), + europeKyiv(value: 'europe/kyiv'), + europeLisbon(value: 'europe/lisbon'), + europeLjubljana(value: 'europe/ljubljana'), + europeLondon(value: 'europe/london'), + europeLuxembourg(value: 'europe/luxembourg'), + europeMadrid(value: 'europe/madrid'), + europeMalta(value: 'europe/malta'), + europeMariehamn(value: 'europe/mariehamn'), + europeMinsk(value: 'europe/minsk'), + europeMonaco(value: 'europe/monaco'), + europeMoscow(value: 'europe/moscow'), + europeOslo(value: 'europe/oslo'), + europeParis(value: 'europe/paris'), + europePodgorica(value: 'europe/podgorica'), + europePrague(value: 'europe/prague'), + europeRiga(value: 'europe/riga'), + europeRome(value: 'europe/rome'), + europeSamara(value: 'europe/samara'), + europeSanMarino(value: 'europe/san_marino'), + europeSarajevo(value: 'europe/sarajevo'), + europeSaratov(value: 'europe/saratov'), + europeSimferopol(value: 'europe/simferopol'), + europeSkopje(value: 'europe/skopje'), + europeSofia(value: 'europe/sofia'), + europeStockholm(value: 'europe/stockholm'), + europeTallinn(value: 'europe/tallinn'), + europeTirane(value: 'europe/tirane'), + europeUlyanovsk(value: 'europe/ulyanovsk'), + europeVaduz(value: 'europe/vaduz'), + europeVatican(value: 'europe/vatican'), + europeVienna(value: 'europe/vienna'), + europeVilnius(value: 'europe/vilnius'), + europeVolgograd(value: 'europe/volgograd'), + europeWarsaw(value: 'europe/warsaw'), + europeZagreb(value: 'europe/zagreb'), + europeZurich(value: 'europe/zurich'), + indianAntananarivo(value: 'indian/antananarivo'), + indianChagos(value: 'indian/chagos'), + indianChristmas(value: 'indian/christmas'), + indianCocos(value: 'indian/cocos'), + indianComoro(value: 'indian/comoro'), + indianKerguelen(value: 'indian/kerguelen'), + indianMahe(value: 'indian/mahe'), + indianMaldives(value: 'indian/maldives'), + indianMauritius(value: 'indian/mauritius'), + indianMayotte(value: 'indian/mayotte'), + indianReunion(value: 'indian/reunion'), + pacificApia(value: 'pacific/apia'), + pacificAuckland(value: 'pacific/auckland'), + pacificBougainville(value: 'pacific/bougainville'), + pacificChatham(value: 'pacific/chatham'), + pacificChuuk(value: 'pacific/chuuk'), + pacificEaster(value: 'pacific/easter'), + pacificEfate(value: 'pacific/efate'), + pacificFakaofo(value: 'pacific/fakaofo'), + pacificFiji(value: 'pacific/fiji'), + pacificFunafuti(value: 'pacific/funafuti'), + pacificGalapagos(value: 'pacific/galapagos'), + pacificGambier(value: 'pacific/gambier'), + pacificGuadalcanal(value: 'pacific/guadalcanal'), + pacificGuam(value: 'pacific/guam'), + pacificHonolulu(value: 'pacific/honolulu'), + pacificKanton(value: 'pacific/kanton'), + pacificKiritimati(value: 'pacific/kiritimati'), + pacificKosrae(value: 'pacific/kosrae'), + pacificKwajalein(value: 'pacific/kwajalein'), + pacificMajuro(value: 'pacific/majuro'), + pacificMarquesas(value: 'pacific/marquesas'), + pacificMidway(value: 'pacific/midway'), + pacificNauru(value: 'pacific/nauru'), + pacificNiue(value: 'pacific/niue'), + pacificNorfolk(value: 'pacific/norfolk'), + pacificNoumea(value: 'pacific/noumea'), + pacificPagoPago(value: 'pacific/pago_pago'), + pacificPalau(value: 'pacific/palau'), + pacificPitcairn(value: 'pacific/pitcairn'), + pacificPohnpei(value: 'pacific/pohnpei'), + pacificPortMoresby(value: 'pacific/port_moresby'), + pacificRarotonga(value: 'pacific/rarotonga'), + pacificSaipan(value: 'pacific/saipan'), + pacificTahiti(value: 'pacific/tahiti'), + pacificTarawa(value: 'pacific/tarawa'), + pacificTongatapu(value: 'pacific/tongatapu'), + pacificWake(value: 'pacific/wake'), + pacificWallis(value: 'pacific/wallis'), + utc(value: 'utc'); - const Timezone({required this.value}); + const Timezone({ + 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 344a8770..f80fa854 100644 --- a/lib/src/models/algo_argon2.dart +++ b/lib/src/models/algo_argon2.dart @@ -2,41 +2,41 @@ 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'], + ); + } - @override - Map toMap() { - return { - "type": type, - "memoryCost": memoryCost, - "timeCost": timeCost, - "threads": threads, - }; - } + @override + 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 9909265e..c51da4bb 100644 --- a/lib/src/models/algo_bcrypt.dart +++ b/lib/src/models/algo_bcrypt.dart @@ -2,23 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return { - "type": type, - }; - } + @override + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_md5.dart b/lib/src/models/algo_md5.dart index 746fbd52..43523ab1 100644 --- a/lib/src/models/algo_md5.dart +++ b/lib/src/models/algo_md5.dart @@ -2,23 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return { - "type": type, - }; - } + @override + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_phpass.dart b/lib/src/models/algo_phpass.dart index cab45e49..8562c4e3 100644 --- a/lib/src/models/algo_phpass.dart +++ b/lib/src/models/algo_phpass.dart @@ -2,23 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return { - "type": type, - }; - } + @override + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_scrypt.dart b/lib/src/models/algo_scrypt.dart index a1648843..8e844839 100644 --- a/lib/src/models/algo_scrypt.dart +++ b/lib/src/models/algo_scrypt.dart @@ -2,47 +2,47 @@ 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'], - ); - } - - @override - 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'], + ); + } + + @override + 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 33ef4a6f..5202db05 100644 --- a/lib/src/models/algo_scrypt_modified.dart +++ b/lib/src/models/algo_scrypt_modified.dart @@ -2,41 +2,41 @@ 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(), + ); + } - @override - Map toMap() { - return { - "type": type, - "salt": salt, - "saltSeparator": saltSeparator, - "signerKey": signerKey, - }; - } + @override + 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 4984df75..3d08af9f 100644 --- a/lib/src/models/algo_sha.dart +++ b/lib/src/models/algo_sha.dart @@ -2,23 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return { - "type": type, - }; - } + @override + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/continent.dart b/lib/src/models/continent.dart index ec3c41be..930900bf 100644 --- a/lib/src/models/continent.dart +++ b/lib/src/models/continent.dart @@ -2,29 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return { - "name": name, - "code": code, - }; - } + @override + Map toMap() { + return { + "name": name, + "code": code, + }; + } } diff --git a/lib/src/models/continent_list.dart b/lib/src/models/continent_list.dart index df28f04b..753bcacc 100644 --- a/lib/src/models/continent_list.dart +++ b/lib/src/models/continent_list.dart @@ -2,30 +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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "continents": continents.map((p) => p.toMap()).toList(), - }; - } + @override + 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 3bcbb76d..c4838ba3 100644 --- a/lib/src/models/country.dart +++ b/lib/src/models/country.dart @@ -2,29 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return { - "name": name, - "code": code, - }; - } + @override + Map toMap() { + return { + "name": name, + "code": code, + }; + } } diff --git a/lib/src/models/country_list.dart b/lib/src/models/country_list.dart index 79cb1256..f363a54b 100644 --- a/lib/src/models/country_list.dart +++ b/lib/src/models/country_list.dart @@ -2,30 +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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "countries": countries.map((p) => p.toMap()).toList(), - }; - } + @override + 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 f2b18093..b6bb455f 100644 --- a/lib/src/models/currency.dart +++ b/lib/src/models/currency.dart @@ -2,59 +2,59 @@ 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(), - ); - } - - @override - 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(), + ); + } + + @override + 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 6c39ae2e..eb2bad19 100644 --- a/lib/src/models/currency_list.dart +++ b/lib/src/models/currency_list.dart @@ -2,30 +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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "currencies": currencies.map((p) => p.toMap()).toList(), - }; - } + @override + 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 be08d599..0d1fdeb0 100644 --- a/lib/src/models/document.dart +++ b/lib/src/models/document.dart @@ -2,66 +2,66 @@ part of '../../models.dart'; /// Document class Document implements Model { - /// Document ID. - final String $id; + /// Document ID. + final String $id; - /// Document sequence ID. - final String $sequence; + /// Document sequence ID. + final String $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'].toString(), - $collectionId: map['\$collectionId'].toString(), - $databaseId: map['\$databaseId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - data: map["data"] ?? map, - ); - } + factory Document.fromMap(Map map) { + return Document( + $id: map['\$id'].toString(), + $sequence: map['\$sequence'].toString(), + $collectionId: map['\$collectionId'].toString(), + $databaseId: map['\$databaseId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + data: map["data"] ?? map, + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$sequence": $sequence, - "\$collectionId": $collectionId, - "\$databaseId": $databaseId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "data": data, - }; - } + @override + 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 76a07309..0e30844a 100644 --- a/lib/src/models/document_list.dart +++ b/lib/src/models/document_list.dart @@ -2,33 +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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "documents": documents.map((p) => p.toMap()).toList(), - }; - } + @override + 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 3629e1d6..3e767ca3 100644 --- a/lib/src/models/execution.dart +++ b/lib/src/models/execution.dart @@ -2,129 +2,125 @@ 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 enums.ExecutionTrigger trigger; - - /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, `failed`, or `scheduled`. - final enums.ExecutionStatus status; - - /// HTTP request method type. - final String requestMethod; - - /// HTTP request path and query. - final String requestPath; - - /// HTTP request 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: enums.ExecutionTrigger.values - .firstWhere((e) => e.value == map['trigger']), - status: enums.ExecutionStatus.values - .firstWhere((e) => e.value == map['status']), - 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(), - ); - } - - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "functionId": functionId, - "deploymentId": deploymentId, - "trigger": trigger.value, - "status": status.value, - "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 enums.ExecutionTrigger trigger; + + /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, `failed`, or `scheduled`. + final enums.ExecutionStatus status; + + /// HTTP request method type. + final String requestMethod; + + /// HTTP request path and query. + final String requestPath; + + /// HTTP request 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: enums.ExecutionTrigger.values.firstWhere((e) => e.value == map['trigger']), + status: enums.ExecutionStatus.values.firstWhere((e) => e.value == map['status']), + 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(), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "functionId": functionId, + "deploymentId": deploymentId, + "trigger": trigger.value, + "status": status.value, + "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 63c2ad7e..45b60682 100644 --- a/lib/src/models/execution_list.dart +++ b/lib/src/models/execution_list.dart @@ -2,30 +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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "executions": executions.map((p) => p.toMap()).toList(), - }; - } + @override + 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 01cdcb3a..9e5f9eb1 100644 --- a/lib/src/models/file.dart +++ b/lib/src/models/file.dart @@ -2,101 +2,101 @@ part of '../../models.dart'; /// File class File implements Model { - /// File ID. - final String $id; - - /// Bucket ID. - final String bucketId; - - /// File creation date in ISO 8601 format. - final String $createdAt; - - /// 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 name. - final String name; - - /// File MD5 signature. - final String signature; - - /// File mime type. - final String mimeType; - - /// File original size in bytes. - final int sizeOriginal; - - /// File actual stored size in bytes after compression and/or encryption. - final int sizeActual; - - /// Total number of chunks available - final int chunksTotal; - - /// Total number of chunks uploaded - final int chunksUploaded; - - /// Whether file contents are encrypted at rest. - final bool encryption; - - /// Compression algorithm used for the file. Will be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd). - final String compression; - - 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.sizeActual, - required this.chunksTotal, - required this.chunksUploaded, - required this.encryption, - required this.compression, - }); - - 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'], - sizeActual: map['sizeActual'], - chunksTotal: map['chunksTotal'], - chunksUploaded: map['chunksUploaded'], - encryption: map['encryption'], - compression: map['compression'].toString(), - ); - } - - @override - Map toMap() { - return { - "\$id": $id, - "bucketId": bucketId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "name": name, - "signature": signature, - "mimeType": mimeType, - "sizeOriginal": sizeOriginal, - "sizeActual": sizeActual, - "chunksTotal": chunksTotal, - "chunksUploaded": chunksUploaded, - "encryption": encryption, - "compression": compression, - }; - } + /// File ID. + final String $id; + + /// Bucket ID. + final String bucketId; + + /// File creation date in ISO 8601 format. + final String $createdAt; + + /// 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 name. + final String name; + + /// File MD5 signature. + final String signature; + + /// File mime type. + final String mimeType; + + /// File original size in bytes. + final int sizeOriginal; + + /// File actual stored size in bytes after compression and/or encryption. + final int sizeActual; + + /// Total number of chunks available + final int chunksTotal; + + /// Total number of chunks uploaded + final int chunksUploaded; + + /// Whether file contents are encrypted at rest. + final bool encryption; + + /// Compression algorithm used for the file. Will be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd). + final String compression; + + 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.sizeActual, + required this.chunksTotal, + required this.chunksUploaded, + required this.encryption, + required this.compression, + }); + + 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'], + sizeActual: map['sizeActual'], + chunksTotal: map['chunksTotal'], + chunksUploaded: map['chunksUploaded'], + encryption: map['encryption'], + compression: map['compression'].toString(), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "bucketId": bucketId, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "name": name, + "signature": signature, + "mimeType": mimeType, + "sizeOriginal": sizeOriginal, + "sizeActual": sizeActual, + "chunksTotal": chunksTotal, + "chunksUploaded": chunksUploaded, + "encryption": encryption, + "compression": compression, + }; + } } diff --git a/lib/src/models/file_list.dart b/lib/src/models/file_list.dart index 1157554a..84c54b2e 100644 --- a/lib/src/models/file_list.dart +++ b/lib/src/models/file_list.dart @@ -2,29 +2,29 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "files": files.map((p) => p.toMap()).toList(), - }; - } + @override + 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 fa054420..bbccf88a 100644 --- a/lib/src/models/headers.dart +++ b/lib/src/models/headers.dart @@ -2,29 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return { - "name": name, - "value": value, - }; - } + @override + Map toMap() { + return { + "name": name, + "value": value, + }; + } } diff --git a/lib/src/models/identity.dart b/lib/src/models/identity.dart index cc659043..7e90020c 100644 --- a/lib/src/models/identity.dart +++ b/lib/src/models/identity.dart @@ -2,77 +2,77 @@ 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(), + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "userId": userId, - "provider": provider, - "providerUid": providerUid, - "providerEmail": providerEmail, - "providerAccessToken": providerAccessToken, - "providerAccessTokenExpiry": providerAccessTokenExpiry, - "providerRefreshToken": providerRefreshToken, - }; - } + @override + 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 a5d39ea0..d9cc09a2 100644 --- a/lib/src/models/identity_list.dart +++ b/lib/src/models/identity_list.dart @@ -2,30 +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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "identities": identities.map((p) => p.toMap()).toList(), - }; - } + @override + 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 cda66c70..2000acb6 100644 --- a/lib/src/models/jwt.dart +++ b/lib/src/models/jwt.dart @@ -2,23 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return { - "jwt": jwt, - }; - } + @override + Map toMap() { + return { + "jwt": jwt, + }; + } } diff --git a/lib/src/models/language.dart b/lib/src/models/language.dart index 87dc3606..1422d065 100644 --- a/lib/src/models/language.dart +++ b/lib/src/models/language.dart @@ -2,35 +2,35 @@ 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(), + ); + } - @override - Map toMap() { - return { - "name": name, - "code": code, - "nativeName": nativeName, - }; - } + @override + 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 6198d61e..5d78a367 100644 --- a/lib/src/models/language_list.dart +++ b/lib/src/models/language_list.dart @@ -2,30 +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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "languages": languages.map((p) => p.toMap()).toList(), - }; - } + @override + 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 54dd0c29..3292a896 100644 --- a/lib/src/models/locale.dart +++ b/lib/src/models/locale.dart @@ -2,59 +2,59 @@ 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(), - ); - } - - @override - 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(), + ); + } + + @override + 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 21405aff..49ef3b0b 100644 --- a/lib/src/models/locale_code.dart +++ b/lib/src/models/locale_code.dart @@ -2,29 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return { - "code": code, - "name": name, - }; - } + @override + 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 202355a4..a3a26b61 100644 --- a/lib/src/models/locale_code_list.dart +++ b/lib/src/models/locale_code_list.dart @@ -2,30 +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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "localeCodes": localeCodes.map((p) => p.toMap()).toList(), - }; - } + @override + 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 572cce50..406fcbcf 100644 --- a/lib/src/models/log.dart +++ b/lib/src/models/log.dart @@ -2,149 +2,149 @@ part of '../../models.dart'; /// Log class Log implements Model { - /// Event name. - final String event; - - /// User ID of the actor recorded for this log. During impersonation, this is the original impersonator, not the impersonated target user. - final String userId; - - /// User email of the actor recorded for this log. During impersonation, this is the original impersonator. - final String userEmail; - - /// User name of the actor recorded for this log. During impersonation, this is the original impersonator. - final String userName; - - /// API mode when event triggered. - final String mode; - - /// User type who triggered the audit log. Possible values: user, admin, guest, keyProject, keyAccount, keyOrganization. - final String userType; - - /// 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.userType, - 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(), - userType: map['userType'].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(), - ); - } - - @override - Map toMap() { - return { - "event": event, - "userId": userId, - "userEmail": userEmail, - "userName": userName, - "mode": mode, - "userType": userType, - "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 of the actor recorded for this log. During impersonation, this is the original impersonator, not the impersonated target user. + final String userId; + + /// User email of the actor recorded for this log. During impersonation, this is the original impersonator. + final String userEmail; + + /// User name of the actor recorded for this log. During impersonation, this is the original impersonator. + final String userName; + + /// API mode when event triggered. + final String mode; + + /// User type who triggered the audit log. Possible values: user, admin, guest, keyProject, keyAccount, keyOrganization. + final String userType; + + /// 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.userType, + 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(), + userType: map['userType'].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(), + ); + } + + @override + Map toMap() { + return { + "event": event, + "userId": userId, + "userEmail": userEmail, + "userName": userName, + "mode": mode, + "userType": userType, + "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 3494b111..ebf593c2 100644 --- a/lib/src/models/log_list.dart +++ b/lib/src/models/log_list.dart @@ -2,29 +2,29 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "logs": logs.map((p) => p.toMap()).toList(), - }; - } + @override + 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 4d8a2f9b..4baffb71 100644 --- a/lib/src/models/membership.dart +++ b/lib/src/models/membership.dart @@ -2,107 +2,107 @@ 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; - - /// User phone number. Hide this attribute by toggling membership privacy in the Console. - final String userPhone; - - /// 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; - - /// Most recent access date in ISO 8601 format. Show this attribute by toggling membership privacy in the Console. - final String userAccessedAt; - - /// 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.userPhone, - required this.teamId, - required this.teamName, - required this.invited, - required this.joined, - required this.confirm, - required this.mfa, - required this.userAccessedAt, - 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(), - userPhone: map['userPhone'].toString(), - teamId: map['teamId'].toString(), - teamName: map['teamName'].toString(), - invited: map['invited'].toString(), - joined: map['joined'].toString(), - confirm: map['confirm'], - mfa: map['mfa'], - userAccessedAt: map['userAccessedAt'].toString(), - roles: List.from(map['roles'] ?? []), - ); - } - - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "userId": userId, - "userName": userName, - "userEmail": userEmail, - "userPhone": userPhone, - "teamId": teamId, - "teamName": teamName, - "invited": invited, - "joined": joined, - "confirm": confirm, - "mfa": mfa, - "userAccessedAt": userAccessedAt, - "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; + + /// User phone number. Hide this attribute by toggling membership privacy in the Console. + final String userPhone; + + /// 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; + + /// Most recent access date in ISO 8601 format. Show this attribute by toggling membership privacy in the Console. + final String userAccessedAt; + + /// 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.userPhone, + required this.teamId, + required this.teamName, + required this.invited, + required this.joined, + required this.confirm, + required this.mfa, + required this.userAccessedAt, + 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(), + userPhone: map['userPhone'].toString(), + teamId: map['teamId'].toString(), + teamName: map['teamName'].toString(), + invited: map['invited'].toString(), + joined: map['joined'].toString(), + confirm: map['confirm'], + mfa: map['mfa'], + userAccessedAt: map['userAccessedAt'].toString(), + roles: List.from(map['roles'] ?? []), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "userId": userId, + "userName": userName, + "userEmail": userEmail, + "userPhone": userPhone, + "teamId": teamId, + "teamName": teamName, + "invited": invited, + "joined": joined, + "confirm": confirm, + "mfa": mfa, + "userAccessedAt": userAccessedAt, + "roles": roles, + }; + } } diff --git a/lib/src/models/membership_list.dart b/lib/src/models/membership_list.dart index cc664c9f..a0641a28 100644 --- a/lib/src/models/membership_list.dart +++ b/lib/src/models/membership_list.dart @@ -2,30 +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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "memberships": memberships.map((p) => p.toMap()).toList(), - }; - } + @override + 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 fa385541..3d2e2335 100644 --- a/lib/src/models/mfa_challenge.dart +++ b/lib/src/models/mfa_challenge.dart @@ -2,41 +2,41 @@ 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(), + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "userId": userId, - "expire": expire, - }; - } + @override + 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 2777de7f..a7e5fefc 100644 --- a/lib/src/models/mfa_factors.dart +++ b/lib/src/models/mfa_factors.dart @@ -2,41 +2,41 @@ 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'], + ); + } - @override - Map toMap() { - return { - "totp": totp, - "phone": phone, - "email": email, - "recoveryCode": recoveryCode, - }; - } + @override + 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 864a5db8..33036476 100644 --- a/lib/src/models/mfa_recovery_codes.dart +++ b/lib/src/models/mfa_recovery_codes.dart @@ -2,23 +2,23 @@ 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'] ?? []), + ); + } - @override - Map toMap() { - return { - "recoveryCodes": recoveryCodes, - }; - } + @override + Map toMap() { + return { + "recoveryCodes": recoveryCodes, + }; + } } diff --git a/lib/src/models/mfa_type.dart b/lib/src/models/mfa_type.dart index fe5327fc..05cab363 100644 --- a/lib/src/models/mfa_type.dart +++ b/lib/src/models/mfa_type.dart @@ -2,29 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return { - "secret": secret, - "uri": uri, - }; - } + @override + 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 60e2abd9..7ac578e2 100644 --- a/lib/src/models/phone.dart +++ b/lib/src/models/phone.dart @@ -2,35 +2,35 @@ 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(), + ); + } - @override - Map toMap() { - return { - "code": code, - "countryCode": countryCode, - "countryName": countryName, - }; - } + @override + 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 1a197fc7..9791d590 100644 --- a/lib/src/models/phone_list.dart +++ b/lib/src/models/phone_list.dart @@ -2,29 +2,29 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "phones": phones.map((p) => p.toMap()).toList(), - }; - } + @override + 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 3ca04118..b107afe5 100644 --- a/lib/src/models/preferences.dart +++ b/lib/src/models/preferences.dart @@ -2,24 +2,24 @@ 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["data"] ?? map, - ); - } + factory Preferences.fromMap(Map map) { + return Preferences( + data: map["data"] ?? map, + ); + } - @override - Map toMap() { - return { - "data": data, - }; - } + @override + 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/presence.dart b/lib/src/models/presence.dart index d31911de..133fe66d 100644 --- a/lib/src/models/presence.dart +++ b/lib/src/models/presence.dart @@ -2,71 +2,71 @@ part of '../../models.dart'; /// Presence class Presence implements Model { - /// Presence ID. - final String $id; + /// Presence ID. + final String $id; - /// Presence creation date in ISO 8601 format. - final String $createdAt; + /// Presence creation date in ISO 8601 format. + final String $createdAt; - /// Presence update date in ISO 8601 format. - final String $updatedAt; + /// Presence update date in ISO 8601 format. + final String $updatedAt; - /// Presence permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; + /// Presence permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Presence status. - final String? status; + /// Presence status. + final String? status; - /// Presence source. - final String source; + /// Presence source. + final String source; - /// Presence expiry date in ISO 8601 format. - final String? expiresAt; + /// Presence expiry date in ISO 8601 format. + final String? expiresAt; - /// Presence metadata. - final Map? metadata; + /// Presence metadata. + final Map? metadata; - Presence({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.userId, - this.status, - required this.source, - this.expiresAt, - this.metadata, - }); + Presence({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.userId, + this.status, + required this.source, + this.expiresAt, + this.metadata, + }); - factory Presence.fromMap(Map map) { - return Presence( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - userId: map['userId'].toString(), - status: map['status']?.toString(), - source: map['source'].toString(), - expiresAt: map['expiresAt']?.toString(), - metadata: map['metadata'], - ); - } + factory Presence.fromMap(Map map) { + return Presence( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + userId: map['userId'].toString(), + status: map['status']?.toString(), + source: map['source'].toString(), + expiresAt: map['expiresAt']?.toString(), + metadata: map['metadata'], + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "userId": userId, - "status": status, - "source": source, - "expiresAt": expiresAt, - "metadata": metadata, - }; - } + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "userId": userId, + "status": status, + "source": source, + "expiresAt": expiresAt, + "metadata": metadata, + }; + } } diff --git a/lib/src/models/presence_list.dart b/lib/src/models/presence_list.dart index 3d010b1c..aebbe880 100644 --- a/lib/src/models/presence_list.dart +++ b/lib/src/models/presence_list.dart @@ -2,30 +2,29 @@ part of '../../models.dart'; /// Presences List class PresenceList implements Model { - /// Total number of presences that matched your query. - final int total; + /// Total number of presences that matched your query. + final int total; - /// List of presences. - final List presences; + /// List of presences. + final List presences; - PresenceList({ - required this.total, - required this.presences, - }); + PresenceList({ + required this.total, + required this.presences, + }); - factory PresenceList.fromMap(Map map) { - return PresenceList( - total: map['total'], - presences: - List.from(map['presences'].map((p) => Presence.fromMap(p))), - ); - } + factory PresenceList.fromMap(Map map) { + return PresenceList( + total: map['total'], + presences: List.from(map['presences'].map((p) => Presence.fromMap(p))), + ); + } - @override - Map toMap() { - return { - "total": total, - "presences": presences.map((p) => p.toMap()).toList(), - }; - } + @override + Map toMap() { + return { + "total": total, + "presences": presences.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/row.dart b/lib/src/models/row.dart index a825eab0..c5f233b4 100644 --- a/lib/src/models/row.dart +++ b/lib/src/models/row.dart @@ -2,66 +2,66 @@ part of '../../models.dart'; /// Row class Row implements Model { - /// Row ID. - final String $id; + /// Row ID. + final String $id; - /// Row sequence ID. - final String $sequence; + /// Row sequence ID. + final String $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'].toString(), - $tableId: map['\$tableId'].toString(), - $databaseId: map['\$databaseId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - data: map["data"] ?? map, - ); - } + factory Row.fromMap(Map map) { + return Row( + $id: map['\$id'].toString(), + $sequence: map['\$sequence'].toString(), + $tableId: map['\$tableId'].toString(), + $databaseId: map['\$databaseId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + data: map["data"] ?? map, + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$sequence": $sequence, - "\$tableId": $tableId, - "\$databaseId": $databaseId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "data": data, - }; - } + @override + 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 5023c633..90efa95f 100644 --- a/lib/src/models/row_list.dart +++ b/lib/src/models/row_list.dart @@ -2,32 +2,32 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "rows": rows.map((p) => p.toMap()).toList(), - }; - } + @override + 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 92e4034e..c37de95a 100644 --- a/lib/src/models/session.dart +++ b/lib/src/models/session.dart @@ -2,191 +2,191 @@ 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(), - ); - } - - @override - 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(), + ); + } + + @override + 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 4ea12394..d823d0e6 100644 --- a/lib/src/models/session_list.dart +++ b/lib/src/models/session_list.dart @@ -2,30 +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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "sessions": sessions.map((p) => p.toMap()).toList(), - }; - } + @override + 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 450aafd1..850ab8d2 100644 --- a/lib/src/models/subscriber.dart +++ b/lib/src/models/subscriber.dart @@ -2,71 +2,71 @@ 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(), + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "targetId": targetId, - "target": target.toMap(), - "userId": userId, - "userName": userName, - "topicId": topicId, - "providerType": providerType, - }; - } + @override + 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 c2e8c4dc..742e7590 100644 --- a/lib/src/models/target.dart +++ b/lib/src/models/target.dart @@ -2,71 +2,71 @@ 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'], + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "userId": userId, - "providerId": providerId, - "providerType": providerType, - "identifier": identifier, - "expired": expired, - }; - } + @override + 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 91b888b9..21e65e95 100644 --- a/lib/src/models/team.dart +++ b/lib/src/models/team.dart @@ -2,53 +2,53 @@ 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']), - ); - } - - @override - 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']), + ); + } + + @override + 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 e8f1c621..ffca5e98 100644 --- a/lib/src/models/team_list.dart +++ b/lib/src/models/team_list.dart @@ -2,29 +2,29 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "teams": teams.map((p) => p.toMap()).toList(), - }; - } + @override + 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 b5ea87c8..b05320da 100644 --- a/lib/src/models/token.dart +++ b/lib/src/models/token.dart @@ -2,53 +2,53 @@ 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(), - ); - } - - @override - 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(), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "userId": userId, + "secret": secret, + "expire": expire, + "phrase": phrase, + }; + } } diff --git a/lib/src/models/transaction.dart b/lib/src/models/transaction.dart index b0606dd8..e3f3e43d 100644 --- a/lib/src/models/transaction.dart +++ b/lib/src/models/transaction.dart @@ -2,53 +2,53 @@ part of '../../models.dart'; /// Transaction class Transaction implements Model { - /// Transaction ID. - final String $id; - - /// Transaction creation time in ISO 8601 format. - final String $createdAt; - - /// Transaction update date in ISO 8601 format. - final String $updatedAt; - - /// Current status of the transaction. One of: pending, committing, committed, rolled_back, failed. - final String status; - - /// Number of operations in the transaction. - final int operations; - - /// Expiration time in ISO 8601 format. - final String expiresAt; - - Transaction({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.status, - required this.operations, - required this.expiresAt, - }); - - factory Transaction.fromMap(Map map) { - return Transaction( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - status: map['status'].toString(), - operations: map['operations'], - expiresAt: map['expiresAt'].toString(), - ); - } - - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "status": status, - "operations": operations, - "expiresAt": expiresAt, - }; - } + /// Transaction ID. + final String $id; + + /// Transaction creation time in ISO 8601 format. + final String $createdAt; + + /// Transaction update date in ISO 8601 format. + final String $updatedAt; + + /// Current status of the transaction. One of: pending, committing, committed, rolled_back, failed. + final String status; + + /// Number of operations in the transaction. + final int operations; + + /// Expiration time in ISO 8601 format. + final String expiresAt; + + Transaction({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.status, + required this.operations, + required this.expiresAt, + }); + + factory Transaction.fromMap(Map map) { + return Transaction( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + status: map['status'].toString(), + operations: map['operations'], + expiresAt: map['expiresAt'].toString(), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "status": status, + "operations": operations, + "expiresAt": expiresAt, + }; + } } diff --git a/lib/src/models/transaction_list.dart b/lib/src/models/transaction_list.dart index 7f321175..19ea651d 100644 --- a/lib/src/models/transaction_list.dart +++ b/lib/src/models/transaction_list.dart @@ -2,30 +2,29 @@ part of '../../models.dart'; /// Transaction List class TransactionList implements Model { - /// Total number of transactions that matched your query. - final int total; + /// Total number of transactions that matched your query. + final int total; - /// List of transactions. - final List transactions; + /// List of transactions. + final List transactions; - TransactionList({ - required this.total, - required this.transactions, - }); + TransactionList({ + required this.total, + required this.transactions, + }); - factory TransactionList.fromMap(Map map) { - return TransactionList( - total: map['total'], - transactions: List.from( - map['transactions'].map((p) => Transaction.fromMap(p))), - ); - } + factory TransactionList.fromMap(Map map) { + return TransactionList( + total: map['total'], + transactions: List.from(map['transactions'].map((p) => Transaction.fromMap(p))), + ); + } - @override - Map toMap() { - return { - "total": total, - "transactions": transactions.map((p) => p.toMap()).toList(), - }; - } + @override + Map toMap() { + return { + "total": total, + "transactions": transactions.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/user.dart b/lib/src/models/user.dart index 5a6cad30..e3b9536b 100644 --- a/lib/src/models/user.dart +++ b/lib/src/models/user.dart @@ -2,173 +2,173 @@ part of '../../models.dart'; /// User class User implements Model { - /// User ID. - final String $id; + /// User ID. + final String $id; - /// User creation date in ISO 8601 format. - final String $createdAt; + /// User creation date in ISO 8601 format. + final String $createdAt; - /// User update date in ISO 8601 format. - final String $updatedAt; + /// 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; - - /// Canonical form of the user email address. - final String? emailCanonical; - - /// Whether the user email is from a free email provider. - final bool? emailIsFree; - - /// Whether the user email is from a disposable email provider. - final bool? emailIsDisposable; - - /// Whether the user email is from a corporate domain. - final bool? emailIsCorporate; - - /// Whether the user email is in its canonical form. - final bool? emailIsCanonical; - - /// 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; - - /// Whether the user can impersonate other users. - final bool? impersonator; - - /// ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data. - final String? impersonatorUserId; - - 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, - this.emailCanonical, - this.emailIsFree, - this.emailIsDisposable, - this.emailIsCorporate, - this.emailIsCanonical, - required this.phoneVerification, - required this.mfa, - required this.prefs, - required this.targets, - required this.accessedAt, - this.impersonator, - this.impersonatorUserId, - }); - - 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'], - emailCanonical: map['emailCanonical']?.toString(), - emailIsFree: map['emailIsFree'], - emailIsDisposable: map['emailIsDisposable'], - emailIsCorporate: map['emailIsCorporate'], - emailIsCanonical: map['emailIsCanonical'], - 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(), - impersonator: map['impersonator'], - impersonatorUserId: map['impersonatorUserId']?.toString(), - ); - } - - @override - 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, - "emailCanonical": emailCanonical, - "emailIsFree": emailIsFree, - "emailIsDisposable": emailIsDisposable, - "emailIsCorporate": emailIsCorporate, - "emailIsCanonical": emailIsCanonical, - "phoneVerification": phoneVerification, - "mfa": mfa, - "prefs": prefs.toMap(), - "targets": targets.map((p) => p.toMap()).toList(), - "accessedAt": accessedAt, - "impersonator": impersonator, - "impersonatorUserId": impersonatorUserId, - }; - } + /// 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; + + /// Canonical form of the user email address. + final String? emailCanonical; + + /// Whether the user email is from a free email provider. + final bool? emailIsFree; + + /// Whether the user email is from a disposable email provider. + final bool? emailIsDisposable; + + /// Whether the user email is from a corporate domain. + final bool? emailIsCorporate; + + /// Whether the user email is in its canonical form. + final bool? emailIsCanonical; + + /// 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; + + /// Whether the user can impersonate other users. + final bool? impersonator; + + /// ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data. + final String? impersonatorUserId; + + 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, + this.emailCanonical, + this.emailIsFree, + this.emailIsDisposable, + this.emailIsCorporate, + this.emailIsCanonical, + required this.phoneVerification, + required this.mfa, + required this.prefs, + required this.targets, + required this.accessedAt, + this.impersonator, + this.impersonatorUserId, + }); + + 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'], + emailCanonical: map['emailCanonical']?.toString(), + emailIsFree: map['emailIsFree'], + emailIsDisposable: map['emailIsDisposable'], + emailIsCorporate: map['emailIsCorporate'], + emailIsCanonical: map['emailIsCanonical'], + 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(), + impersonator: map['impersonator'], + impersonatorUserId: map['impersonatorUserId']?.toString(), + ); + } + + @override + 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, + "emailCanonical": emailCanonical, + "emailIsFree": emailIsFree, + "emailIsDisposable": emailIsDisposable, + "emailIsCorporate": emailIsCorporate, + "emailIsCanonical": emailIsCanonical, + "phoneVerification": phoneVerification, + "mfa": mfa, + "prefs": prefs.toMap(), + "targets": targets.map((p) => p.toMap()).toList(), + "accessedAt": accessedAt, + "impersonator": impersonator, + "impersonatorUserId": impersonatorUserId, + }; + } } diff --git a/lib/src/realtime.dart b/lib/src/realtime.dart index 28e4c43d..7a5e6303 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(); /// ``` - /// + /// /// You can also use Channel builders: /// ```dart /// final subscription = realtime.subscribe([ diff --git a/lib/src/realtime_io.dart b/lib/src/realtime_io.dart index 0ed367a6..83f01b4c 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) { 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 72edf5ee..6cebb5b1 100644 --- a/lib/src/realtime_mixin.dart +++ b/lib/src/realtime_mixin.dart @@ -58,7 +58,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" + })); } }); } @@ -138,11 +140,9 @@ mixin RealtimeMixin { case 'event': final messageData = data.data as Map; final message = RealtimeMessage.fromMap(messageData); - final subscriptions = - (messageData['subscriptions'] as List?) - ?.map((x) => x.toString()) - .toList() ?? - []; + final subscriptions = (messageData['subscriptions'] as List?) + ?.map((x) => x.toString()) + .toList() ?? []; if (subscriptions.isEmpty) { break; @@ -209,15 +209,13 @@ mixin RealtimeMixin { "Please set endPointRealtime to connect to realtime server"); } var uri = Uri.parse(client.endPointRealtime!); - - var queryParams = - "project=${Uri.encodeComponent(client.config['project']!)}"; + + var queryParams = "project=${Uri.encodeComponent(client.config['project']!)}"; final portPart = (uri.hasPort && uri.port != 80 && uri.port != 443) ? ':${uri.port}' : ''; - return Uri.parse( - "${uri.scheme}://${uri.host}$portPart${uri.path}/realtime?$queryParams"); + return Uri.parse("${uri.scheme}://${uri.host}$portPart${uri.path}/realtime?$queryParams"); } void _sendUnsubscribeMessage(List subscriptionIds) { @@ -312,11 +310,9 @@ mixin RealtimeMixin { return channel is String ? channel : channel.toString(); } - RealtimeSubscription subscribeTo(List channels, - [List queries = const []]) { + RealtimeSubscription subscribeTo(List channels, [List queries = const []]) { StreamController controller = StreamController.broadcast(); - final channelStrings = - channels.map((ch) => _channelToString(ch)).toList().cast(); + final channelStrings = channels.map((ch) => _channelToString(ch)).toList().cast(); final queryStrings = List.from(queries); final subscriptionId = _generateUniqueSubscriptionId(); @@ -333,7 +329,8 @@ mixin RealtimeMixin { _sendUnsubscribeMessage([subscriptionId]); } - Future update({List? channels, List? queries}) async { + Future update( + {List? channels, List? queries}) async { final current = _subscriptions[subscriptionId]; if (current == null) { return; @@ -420,4 +417,4 @@ mixin RealtimeMixin { // until the application-level handshake completes. _flushPendingPresence(); } -} +} \ No newline at end of file diff --git a/lib/src/realtime_response.dart b/lib/src/realtime_response.dart index b0356111..56e7669a 100644 --- a/lib/src/realtime_response.dart +++ b/lib/src/realtime_response.dart @@ -8,6 +8,7 @@ class RealtimeResponse { required this.type, required this.data, }); + RealtimeResponse copyWith({ String? type, @@ -35,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)'; @@ -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 diff --git a/lib/src/realtime_stub.dart b/lib/src/realtime_stub.dart index 3aab4e03..ce0b7e95 100644 --- a/lib/src/realtime_stub.dart +++ b/lib/src/realtime_stub.dart @@ -3,5 +3,5 @@ import 'client.dart'; /// Implemented in `realtime_browser.dart` and `realtime_io.dart`. RealtimeBase createRealtime(Client client) => throw UnsupportedError( - 'Cannot create a client without dart:html or dart:io.', - ); + 'Cannot create a client without dart:html or dart:io.', +); diff --git a/test/channel_test.dart b/test/channel_test.dart index 9e0e11d3..62031aec 100644 --- a/test/channel_test.dart +++ b/test/channel_test.dart @@ -13,22 +13,12 @@ void main() { }); test('returns database channel with action', () { - expect( - Channel.database('db1') - .collection('col1') - .document('doc1') - .create() - .toString(), + expect(Channel.database('db1').collection('col1').document('doc1').create().toString(), 'databases.db1.collections.col1.documents.doc1.create'); }); test('returns database channel with upsert action', () { - expect( - Channel.database('db1') - .collection('col1') - .document('doc1') - .upsert() - .toString(), + expect(Channel.database('db1').collection('col1').document('doc1').upsert().toString(), 'databases.db1.collections.col1.documents.doc1.upsert'); }); }); @@ -44,12 +34,7 @@ void main() { }); test('returns tablesdb channel with action', () { - expect( - Channel.tablesdb('db1') - .table('table1') - .row('row1') - .update() - .toString(), + expect(Channel.tablesdb('db1').table('table1').row('row1').update().toString(), 'tablesdb.db1.tables.table1.rows.row1.update'); }); }); @@ -62,16 +47,16 @@ void main() { group('bucket()', () { test('throws when bucket id is missing', () { - expect(() => Channel.bucket(''), throwsArgumentError); + expect(() => Channel.bucket(''), throwsArgumentError); }); test('returns buckets channel with specific IDs', () { - expect( - Channel.bucket('bucket1').file().toString(), 'buckets.bucket1.files'); + expect(Channel.bucket('bucket1').file().toString(), + 'buckets.bucket1.files'); }); test('returns buckets channel with action', () { - expect(Channel.bucket('bucket1').file('file1').delete().toString(), + expect(Channel.bucket('bucket1').file('file1').delete().toString(), 'buckets.bucket1.files.file1.delete'); }); }); @@ -98,30 +83,29 @@ void main() { group('teams()', () { test('throws when team id is missing', () { - expect(() => Channel.team(''), throwsArgumentError); + expect(() => Channel.team(''), throwsArgumentError); }); test('returns teams channel with specific team ID', () { - expect(Channel.team('team1').toString(), 'teams.team1'); + expect(Channel.team('team1').toString(), 'teams.team1'); }); test('returns teams channel with action', () { - expect(Channel.team('team1').create().toString(), 'teams.team1.create'); + expect(Channel.team('team1').create().toString(), 'teams.team1.create'); }); }); group('memberships()', () { test('throws when membership id is missing', () { - expect(() => Channel.membership(''), throwsArgumentError); + expect(() => Channel.membership(''), throwsArgumentError); }); test('returns memberships channel with specific membership ID', () { - expect(Channel.membership('membership1').toString(), - 'memberships.membership1'); + expect(Channel.membership('membership1').toString(), 'memberships.membership1'); }); test('returns memberships channel with action', () { - expect(Channel.membership('membership1').update().toString(), + expect(Channel.membership('membership1').update().toString(), 'memberships.membership1.update'); }); }); diff --git a/test/query_test.dart b/test/query_test.dart index db7b9214..25388fad 100644 --- a/test/query_test.dart +++ b/test/query_test.dart @@ -354,3 +354,4 @@ void main() { expect(query['method'], 'between'); }); } + diff --git a/test/services/account_test.dart b/test/services/account_test.dart index d5d61fe7..bd65aa32 100644 --- a/test/services/account_test.dart +++ b/test/services/account_test.dart @@ -24,11 +24,12 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -40,1356 +41,1540 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method( - #chunkedUpload, [path, params, paramName, idParamName, headers]), - returnValue: Response(data: {})); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Account test', () { - late MockClient client; - late Account account; + group('Account test', () { + late MockClient client; + late Account account; + + setUp(() { + client = MockClient(); + account = Account(client); + }); + + test('test method get()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.get( + ); + expect(response, isA()); - setUp(() { - client = MockClient(); - account = Account(client); - }); + }); + + test('test method create()', () async { - test('test method get()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.get(); - expect(response, isA()); - }); + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - test('test method create()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.create( - userId: '', - email: 'email@example.com', - password: 'password', - ); - expect(response, isA()); - }); - test('test method updateEmail()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateEmail( - email: 'email@example.com', - password: 'password', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - test('test method listIdentities()', () async { - final Map data = { - 'total': 5, - 'identities': [], - }; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final response = await account.create( + userId: '', + email: 'email@example.com', + password: 'password', + ); + expect(response, isA()); - final response = await account.listIdentities(); - expect(response, isA()); - }); + }); - test('test method deleteIdentity()', () async { - final data = ''; + test('test method updateEmail()', () async { - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - final response = await account.deleteIdentity( - identityId: '', - ); - }); - test('test method createJWT()', () async { - final Map data = { - 'jwt': - 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', - }; + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - final response = await account.createJWT(); - expect(response, isA()); - }); + final response = await account.updateEmail( + email: 'email@example.com', + password: 'password', + ); + expect(response, isA()); - test('test method listLogs()', () async { - final Map data = { - 'total': 5, - 'logs': [], - }; + }); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + test('test method listIdentities()', () async { - final response = await account.listLogs(); - expect(response, isA()); - }); + final Map data = { + 'total': 5, + 'identities': [],}; - test('test method updateMFA()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateMFA( - mfa: true, - ); - expect(response, isA()); - }); - test('test method createMfaAuthenticator()', () async { - final Map data = { - 'secret': '[SHARED_SECRET]', - 'uri': - 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createMfaAuthenticator( - type: enums.AuthenticatorType.totp, - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method createMFAAuthenticator()', () async { - final Map data = { - 'secret': '[SHARED_SECRET]', - 'uri': - 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createMFAAuthenticator( - type: enums.AuthenticatorType.totp, - ); - expect(response, isA()); - }); - test('test method updateMfaAuthenticator()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateMfaAuthenticator( - type: enums.AuthenticatorType.totp, - otp: '', - ); - expect(response, isA()); - }); + final response = await account.listIdentities( + ); + expect(response, isA()); - test('test method updateMFAAuthenticator()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateMFAAuthenticator( - type: enums.AuthenticatorType.totp, - otp: '', - ); - expect(response, isA()); - }); + }); - test('test method deleteMfaAuthenticator()', () async { - final data = ''; + test('test method deleteIdentity()', () async { - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + final data = ''; - final response = await account.deleteMfaAuthenticator( - type: enums.AuthenticatorType.totp, - ); - }); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - test('test method deleteMFAAuthenticator()', () async { - final data = ''; - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + final response = await account.deleteIdentity( + identityId: '', + ); + }); - final response = await account.deleteMFAAuthenticator( - type: enums.AuthenticatorType.totp, - ); - }); + test('test method createJWT()', () async { - test('test method createMfaChallenge()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'expire': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createMfaChallenge( - factor: enums.AuthenticationFactor.email, - ); - expect(response, isA()); - }); + final Map data = { + 'jwt': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c',}; - test('test method createMFAChallenge()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'expire': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createMFAChallenge( - factor: enums.AuthenticationFactor.email, - ); - expect(response, isA()); - }); - test('test method updateMfaChallenge()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateMfaChallenge( - challengeId: '', - otp: '', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - test('test method updateMFAChallenge()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateMFAChallenge( - challengeId: '', - otp: '', - ); - expect(response, isA()); - }); - test('test method listMfaFactors()', () async { - final Map data = { - 'totp': true, - 'phone': true, - 'email': true, - 'recoveryCode': true, - }; + final response = await account.createJWT( + ); + expect(response, isA()); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + }); - final response = await account.listMfaFactors(); - expect(response, isA()); - }); + test('test method listLogs()', () async { - test('test method listMFAFactors()', () async { - final Map data = { - 'totp': true, - 'phone': true, - 'email': true, - 'recoveryCode': true, - }; + final Map data = { + 'total': 5, + 'logs': [],}; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - final response = await account.listMFAFactors(); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method getMfaRecoveryCodes()', () async { - final Map data = { - 'recoveryCodes': [], - }; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final response = await account.listLogs( + ); + expect(response, isA()); - final response = await account.getMfaRecoveryCodes(); - expect(response, isA()); - }); + }); - test('test method getMFARecoveryCodes()', () async { - final Map data = { - 'recoveryCodes': [], - }; + test('test method updateMFA()', () async { - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - final response = await account.getMFARecoveryCodes(); - expect(response, isA()); - }); - test('test method createMfaRecoveryCodes()', () async { - final Map data = { - 'recoveryCodes': [], - }; + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - final response = await account.createMfaRecoveryCodes(); - expect(response, isA()); - }); + final response = await account.updateMFA( + mfa: true, + ); + expect(response, isA()); - test('test method createMFARecoveryCodes()', () async { - final Map data = { - 'recoveryCodes': [], - }; + }); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + test('test method createMfaAuthenticator()', () async { - final response = await account.createMFARecoveryCodes(); - expect(response, isA()); - }); + final Map data = { + 'secret': '[SHARED_SECRET]', + 'uri': 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite',}; - test('test method updateMfaRecoveryCodes()', () async { - final Map data = { - 'recoveryCodes': [], - }; - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - final response = await account.updateMfaRecoveryCodes(); - expect(response, isA()); - }); - test('test method updateMFARecoveryCodes()', () async { - final Map data = { - 'recoveryCodes': [], - }; + final response = await account.createMfaAuthenticator( + type: enums.AuthenticatorType.totp, + ); + expect(response, isA()); - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + }); - final response = await account.updateMFARecoveryCodes(); - expect(response, isA()); - }); + test('test method createMFAAuthenticator()', () async { - test('test method updateName()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateName( - name: '', - ); - expect(response, isA()); - }); + final Map data = { + 'secret': '[SHARED_SECRET]', + 'uri': 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite',}; - test('test method updatePassword()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updatePassword( - password: 'password', - ); - expect(response, isA()); - }); - test('test method updatePhone()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updatePhone( - phone: '+12065550100', - password: 'password', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - test('test method getPrefs()', () async { - final Map data = {}; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final response = await account.createMFAAuthenticator( + type: enums.AuthenticatorType.totp, + ); + expect(response, isA()); - final response = await account.getPrefs(); - expect(response, isA()); - }); + }); - test('test method updatePrefs()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updatePrefs( - prefs: {}, - ); - expect(response, isA()); - }); + test('test method updateMfaAuthenticator()', () async { - test('test method createRecovery()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createRecovery( - email: 'email@example.com', - url: 'https://example.com', - ); - expect(response, isA()); - }); + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - test('test method updateRecovery()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateRecovery( - userId: '', - secret: '', - password: 'password', - ); - expect(response, isA()); - }); - test('test method listSessions()', () async { - final Map data = { - 'total': 5, - 'sessions': [], - }; + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - final response = await account.listSessions(); - expect(response, isA()); - }); + final response = await account.updateMfaAuthenticator( + type: enums.AuthenticatorType.totp, + otp: '', + ); + expect(response, isA()); - test('test method deleteSessions()', () async { - final data = ''; + }); - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + test('test method updateMFAAuthenticator()', () async { - final response = await account.deleteSessions(); - }); + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - test('test method createAnonymousSession()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createAnonymousSession(); - expect(response, isA()); - }); - test('test method createEmailPasswordSession()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createEmailPasswordSession( - email: 'email@example.com', - password: 'password', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); - test('test method updateMagicURLSession()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateMagicURLSession( - userId: '', - secret: '', - ); - expect(response, isA()); - }); - test('test method createOAuth2Session()', () async { - when(client.webAuth( - argThat(isNotNull), - )).thenAnswer((_) async => 'done'); + final response = await account.updateMFAAuthenticator( + type: enums.AuthenticatorType.totp, + otp: '', + ); + expect(response, isA()); - final response = await account.createOAuth2Session( - provider: enums.OAuthProvider.amazon, - ); - expect(response, equals('done')); - }); + }); - test('test method updatePhoneSession()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updatePhoneSession( - userId: '', - secret: '', - ); - expect(response, isA()); - }); + test('test method deleteMfaAuthenticator()', () async { - test('test method createSession()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createSession( - userId: '', - secret: '', - ); - expect(response, isA()); - }); + final data = ''; - test('test method getSession()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.getSession( - sessionId: '', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - test('test method updateSession()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateSession( - sessionId: '', - ); - expect(response, isA()); - }); - test('test method deleteSession()', () async { - final data = ''; + final response = await account.deleteMfaAuthenticator( + type: enums.AuthenticatorType.totp, + ); + }); - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + test('test method deleteMFAAuthenticator()', () async { - final response = await account.deleteSession( - sessionId: '', - ); - }); + final data = ''; - test('test method updateStatus()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateStatus(); - expect(response, isA()); - }); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - test('test method createPushTarget()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'Apple iPhone 12', - 'userId': '259125845563242502', - 'providerType': 'email', - 'identifier': 'token', - 'expired': true, - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createPushTarget( - targetId: '', - identifier: '', - ); - expect(response, isA()); - }); - test('test method updatePushTarget()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'Apple iPhone 12', - 'userId': '259125845563242502', - 'providerType': 'email', - 'identifier': 'token', - 'expired': true, - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updatePushTarget( - targetId: '', - identifier: '', - ); - expect(response, isA()); - }); + final response = await account.deleteMFAAuthenticator( + type: enums.AuthenticatorType.totp, + ); + }); + + test('test method createMfaChallenge()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'expire': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createMfaChallenge( + factor: enums.AuthenticationFactor.email, + ); + expect(response, isA()); + + }); + + test('test method createMFAChallenge()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'expire': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createMFAChallenge( + factor: enums.AuthenticationFactor.email, + ); + expect(response, isA()); + + }); + + test('test method updateMfaChallenge()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - test('test method deletePushTarget()', () async { - final data = ''; - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); - final response = await account.deletePushTarget( - targetId: '', - ); - }); - test('test method createEmailToken()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createEmailToken( - userId: '', - email: 'email@example.com', - ); - expect(response, isA()); - }); + final response = await account.updateMfaChallenge( + challengeId: '', + otp: '', + ); + expect(response, isA()); - test('test method createMagicURLToken()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createMagicURLToken( - userId: '', - email: 'email@example.com', - ); - expect(response, isA()); - }); + }); - test('test method createOAuth2Token()', () async { - when(client.webAuth( - argThat(isNotNull), - )).thenAnswer((_) async => 'done'); + test('test method updateMFAChallenge()', () async { - final response = await account.createOAuth2Token( - provider: enums.OAuthProvider.amazon, - ); - expect(response, equals('done')); - }); + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - test('test method createPhoneToken()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createPhoneToken( - userId: '', - phone: '+12065550100', - ); - expect(response, isA()); - }); - test('test method createEmailVerification()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createEmailVerification( - url: 'https://example.com', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); - test('test method createVerification()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createVerification( - url: 'https://example.com', - ); - expect(response, isA()); - }); - test('test method updateEmailVerification()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateEmailVerification( - userId: '', - secret: '', - ); - expect(response, isA()); - }); + final response = await account.updateMFAChallenge( + challengeId: '', + otp: '', + ); + expect(response, isA()); - test('test method updateVerification()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateVerification( - userId: '', - secret: '', - ); - expect(response, isA()); - }); + }); - test('test method createPhoneVerification()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createPhoneVerification(); - expect(response, isA()); - }); + test('test method listMfaFactors()', () async { + + final Map data = { + 'totp': true, + 'phone': true, + 'email': true, + 'recoveryCode': true,}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.listMfaFactors( + ); + expect(response, isA()); + + }); + + test('test method listMFAFactors()', () async { + + final Map data = { + 'totp': true, + 'phone': true, + 'email': true, + 'recoveryCode': true,}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.listMFAFactors( + ); + expect(response, isA()); + + }); + + test('test method getMfaRecoveryCodes()', () async { + + final Map data = { + 'recoveryCodes': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.getMfaRecoveryCodes( + ); + expect(response, isA()); + + }); + + test('test method getMFARecoveryCodes()', () async { + + final Map data = { + 'recoveryCodes': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.getMFARecoveryCodes( + ); + expect(response, isA()); + + }); + + test('test method createMfaRecoveryCodes()', () async { + + final Map data = { + 'recoveryCodes': [],}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createMfaRecoveryCodes( + ); + expect(response, isA()); + + }); + + test('test method createMFARecoveryCodes()', () async { + + final Map data = { + 'recoveryCodes': [],}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createMFARecoveryCodes( + ); + expect(response, isA()); + + }); + + test('test method updateMfaRecoveryCodes()', () async { + + final Map data = { + 'recoveryCodes': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateMfaRecoveryCodes( + ); + expect(response, isA()); + + }); + + test('test method updateMFARecoveryCodes()', () async { + + final Map data = { + 'recoveryCodes': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateMFARecoveryCodes( + ); + expect(response, isA()); + + }); + + test('test method updateName()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateName( + name: '', + ); + expect(response, isA()); + + }); + + test('test method updatePassword()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updatePassword( + password: 'password', + ); + expect(response, isA()); + + }); + + test('test method updatePhone()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updatePhone( + phone: '+12065550100', + password: 'password', + ); + expect(response, isA()); + + }); + + test('test method getPrefs()', () async { + + final Map data = {}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.getPrefs( + ); + expect(response, isA()); + + }); + + test('test method updatePrefs()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updatePrefs( + prefs: {}, + ); + expect(response, isA()); + + }); + + test('test method createRecovery()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createRecovery( + email: 'email@example.com', + url: 'https://example.com', + ); + expect(response, isA()); + + }); + + test('test method updateRecovery()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateRecovery( + userId: '', + secret: '', + password: 'password', + ); + expect(response, isA()); + + }); + + test('test method listSessions()', () async { + + final Map data = { + 'total': 5, + 'sessions': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.listSessions( + ); + expect(response, isA()); + + }); + + test('test method deleteSessions()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.deleteSessions( + ); + }); + + test('test method createAnonymousSession()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createAnonymousSession( + ); + expect(response, isA()); + + }); + + test('test method createEmailPasswordSession()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createEmailPasswordSession( + email: 'email@example.com', + password: 'password', + ); + expect(response, isA()); + + }); + + test('test method updateMagicURLSession()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateMagicURLSession( + userId: '', + secret: '', + ); + expect(response, isA()); + + }); + + test('test method createOAuth2Session()', () async { + + + when(client.webAuth( + argThat(isNotNull), + )).thenAnswer((_) async => 'done'); + + + final response = await account.createOAuth2Session( + provider: enums.OAuthProvider.amazon, + ); + expect(response, equals('done')); + + }); + + test('test method updatePhoneSession()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updatePhoneSession( + userId: '', + secret: '', + ); + expect(response, isA()); + + }); + + test('test method createSession()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createSession( + userId: '', + secret: '', + ); + expect(response, isA()); + + }); + + test('test method getSession()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.getSession( + sessionId: '', + ); + expect(response, isA()); + + }); + + test('test method updateSession()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateSession( + sessionId: '', + ); + expect(response, isA()); + + }); + + test('test method deleteSession()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.deleteSession( + sessionId: '', + ); + }); + + test('test method updateStatus()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateStatus( + ); + expect(response, isA()); + + }); + + test('test method createPushTarget()', () async { + + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Apple iPhone 12', + 'userId': '259125845563242502', + 'providerType': 'email', + 'identifier': 'token', + 'expired': true,}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createPushTarget( + targetId: '', + identifier: '', + ); + expect(response, isA()); + + }); + + test('test method updatePushTarget()', () async { + + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Apple iPhone 12', + 'userId': '259125845563242502', + 'providerType': 'email', + 'identifier': 'token', + 'expired': true,}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updatePushTarget( + targetId: '', + identifier: '', + ); + expect(response, isA()); + + }); + + test('test method deletePushTarget()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.deletePushTarget( + targetId: '', + ); + }); + + test('test method createEmailToken()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createEmailToken( + userId: '', + email: 'email@example.com', + ); + expect(response, isA()); + + }); + + test('test method createMagicURLToken()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createMagicURLToken( + userId: '', + email: 'email@example.com', + ); + expect(response, isA()); + + }); + + test('test method createOAuth2Token()', () async { + + + when(client.webAuth( + argThat(isNotNull), + )).thenAnswer((_) async => 'done'); + + + final response = await account.createOAuth2Token( + provider: enums.OAuthProvider.amazon, + ); + expect(response, equals('done')); + + }); + + test('test method createPhoneToken()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createPhoneToken( + userId: '', + phone: '+12065550100', + ); + expect(response, isA()); + + }); + + test('test method createEmailVerification()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createEmailVerification( + url: 'https://example.com', + ); + expect(response, isA()); + + }); + + test('test method createVerification()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createVerification( + url: 'https://example.com', + ); + expect(response, isA()); + + }); + + test('test method updateEmailVerification()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateEmailVerification( + userId: '', + secret: '', + ); + expect(response, isA()); + + }); + + test('test method updateVerification()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateVerification( + userId: '', + secret: '', + ); + expect(response, isA()); + + }); + + test('test method createPhoneVerification()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createPhoneVerification( + ); + expect(response, isA()); + + }); + + test('test method updatePhoneVerification()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updatePhoneVerification( + userId: '', + secret: '', + ); + expect(response, isA()); + + }); - test('test method updatePhoneVerification()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updatePhoneVerification( - userId: '', - secret: '', - ); - expect(response, isA()); }); - }); } diff --git a/test/services/avatars_test.dart b/test/services/avatars_test.dart index 8d2c48fb..4bdb434d 100644 --- a/test/services/avatars_test.dart +++ b/test/services/avatars_test.dart @@ -24,11 +24,12 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -40,123 +41,138 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method( - #chunkedUpload, [path, params, paramName, idParamName, headers]), - returnValue: Response(data: {})); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Avatars test', () { - late MockClient client; - late Avatars avatars; + group('Avatars test', () { + late MockClient client; + late Avatars avatars; - setUp(() { - client = MockClient(); - avatars = Avatars(client); - }); + setUp(() { + client = MockClient(); + avatars = Avatars(client); + }); - test('test method getBrowser()', () async { - final Uint8List data = Uint8List.fromList([]); + test('test method getBrowser()', () async { +final Uint8List data = Uint8List.fromList([]); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await avatars.getBrowser( - code: enums.Browser.avantBrowser, - ); - expect(response, isA()); - }); - test('test method getCreditCard()', () async { - final Uint8List data = Uint8List.fromList([]); + final response = await avatars.getBrowser( + code: enums.Browser.avantBrowser, + ); + expect(response, isA()); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + }); - final response = await avatars.getCreditCard( - code: enums.CreditCard.americanExpress, - ); - expect(response, isA()); - }); + test('test method getCreditCard()', () async { +final Uint8List data = Uint8List.fromList([]); - test('test method getFavicon()', () async { - final Uint8List data = Uint8List.fromList([]); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - final response = await avatars.getFavicon( - url: 'https://example.com', - ); - expect(response, isA()); - }); + final response = await avatars.getCreditCard( + code: enums.CreditCard.americanExpress, + ); + expect(response, isA()); - test('test method getFlag()', () async { - final Uint8List data = Uint8List.fromList([]); + }); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + test('test method getFavicon()', () async { +final Uint8List data = Uint8List.fromList([]); - final response = await avatars.getFlag( - code: enums.Flag.afghanistan, - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method getImage()', () async { - final Uint8List data = Uint8List.fromList([]); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final response = await avatars.getFavicon( + url: 'https://example.com', + ); + expect(response, isA()); - final response = await avatars.getImage( - url: 'https://example.com', - ); - expect(response, isA()); - }); + }); - test('test method getInitials()', () async { - final Uint8List data = Uint8List.fromList([]); + test('test method getFlag()', () async { +final Uint8List data = Uint8List.fromList([]); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await avatars.getInitials(); - expect(response, isA()); - }); - test('test method getQR()', () async { - final Uint8List data = Uint8List.fromList([]); + final response = await avatars.getFlag( + code: enums.Flag.afghanistan, + ); + expect(response, isA()); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + }); + + test('test method getImage()', () async { +final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await avatars.getImage( + url: 'https://example.com', + ); + expect(response, isA()); + + }); + + test('test method getInitials()', () async { +final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await avatars.getInitials( + ); + expect(response, isA()); + + }); + + test('test method getQR()', () async { +final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await avatars.getQR( + text: '', + ); + expect(response, isA()); + + }); + + test('test method getScreenshot()', () async { +final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await avatars.getQR( - text: '', - ); - expect(response, isA()); - }); - test('test method getScreenshot()', () async { - final Uint8List data = Uint8List.fromList([]); + final response = await avatars.getScreenshot( + url: 'https://example.com', + ); + expect(response, isA()); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + }); - final response = await avatars.getScreenshot( - url: 'https://example.com', - ); - expect(response, isA()); }); - }); } diff --git a/test/services/databases_test.dart b/test/services/databases_test.dart index a3807093..a4b0a6cc 100644 --- a/test/services/databases_test.dart +++ b/test/services/databases_test.dart @@ -24,11 +24,12 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -40,297 +41,337 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method( - #chunkedUpload, [path, params, paramName, idParamName, headers]), - returnValue: Response(data: {})); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Databases test', () { - late MockClient client; - late Databases databases; + group('Databases test', () { + late MockClient client; + late Databases databases; - setUp(() { - client = MockClient(); - databases = Databases(client); - }); + setUp(() { + client = MockClient(); + databases = Databases(client); + }); - test('test method listTransactions()', () async { - final Map data = { - 'total': 5, - 'transactions': [], - }; + test('test method listTransactions()', () async { - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final Map data = { + 'total': 5, + 'transactions': [],}; - final response = await databases.listTransactions(); - expect(response, isA()); - }); - test('test method createTransaction()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await databases.createTransaction(); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method getTransaction()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await databases.getTransaction( - transactionId: '', - ); - expect(response, isA()); - }); - test('test method updateTransaction()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await databases.updateTransaction( - transactionId: '', - ); - expect(response, isA()); - }); + final response = await databases.listTransactions( + ); + expect(response, isA()); - test('test method deleteTransaction()', () async { - final data = ''; + }); - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + test('test method createTransaction()', () async { - final response = await databases.deleteTransaction( - transactionId: '', - ); - }); + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - test('test method createOperations()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await databases.createOperations( - transactionId: '', - ); - expect(response, isA()); - }); - test('test method listDocuments()', () async { - final Map data = { - 'total': 5, - 'documents': [], - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await databases.listDocuments( - databaseId: '', - collectionId: '', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - test('test method createDocument()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await databases.createDocument( - databaseId: '', - collectionId: '', - documentId: '', - data: {}, - ); - expect(response, isA()); - }); - test('test method getDocument()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await databases.getDocument( - databaseId: '', - collectionId: '', - documentId: '', - ); - expect(response, isA()); - }); + final response = await databases.createTransaction( + ); + expect(response, isA()); - test('test method upsertDocument()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await databases.upsertDocument( - databaseId: '', - collectionId: '', - documentId: '', - ); - expect(response, isA()); - }); + }); - test('test method updateDocument()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await databases.updateDocument( - databaseId: '', - collectionId: '', - documentId: '', - ); - expect(response, isA()); - }); + test('test method getTransaction()', () async { - test('test method deleteDocument()', () async { - final data = ''; + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - final response = await databases.deleteDocument( - databaseId: '', - collectionId: '', - documentId: '', - ); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method decrementDocumentAttribute()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await databases.decrementDocumentAttribute( - databaseId: '', - collectionId: '', - documentId: '', - attribute: '', - ); - expect(response, isA()); - }); - test('test method incrementDocumentAttribute()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await databases.incrementDocumentAttribute( - databaseId: '', - collectionId: '', - documentId: '', - attribute: '', - ); - expect(response, isA()); + final response = await databases.getTransaction( + transactionId: '', + ); + expect(response, isA()); + + }); + + test('test method updateTransaction()', () async { + + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.updateTransaction( + transactionId: '', + ); + expect(response, isA()); + + }); + + test('test method deleteTransaction()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.deleteTransaction( + transactionId: '', + ); + }); + + test('test method createOperations()', () async { + + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.createOperations( + transactionId: '', + ); + expect(response, isA()); + + }); + + test('test method listDocuments()', () async { + + final Map data = { + 'total': 5, + 'documents': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.listDocuments( + databaseId: '', + collectionId: '', + ); + expect(response, isA()); + + }); + + test('test method createDocument()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.createDocument( + databaseId: '', + collectionId: '', + documentId: '', + data: {}, + ); + expect(response, isA()); + + }); + + test('test method getDocument()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.getDocument( + databaseId: '', + collectionId: '', + documentId: '', + ); + expect(response, isA()); + + }); + + test('test method upsertDocument()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.upsertDocument( + databaseId: '', + collectionId: '', + documentId: '', + ); + expect(response, isA()); + + }); + + test('test method updateDocument()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.updateDocument( + databaseId: '', + collectionId: '', + documentId: '', + ); + expect(response, isA()); + + }); + + test('test method deleteDocument()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.deleteDocument( + databaseId: '', + collectionId: '', + documentId: '', + ); + }); + + test('test method decrementDocumentAttribute()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.decrementDocumentAttribute( + databaseId: '', + collectionId: '', + documentId: '', + attribute: '', + ); + expect(response, isA()); + + }); + + test('test method incrementDocumentAttribute()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.incrementDocumentAttribute( + databaseId: '', + collectionId: '', + documentId: '', + attribute: '', + ); + expect(response, isA()); + + }); + }); - }); } diff --git a/test/services/functions_test.dart b/test/services/functions_test.dart index c6e50a50..9b0d046f 100644 --- a/test/services/functions_test.dart +++ b/test/services/functions_test.dart @@ -24,11 +24,12 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -40,100 +41,107 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method( - #chunkedUpload, [path, params, paramName, idParamName, headers]), - returnValue: Response(data: {})); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Functions test', () { - late MockClient client; - late Functions functions; + group('Functions test', () { + late MockClient client; + late Functions functions; - setUp(() { - client = MockClient(); - functions = Functions(client); - }); + setUp(() { + client = MockClient(); + functions = Functions(client); + }); - test('test method listExecutions()', () async { - final Map data = { - 'total': 5, - 'executions': [], - }; + test('test method listExecutions()', () async { - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final Map data = { + 'total': 5, + 'executions': [],}; - final response = await functions.listExecutions( - functionId: '', - ); - expect(response, isA()); - }); - test('test method createExecution()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'functionId': '5e5ea6g16897e', - 'deploymentId': '5e5ea5c16897e', - 'trigger': 'http', - 'status': 'processing', - 'requestMethod': 'GET', - 'requestPath': '/articles?id=5', - 'requestHeaders': [], - 'responseStatusCode': 200, - 'responseBody': '', - 'responseHeaders': [], - 'logs': '', - 'errors': '', - 'duration': 0.4, - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await functions.createExecution( - functionId: '', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await functions.listExecutions( + functionId: '', + ); + expect(response, isA()); + + }); + + test('test method createExecution()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'functionId': '5e5ea6g16897e', + 'deploymentId': '5e5ea5c16897e', + 'trigger': 'http', + 'status': 'processing', + 'requestMethod': 'GET', + 'requestPath': '/articles?id=5', + 'requestHeaders': [], + 'responseStatusCode': 200, + 'responseBody': '', + 'responseHeaders': [], + 'logs': '', + 'errors': '', + 'duration': 0.4,}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await functions.createExecution( + functionId: '', + ); + expect(response, isA()); + + }); + + test('test method getExecution()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'functionId': '5e5ea6g16897e', + 'deploymentId': '5e5ea5c16897e', + 'trigger': 'http', + 'status': 'processing', + 'requestMethod': 'GET', + 'requestPath': '/articles?id=5', + 'requestHeaders': [], + 'responseStatusCode': 200, + 'responseBody': '', + 'responseHeaders': [], + 'logs': '', + 'errors': '', + 'duration': 0.4,}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await functions.getExecution( + functionId: '', + executionId: '', + ); + expect(response, isA()); + + }); - test('test method getExecution()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'functionId': '5e5ea6g16897e', - 'deploymentId': '5e5ea5c16897e', - 'trigger': 'http', - 'status': 'processing', - 'requestMethod': 'GET', - 'requestPath': '/articles?id=5', - 'requestHeaders': [], - 'responseStatusCode': 200, - 'responseBody': '', - 'responseHeaders': [], - 'logs': '', - 'errors': '', - 'duration': 0.4, - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await functions.getExecution( - functionId: '', - executionId: '', - ); - expect(response, isA()); }); - }); } diff --git a/test/services/graphql_test.dart b/test/services/graphql_test.dart index 84b7de1c..c548e414 100644 --- a/test/services/graphql_test.dart +++ b/test/services/graphql_test.dart @@ -24,11 +24,12 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -40,45 +41,47 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method( - #chunkedUpload, [path, params, paramName, idParamName, headers]), - returnValue: Response(data: {})); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Graphql test', () { - late MockClient client; - late Graphql graphql; + group('Graphql test', () { + late MockClient client; + late Graphql graphql; - setUp(() { - client = MockClient(); - graphql = Graphql(client); - }); + setUp(() { + client = MockClient(); + graphql = Graphql(client); + }); - test('test method query()', () async { - final data = ''; + test('test method query()', () async { - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + final data = ''; - final response = await graphql.query( - query: {}, - ); - }); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await graphql.query( + query: {}, + ); + }); + + test('test method mutation()', () async { + + final data = ''; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - test('test method mutation()', () async { - final data = ''; - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + final response = await graphql.mutation( + query: {}, + ); + }); - final response = await graphql.mutation( - query: {}, - ); }); - }); } diff --git a/test/services/locale_test.dart b/test/services/locale_test.dart index f9f6489d..42faaf72 100644 --- a/test/services/locale_test.dart +++ b/test/services/locale_test.dart @@ -24,11 +24,12 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -40,138 +41,168 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method( - #chunkedUpload, [path, params, paramName, idParamName, headers]), - returnValue: Response(data: {})); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Locale test', () { - late MockClient client; - late Locale locale; + group('Locale test', () { + late MockClient client; + late Locale locale; - setUp(() { - client = MockClient(); - locale = Locale(client); - }); + setUp(() { + client = MockClient(); + locale = Locale(client); + }); - test('test method get()', () async { - final Map data = { - 'ip': '127.0.0.1', - 'countryCode': 'US', - 'country': 'United States', - 'continentCode': 'NA', - 'continent': 'North America', - 'eu': true, - 'currency': 'USD', - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await locale.get(); - expect(response, isA()); - }); + test('test method get()', () async { - test('test method listCodes()', () async { - final Map data = { - 'total': 5, - 'localeCodes': [], - }; + final Map data = { + 'ip': '127.0.0.1', + 'countryCode': 'US', + 'country': 'United States', + 'continentCode': 'NA', + 'continent': 'North America', + 'eu': true, + 'currency': 'USD',}; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - final response = await locale.listCodes(); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method listContinents()', () async { - final Map data = { - 'total': 5, - 'continents': [], - }; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final response = await locale.get( + ); + expect(response, isA()); - final response = await locale.listContinents(); - expect(response, isA()); - }); + }); - test('test method listCountries()', () async { - final Map data = { - 'total': 5, - 'countries': [], - }; + test('test method listCodes()', () async { - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final Map data = { + 'total': 5, + 'localeCodes': [],}; - final response = await locale.listCountries(); - expect(response, isA()); - }); - test('test method listCountriesEU()', () async { - final Map data = { - 'total': 5, - 'countries': [], - }; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - final response = await locale.listCountriesEU(); - expect(response, isA()); - }); + final response = await locale.listCodes( + ); + expect(response, isA()); - test('test method listCountriesPhones()', () async { - final Map data = { - 'total': 5, - 'phones': [], - }; + }); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + test('test method listContinents()', () async { - final response = await locale.listCountriesPhones(); - expect(response, isA()); - }); + final Map data = { + 'total': 5, + 'continents': [],}; - test('test method listCurrencies()', () async { - final Map data = { - 'total': 5, - 'currencies': [], - }; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await locale.listContinents( + ); + expect(response, isA()); + + }); + + test('test method listCountries()', () async { + + final Map data = { + 'total': 5, + 'countries': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await locale.listCountries( + ); + expect(response, isA()); + + }); + + test('test method listCountriesEU()', () async { + + final Map data = { + 'total': 5, + 'countries': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await locale.listCountriesEU( + ); + expect(response, isA()); + + }); + + test('test method listCountriesPhones()', () async { + + final Map data = { + 'total': 5, + 'phones': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await locale.listCountriesPhones( + ); + expect(response, isA()); + + }); + + test('test method listCurrencies()', () async { + + final Map data = { + 'total': 5, + 'currencies': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await locale.listCurrencies( + ); + expect(response, isA()); + + }); + + test('test method listLanguages()', () async { + + final Map data = { + 'total': 5, + 'languages': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await locale.listCurrencies(); - expect(response, isA()); - }); - test('test method listLanguages()', () async { - final Map data = { - 'total': 5, - 'languages': [], - }; + final response = await locale.listLanguages( + ); + expect(response, isA()); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + }); - final response = await locale.listLanguages(); - expect(response, isA()); }); - }); } diff --git a/test/services/messaging_test.dart b/test/services/messaging_test.dart index 0c938eff..5899ace3 100644 --- a/test/services/messaging_test.dart +++ b/test/services/messaging_test.dart @@ -24,11 +24,12 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -40,68 +41,71 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method( - #chunkedUpload, [path, params, paramName, idParamName, headers]), - returnValue: Response(data: {})); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Messaging test', () { - late MockClient client; - late Messaging messaging; + group('Messaging test', () { + late MockClient client; + late Messaging messaging; - setUp(() { - client = MockClient(); - messaging = Messaging(client); - }); + setUp(() { + client = MockClient(); + messaging = Messaging(client); + }); - test('test method createSubscriber()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'targetId': '259125845563242502', - 'target': { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'Apple iPhone 12', - 'userId': '259125845563242502', - 'providerType': 'email', - 'identifier': 'token', - 'expired': true, - }, - 'userId': '5e5ea5c16897e', - 'userName': 'Aegon Targaryen', - 'topicId': '259125845563242502', - 'providerType': 'email', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await messaging.createSubscriber( - topicId: '', - subscriberId: '', - targetId: '', - ); - expect(response, isA()); - }); + test('test method createSubscriber()', () async { + + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'targetId': '259125845563242502', + 'target': { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Apple iPhone 12', + 'userId': '259125845563242502', + 'providerType': 'email', + 'identifier': 'token', + 'expired': true, + }, + 'userId': '5e5ea5c16897e', + 'userName': 'Aegon Targaryen', + 'topicId': '259125845563242502', + 'providerType': 'email',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.createSubscriber( + topicId: '', + subscriberId: '', + targetId: '', + ); + expect(response, isA()); + + }); + + test('test method deleteSubscriber()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - test('test method deleteSubscriber()', () async { - final data = ''; - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + final response = await messaging.deleteSubscriber( + topicId: '', + subscriberId: '', + ); + }); - final response = await messaging.deleteSubscriber( - topicId: '', - subscriberId: '', - ); }); - }); } diff --git a/test/services/presences_test.dart b/test/services/presences_test.dart index 7fed0439..7b99675f 100644 --- a/test/services/presences_test.dart +++ b/test/services/presences_test.dart @@ -24,11 +24,12 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -40,108 +41,121 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method( - #chunkedUpload, [path, params, paramName, idParamName, headers]), - returnValue: Response(data: {})); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Presences test', () { - late MockClient client; - late Presences presences; + group('Presences test', () { + late MockClient client; + late Presences presences; - setUp(() { - client = MockClient(); - presences = Presences(client); - }); + setUp(() { + client = MockClient(); + presences = Presences(client); + }); - test('test method list()', () async { - final Map data = { - 'total': 5, - 'presences': [], - }; + test('test method list()', () async { - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final Map data = { + 'total': 5, + 'presences': [],}; - final response = await presences.list(); - expect(response, isA()); - }); - test('test method get()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'userId': '674af8f3e12a5f9ac0be', - 'source': 'HTTP', - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await presences.get( - presenceId: '', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method upsert()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'userId': '674af8f3e12a5f9ac0be', - 'source': 'HTTP', - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await presences.upsert( - presenceId: '', - status: '', - ); - expect(response, isA()); - }); - test('test method update()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'userId': '674af8f3e12a5f9ac0be', - 'source': 'HTTP', - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await presences.update( - presenceId: '', - ); - expect(response, isA()); - }); + final response = await presences.list( + ); + expect(response, isA()); + + }); + + test('test method get()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'userId': '674af8f3e12a5f9ac0be', + 'source': 'HTTP',}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await presences.get( + presenceId: '', + ); + expect(response, isA()); + + }); + + test('test method upsert()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'userId': '674af8f3e12a5f9ac0be', + 'source': 'HTTP',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await presences.upsert( + presenceId: '', + status: '', + ); + expect(response, isA()); + + }); + + test('test method update()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'userId': '674af8f3e12a5f9ac0be', + 'source': 'HTTP',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await presences.update( + presenceId: '', + ); + expect(response, isA()); + + }); + + test('test method delete()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - test('test method delete()', () async { - final data = ''; - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + final response = await presences.delete( + presenceId: '', + ); + }); - final response = await presences.delete( - presenceId: '', - ); }); - }); } diff --git a/test/services/storage_test.dart b/test/services/storage_test.dart index 55a42f94..2390bfdd 100644 --- a/test/services/storage_test.dart +++ b/test/services/storage_test.dart @@ -24,11 +24,12 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -40,184 +41,202 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method( - #chunkedUpload, [path, params, paramName, idParamName, headers]), - returnValue: Response(data: {})); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Storage test', () { - late MockClient client; - late Storage storage; + group('Storage test', () { + late MockClient client; + late Storage storage; + + setUp(() { + client = MockClient(); + storage = Storage(client); + }); + + test('test method listFiles()', () async { + + final Map data = { + 'total': 5, + 'files': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await storage.listFiles( + bucketId: '', + ); + expect(response, isA()); + + }); + + test('test method createFile()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + 'bucketId': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'name': 'Pink.png', + 'signature': '5d529fd02b544198ae075bd57c1762bb', + 'mimeType': 'image/png', + 'sizeOriginal': 17890, + 'sizeActual': 12345, + 'chunksTotal': 17890, + 'chunksUploaded': 17890, + 'encryption': true, + 'compression': 'gzip',}; + - setUp(() { - client = MockClient(); - storage = Storage(client); - }); + when(client.chunkedUpload( + path: argThat(isNotNull), + params: argThat(isNotNull), + paramName: argThat(isNotNull), + idParamName: argThat(isNotNull), + headers: argThat(isNotNull), + )).thenAnswer((_) async => Response(data: data)); - test('test method listFiles()', () async { - final Map data = { - 'total': 5, - 'files': [], - }; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final response = await storage.createFile( + bucketId: '', + fileId: '', + file: InputFile.fromPath(path: './image.png'), + ); + expect(response, isA()); + + }); - final response = await storage.listFiles( - bucketId: '', - ); - expect(response, isA()); - }); + test('test method getFile()', () async { - test('test method createFile()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - 'bucketId': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'name': 'Pink.png', - 'signature': '5d529fd02b544198ae075bd57c1762bb', - 'mimeType': 'image/png', - 'sizeOriginal': 17890, - 'sizeActual': 12345, - 'chunksTotal': 17890, - 'chunksUploaded': 17890, - 'encryption': true, - 'compression': 'gzip', - }; - - when(client.chunkedUpload( - path: argThat(isNotNull), - params: argThat(isNotNull), - paramName: argThat(isNotNull), - idParamName: argThat(isNotNull), - headers: argThat(isNotNull), - )).thenAnswer((_) async => Response(data: data)); - - final response = await storage.createFile( - bucketId: '', - fileId: '', - file: InputFile.fromPath(path: './image.png'), - ); - expect(response, isA()); - }); + final Map data = { + '\$id': '5e5ea5c16897e', + 'bucketId': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'name': 'Pink.png', + 'signature': '5d529fd02b544198ae075bd57c1762bb', + 'mimeType': 'image/png', + 'sizeOriginal': 17890, + 'sizeActual': 12345, + 'chunksTotal': 17890, + 'chunksUploaded': 17890, + 'encryption': true, + 'compression': 'gzip',}; - test('test method getFile()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - 'bucketId': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'name': 'Pink.png', - 'signature': '5d529fd02b544198ae075bd57c1762bb', - 'mimeType': 'image/png', - 'sizeOriginal': 17890, - 'sizeActual': 12345, - 'chunksTotal': 17890, - 'chunksUploaded': 17890, - 'encryption': true, - 'compression': 'gzip', - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await storage.getFile( - bucketId: '', - fileId: '', - ); - expect(response, isA()); - }); - test('test method updateFile()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - 'bucketId': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'name': 'Pink.png', - 'signature': '5d529fd02b544198ae075bd57c1762bb', - 'mimeType': 'image/png', - 'sizeOriginal': 17890, - 'sizeActual': 12345, - 'chunksTotal': 17890, - 'chunksUploaded': 17890, - 'encryption': true, - 'compression': 'gzip', - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await storage.updateFile( - bucketId: '', - fileId: '', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method deleteFile()', () async { - final data = ''; - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + final response = await storage.getFile( + bucketId: '', + fileId: '', + ); + expect(response, isA()); - final response = await storage.deleteFile( - bucketId: '', - fileId: '', - ); - }); + }); - test('test method getFileDownload()', () async { - final Uint8List data = Uint8List.fromList([]); + test('test method updateFile()', () async { - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final Map data = { + '\$id': '5e5ea5c16897e', + 'bucketId': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'name': 'Pink.png', + 'signature': '5d529fd02b544198ae075bd57c1762bb', + 'mimeType': 'image/png', + 'sizeOriginal': 17890, + 'sizeActual': 12345, + 'chunksTotal': 17890, + 'chunksUploaded': 17890, + 'encryption': true, + 'compression': 'gzip',}; - final response = await storage.getFileDownload( - bucketId: '', - fileId: '', - ); - expect(response, isA()); - }); - test('test method getFilePreview()', () async { - final Uint8List data = Uint8List.fromList([]); + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - final response = await storage.getFilePreview( - bucketId: '', - fileId: '', - ); - expect(response, isA()); - }); + final response = await storage.updateFile( + bucketId: '', + fileId: '', + ); + expect(response, isA()); + + }); + + test('test method deleteFile()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await storage.deleteFile( + bucketId: '', + fileId: '', + ); + }); + + test('test method getFileDownload()', () async { +final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await storage.getFileDownload( + bucketId: '', + fileId: '', + ); + expect(response, isA()); + + }); + + test('test method getFilePreview()', () async { +final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await storage.getFilePreview( + bucketId: '', + fileId: '', + ); + expect(response, isA()); + + }); + + test('test method getFileView()', () async { +final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + - test('test method getFileView()', () async { - final Uint8List data = Uint8List.fromList([]); + final response = await storage.getFileView( + bucketId: '', + fileId: '', + ); + expect(response, isA()); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + }); - final response = await storage.getFileView( - bucketId: '', - fileId: '', - ); - expect(response, isA()); }); - }); } diff --git a/test/services/tables_db_test.dart b/test/services/tables_db_test.dart index f318cad2..5219d2bf 100644 --- a/test/services/tables_db_test.dart +++ b/test/services/tables_db_test.dart @@ -24,11 +24,12 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -40,297 +41,337 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method( - #chunkedUpload, [path, params, paramName, idParamName, headers]), - returnValue: Response(data: {})); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('TablesDB test', () { - late MockClient client; - late TablesDB tablesDB; + group('TablesDB test', () { + late MockClient client; + late TablesDB tablesDB; - setUp(() { - client = MockClient(); - tablesDB = TablesDB(client); - }); + setUp(() { + client = MockClient(); + tablesDB = TablesDB(client); + }); - test('test method listTransactions()', () async { - final Map data = { - 'total': 5, - 'transactions': [], - }; + test('test method listTransactions()', () async { - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final Map data = { + 'total': 5, + 'transactions': [],}; - final response = await tablesDB.listTransactions(); - expect(response, isA()); - }); - test('test method createTransaction()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.createTransaction(); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method getTransaction()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.getTransaction( - transactionId: '', - ); - expect(response, isA()); - }); - test('test method updateTransaction()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.updateTransaction( - transactionId: '', - ); - expect(response, isA()); - }); + final response = await tablesDB.listTransactions( + ); + expect(response, isA()); - test('test method deleteTransaction()', () async { - final data = ''; + }); - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + test('test method createTransaction()', () async { - final response = await tablesDB.deleteTransaction( - transactionId: '', - ); - }); + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - test('test method createOperations()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.createOperations( - transactionId: '', - ); - expect(response, isA()); - }); - test('test method listRows()', () async { - final Map data = { - 'total': 5, - 'rows': [], - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.listRows( - databaseId: '', - tableId: '', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - test('test method createRow()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.createRow( - databaseId: '', - tableId: '', - rowId: '', - data: {}, - ); - expect(response, isA()); - }); - test('test method getRow()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.getRow( - databaseId: '', - tableId: '', - rowId: '', - ); - expect(response, isA()); - }); + final response = await tablesDB.createTransaction( + ); + expect(response, isA()); - test('test method upsertRow()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.upsertRow( - databaseId: '', - tableId: '', - rowId: '', - ); - expect(response, isA()); - }); + }); - test('test method updateRow()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.updateRow( - databaseId: '', - tableId: '', - rowId: '', - ); - expect(response, isA()); - }); + test('test method getTransaction()', () async { - test('test method deleteRow()', () async { - final data = ''; + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - final response = await tablesDB.deleteRow( - databaseId: '', - tableId: '', - rowId: '', - ); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method decrementRowColumn()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.decrementRowColumn( - databaseId: '', - tableId: '', - rowId: '', - column: '', - ); - expect(response, isA()); - }); - test('test method incrementRowColumn()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.incrementRowColumn( - databaseId: '', - tableId: '', - rowId: '', - column: '', - ); - expect(response, isA()); + final response = await tablesDB.getTransaction( + transactionId: '', + ); + expect(response, isA()); + + }); + + test('test method updateTransaction()', () async { + + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.updateTransaction( + transactionId: '', + ); + expect(response, isA()); + + }); + + test('test method deleteTransaction()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.deleteTransaction( + transactionId: '', + ); + }); + + test('test method createOperations()', () async { + + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.createOperations( + transactionId: '', + ); + expect(response, isA()); + + }); + + test('test method listRows()', () async { + + final Map data = { + 'total': 5, + 'rows': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.listRows( + databaseId: '', + tableId: '', + ); + expect(response, isA()); + + }); + + test('test method createRow()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.createRow( + databaseId: '', + tableId: '', + rowId: '', + data: {}, + ); + expect(response, isA()); + + }); + + test('test method getRow()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.getRow( + databaseId: '', + tableId: '', + rowId: '', + ); + expect(response, isA()); + + }); + + test('test method upsertRow()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.upsertRow( + databaseId: '', + tableId: '', + rowId: '', + ); + expect(response, isA()); + + }); + + test('test method updateRow()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.updateRow( + databaseId: '', + tableId: '', + rowId: '', + ); + expect(response, isA()); + + }); + + test('test method deleteRow()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.deleteRow( + databaseId: '', + tableId: '', + rowId: '', + ); + }); + + test('test method decrementRowColumn()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.decrementRowColumn( + databaseId: '', + tableId: '', + rowId: '', + column: '', + ); + expect(response, isA()); + + }); + + test('test method incrementRowColumn()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.incrementRowColumn( + databaseId: '', + tableId: '', + rowId: '', + column: '', + ); + expect(response, isA()); + + }); + }); - }); } diff --git a/test/services/teams_test.dart b/test/services/teams_test.dart index 83f2667b..ea72a432 100644 --- a/test/services/teams_test.dart +++ b/test/services/teams_test.dart @@ -24,11 +24,12 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -40,288 +41,326 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method( - #chunkedUpload, [path, params, paramName, idParamName, headers]), - returnValue: Response(data: {})); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Teams test', () { - late MockClient client; - late Teams teams; + group('Teams test', () { + late MockClient client; + late Teams teams; - setUp(() { - client = MockClient(); - teams = Teams(client); - }); + setUp(() { + client = MockClient(); + teams = Teams(client); + }); - test('test method list()', () async { - final Map data = { - 'total': 5, - 'teams': [], - }; + test('test method list()', () async { - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final Map data = { + 'total': 5, + 'teams': [],}; - final response = await teams.list(); - expect(response, isA()); - }); - test('test method create()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'VIP', - 'total': 7, - 'prefs': {}, - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await teams.create( - teamId: '', - name: '', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method get()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'VIP', - 'total': 7, - 'prefs': {}, - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await teams.get( - teamId: '', - ); - expect(response, isA()); - }); - test('test method updateName()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'VIP', - 'total': 7, - 'prefs': {}, - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await teams.updateName( - teamId: '', - name: '', - ); - expect(response, isA()); - }); + final response = await teams.list( + ); + expect(response, isA()); - test('test method delete()', () async { - final data = ''; + }); - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + test('test method create()', () async { - final response = await teams.delete( - teamId: '', - ); - }); + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'VIP', + 'total': 7, + 'prefs': {},}; - test('test method listMemberships()', () async { - final Map data = { - 'total': 5, - 'memberships': [], - }; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - final response = await teams.listMemberships( - teamId: '', - ); - expect(response, isA()); - }); - test('test method createMembership()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [], - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await teams.createMembership( - teamId: '', - roles: [], - ); - expect(response, isA()); - }); + final response = await teams.create( + teamId: '', + name: '', + ); + expect(response, isA()); - test('test method getMembership()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [], - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await teams.getMembership( - teamId: '', - membershipId: '', - ); - expect(response, isA()); - }); + }); - test('test method updateMembership()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [], - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await teams.updateMembership( - teamId: '', - membershipId: '', - roles: [], - ); - expect(response, isA()); - }); + test('test method get()', () async { - test('test method deleteMembership()', () async { - final data = ''; + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'VIP', + 'total': 7, + 'prefs': {},}; - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - final response = await teams.deleteMembership( - teamId: '', - membershipId: '', - ); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method updateMembershipStatus()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [], - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await teams.updateMembershipStatus( - teamId: '', - membershipId: '', - userId: '', - secret: '', - ); - expect(response, isA()); - }); - test('test method getPrefs()', () async { - final Map data = {}; + final response = await teams.get( + teamId: '', + ); + expect(response, isA()); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + }); + + test('test method updateName()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'VIP', + 'total': 7, + 'prefs': {},}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.updateName( + teamId: '', + name: '', + ); + expect(response, isA()); + + }); + + test('test method delete()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.delete( + teamId: '', + ); + }); + + test('test method listMemberships()', () async { + + final Map data = { + 'total': 5, + 'memberships': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.listMemberships( + teamId: '', + ); + expect(response, isA()); + + }); + + test('test method createMembership()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'userPhone': '+1 555 555 5555', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'roles': [],}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.createMembership( + teamId: '', + roles: [], + ); + expect(response, isA()); + + }); + + test('test method getMembership()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'userPhone': '+1 555 555 5555', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'roles': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.getMembership( + teamId: '', + membershipId: '', + ); + expect(response, isA()); + + }); + + test('test method updateMembership()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'userPhone': '+1 555 555 5555', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'roles': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.updateMembership( + teamId: '', + membershipId: '', + roles: [], + ); + expect(response, isA()); + + }); + + test('test method deleteMembership()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.deleteMembership( + teamId: '', + membershipId: '', + ); + }); + + test('test method updateMembershipStatus()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'userPhone': '+1 555 555 5555', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'roles': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.updateMembershipStatus( + teamId: '', + membershipId: '', + userId: '', + secret: '', + ); + expect(response, isA()); + + }); + + test('test method getPrefs()', () async { + + final Map data = {}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.getPrefs( + teamId: '', + ); + expect(response, isA()); + + }); + + test('test method updatePrefs()', () async { + + final Map data = {}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); - final response = await teams.getPrefs( - teamId: '', - ); - expect(response, isA()); - }); - test('test method updatePrefs()', () async { - final Map data = {}; + final response = await teams.updatePrefs( + teamId: '', + prefs: {}, + ); + expect(response, isA()); - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + }); - final response = await teams.updatePrefs( - teamId: '', - prefs: {}, - ); - expect(response, isA()); }); - }); } diff --git a/test/src/models/algo_argon2_test.dart b/test/src/models/algo_argon2_test.dart index 261daa46..15e85f5a 100644 --- a/test/src/models/algo_argon2_test.dart +++ b/test/src/models/algo_argon2_test.dart @@ -14,10 +14,10 @@ void main() { final map = model.toMap(); final result = AlgoArgon2.fromMap(map); - expect(result.type, 'argon2'); - expect(result.memoryCost, 65536); - expect(result.timeCost, 4); - expect(result.threads, 3); - }); + expect(result.type, 'argon2'); + expect(result.memoryCost, 65536); + expect(result.timeCost, 4); + expect(result.threads, 3); + }); }); } diff --git a/test/src/models/algo_bcrypt_test.dart b/test/src/models/algo_bcrypt_test.dart index 3da36624..87a3ca3c 100644 --- a/test/src/models/algo_bcrypt_test.dart +++ b/test/src/models/algo_bcrypt_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = AlgoBcrypt.fromMap(map); - expect(result.type, 'bcrypt'); - }); + expect(result.type, 'bcrypt'); + }); }); } diff --git a/test/src/models/algo_md5_test.dart b/test/src/models/algo_md5_test.dart index e58fa5b5..3b842e6c 100644 --- a/test/src/models/algo_md5_test.dart +++ b/test/src/models/algo_md5_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = AlgoMd5.fromMap(map); - expect(result.type, 'md5'); - }); + expect(result.type, 'md5'); + }); }); } diff --git a/test/src/models/algo_phpass_test.dart b/test/src/models/algo_phpass_test.dart index 3bcbb488..49b1e22c 100644 --- a/test/src/models/algo_phpass_test.dart +++ b/test/src/models/algo_phpass_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = AlgoPhpass.fromMap(map); - expect(result.type, 'phpass'); - }); + expect(result.type, 'phpass'); + }); }); } diff --git a/test/src/models/algo_scrypt_modified_test.dart b/test/src/models/algo_scrypt_modified_test.dart index b2084927..dd7fa8c3 100644 --- a/test/src/models/algo_scrypt_modified_test.dart +++ b/test/src/models/algo_scrypt_modified_test.dart @@ -8,18 +8,16 @@ void main() { type: 'scryptMod', salt: 'UxLMreBr6tYyjQ==', saltSeparator: 'Bw==', - signerKey: - 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ==', + signerKey: 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ==', ); final map = model.toMap(); final result = AlgoScryptModified.fromMap(map); - expect(result.type, 'scryptMod'); - expect(result.salt, 'UxLMreBr6tYyjQ=='); - expect(result.saltSeparator, 'Bw=='); - expect(result.signerKey, - 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ=='); - }); + expect(result.type, 'scryptMod'); + expect(result.salt, 'UxLMreBr6tYyjQ=='); + expect(result.saltSeparator, 'Bw=='); + expect(result.signerKey, 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ=='); + }); }); } diff --git a/test/src/models/algo_scrypt_test.dart b/test/src/models/algo_scrypt_test.dart index 8c131568..c7d9cdbf 100644 --- a/test/src/models/algo_scrypt_test.dart +++ b/test/src/models/algo_scrypt_test.dart @@ -15,11 +15,11 @@ void main() { final map = model.toMap(); final result = AlgoScrypt.fromMap(map); - expect(result.type, 'scrypt'); - expect(result.costCpu, 8); - expect(result.costMemory, 14); - expect(result.costParallel, 1); - expect(result.length, 64); - }); + expect(result.type, 'scrypt'); + expect(result.costCpu, 8); + expect(result.costMemory, 14); + expect(result.costParallel, 1); + expect(result.length, 64); + }); }); } diff --git a/test/src/models/algo_sha_test.dart b/test/src/models/algo_sha_test.dart index d080569c..ae58b57e 100644 --- a/test/src/models/algo_sha_test.dart +++ b/test/src/models/algo_sha_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = AlgoSha.fromMap(map); - expect(result.type, 'sha'); - }); + expect(result.type, 'sha'); + }); }); } diff --git a/test/src/models/continent_list_test.dart b/test/src/models/continent_list_test.dart index e71dcae1..8de695b0 100644 --- a/test/src/models/continent_list_test.dart +++ b/test/src/models/continent_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = ContinentList.fromMap(map); - expect(result.total, 5); - expect(result.continents, []); - }); + expect(result.total, 5); + expect(result.continents, []); + }); }); } diff --git a/test/src/models/continent_test.dart b/test/src/models/continent_test.dart index 85e559f5..d5242a4e 100644 --- a/test/src/models/continent_test.dart +++ b/test/src/models/continent_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = Continent.fromMap(map); - expect(result.name, 'Europe'); - expect(result.code, 'EU'); - }); + expect(result.name, 'Europe'); + expect(result.code, 'EU'); + }); }); } diff --git a/test/src/models/country_list_test.dart b/test/src/models/country_list_test.dart index 6df5c584..869f5db6 100644 --- a/test/src/models/country_list_test.dart +++ b/test/src/models/country_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = CountryList.fromMap(map); - expect(result.total, 5); - expect(result.countries, []); - }); + expect(result.total, 5); + expect(result.countries, []); + }); }); } diff --git a/test/src/models/country_test.dart b/test/src/models/country_test.dart index d5404a7f..bc66ab7b 100644 --- a/test/src/models/country_test.dart +++ b/test/src/models/country_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = Country.fromMap(map); - expect(result.name, 'United States'); - expect(result.code, 'US'); - }); + expect(result.name, 'United States'); + expect(result.code, 'US'); + }); }); } diff --git a/test/src/models/currency_list_test.dart b/test/src/models/currency_list_test.dart index d7410db8..09da675c 100644 --- a/test/src/models/currency_list_test.dart +++ b/test/src/models/currency_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = CurrencyList.fromMap(map); - expect(result.total, 5); - expect(result.currencies, []); - }); + expect(result.total, 5); + expect(result.currencies, []); + }); }); } diff --git a/test/src/models/currency_test.dart b/test/src/models/currency_test.dart index 00e046c7..29890008 100644 --- a/test/src/models/currency_test.dart +++ b/test/src/models/currency_test.dart @@ -17,13 +17,13 @@ void main() { final map = model.toMap(); final result = Currency.fromMap(map); - expect(result.symbol, '\$'); - expect(result.name, 'US dollar'); - expect(result.symbolNative, '\$'); - expect(result.decimalDigits, 2); - expect(result.rounding, 0); - expect(result.code, 'USD'); - expect(result.namePlural, 'US dollars'); - }); + expect(result.symbol, '\$'); + expect(result.name, 'US dollar'); + expect(result.symbolNative, '\$'); + expect(result.decimalDigits, 2); + expect(result.rounding, 0); + expect(result.code, 'USD'); + expect(result.namePlural, 'US dollars'); + }); }); } diff --git a/test/src/models/document_list_test.dart b/test/src/models/document_list_test.dart index 217d37e8..f1a5b3cc 100644 --- a/test/src/models/document_list_test.dart +++ b/test/src/models/document_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = DocumentList.fromMap(map); - expect(result.total, 5); - expect(result.documents, []); - }); + expect(result.total, 5); + expect(result.documents, []); + }); }); } diff --git a/test/src/models/document_test.dart b/test/src/models/document_test.dart index 397b5fab..6c1fbb77 100644 --- a/test/src/models/document_test.dart +++ b/test/src/models/document_test.dart @@ -18,13 +18,13 @@ void main() { final map = model.toMap(); final result = Document.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$sequence, '1'); - expect(result.$collectionId, '5e5ea5c15117e'); - expect(result.$databaseId, '5e5ea5c15117e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$sequence, '1'); + expect(result.$collectionId, '5e5ea5c15117e'); + expect(result.$databaseId, '5e5ea5c15117e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + }); }); } diff --git a/test/src/models/execution_list_test.dart b/test/src/models/execution_list_test.dart index a3305e55..fe74af58 100644 --- a/test/src/models/execution_list_test.dart +++ b/test/src/models/execution_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = ExecutionList.fromMap(map); - expect(result.total, 5); - expect(result.executions, []); - }); + expect(result.total, 5); + expect(result.executions, []); + }); }); } diff --git a/test/src/models/execution_test.dart b/test/src/models/execution_test.dart index 80ef508a..6d9bf33c 100644 --- a/test/src/models/execution_test.dart +++ b/test/src/models/execution_test.dart @@ -28,23 +28,23 @@ void main() { final map = model.toMap(); final result = Execution.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - expect(result.functionId, '5e5ea6g16897e'); - expect(result.deploymentId, '5e5ea5c16897e'); - expect(result.trigger, ExecutionTrigger.http); - expect(result.status, ExecutionStatus.waiting); - expect(result.requestMethod, 'GET'); - expect(result.requestPath, '/articles?id=5'); - expect(result.requestHeaders, []); - expect(result.responseStatusCode, 200); - expect(result.responseBody, ''); - expect(result.responseHeaders, []); - expect(result.logs, ''); - expect(result.errors, ''); - expect(result.duration, 0.4); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + expect(result.functionId, '5e5ea6g16897e'); + expect(result.deploymentId, '5e5ea5c16897e'); + expect(result.trigger, ExecutionTrigger.http); + expect(result.status, ExecutionStatus.waiting); + expect(result.requestMethod, 'GET'); + expect(result.requestPath, '/articles?id=5'); + expect(result.requestHeaders, []); + expect(result.responseStatusCode, 200); + expect(result.responseBody, ''); + expect(result.responseHeaders, []); + expect(result.logs, ''); + expect(result.errors, ''); + expect(result.duration, 0.4); + }); }); } diff --git a/test/src/models/file_list_test.dart b/test/src/models/file_list_test.dart index 8e02f65e..d8e6c95c 100644 --- a/test/src/models/file_list_test.dart +++ b/test/src/models/file_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = FileList.fromMap(map); - expect(result.total, 5); - expect(result.files, []); - }); + expect(result.total, 5); + expect(result.files, []); + }); }); } diff --git a/test/src/models/file_test.dart b/test/src/models/file_test.dart index 7f132646..8a734a08 100644 --- a/test/src/models/file_test.dart +++ b/test/src/models/file_test.dart @@ -24,20 +24,20 @@ void main() { final map = model.toMap(); final result = File.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.bucketId, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - expect(result.name, 'Pink.png'); - expect(result.signature, '5d529fd02b544198ae075bd57c1762bb'); - expect(result.mimeType, 'image/png'); - expect(result.sizeOriginal, 17890); - expect(result.sizeActual, 12345); - expect(result.chunksTotal, 17890); - expect(result.chunksUploaded, 17890); - expect(result.encryption, true); - expect(result.compression, 'gzip'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.bucketId, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + expect(result.name, 'Pink.png'); + expect(result.signature, '5d529fd02b544198ae075bd57c1762bb'); + expect(result.mimeType, 'image/png'); + expect(result.sizeOriginal, 17890); + expect(result.sizeActual, 12345); + expect(result.chunksTotal, 17890); + expect(result.chunksUploaded, 17890); + expect(result.encryption, true); + expect(result.compression, 'gzip'); + }); }); } diff --git a/test/src/models/headers_test.dart b/test/src/models/headers_test.dart index 9252b469..489891d4 100644 --- a/test/src/models/headers_test.dart +++ b/test/src/models/headers_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = Headers.fromMap(map); - expect(result.name, 'Content-Type'); - expect(result.value, 'application/json'); - }); + expect(result.name, 'Content-Type'); + expect(result.value, 'application/json'); + }); }); } diff --git a/test/src/models/identity_list_test.dart b/test/src/models/identity_list_test.dart index 8c35afec..65f562a7 100644 --- a/test/src/models/identity_list_test.dart +++ b/test/src/models/identity_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = IdentityList.fromMap(map); - expect(result.total, 5); - expect(result.identities, []); - }); + expect(result.total, 5); + expect(result.identities, []); + }); }); } diff --git a/test/src/models/identity_test.dart b/test/src/models/identity_test.dart index 525af4ea..708c8c60 100644 --- a/test/src/models/identity_test.dart +++ b/test/src/models/identity_test.dart @@ -20,16 +20,16 @@ void main() { final map = model.toMap(); final result = Identity.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5bb8c16897e'); - expect(result.provider, 'email'); - expect(result.providerUid, '5e5bb8c16897e'); - expect(result.providerEmail, 'user@example.com'); - expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); - expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5bb8c16897e'); + expect(result.provider, 'email'); + expect(result.providerUid, '5e5bb8c16897e'); + expect(result.providerEmail, 'user@example.com'); + expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); + expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + }); }); } diff --git a/test/src/models/jwt_test.dart b/test/src/models/jwt_test.dart index 93376af1..e616a956 100644 --- a/test/src/models/jwt_test.dart +++ b/test/src/models/jwt_test.dart @@ -5,15 +5,13 @@ void main() { group('Jwt', () { test('model', () { final model = Jwt( - jwt: - 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', + jwt: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', ); final map = model.toMap(); final result = Jwt.fromMap(map); - expect(result.jwt, - 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'); - }); + expect(result.jwt, 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'); + }); }); } diff --git a/test/src/models/language_list_test.dart b/test/src/models/language_list_test.dart index a07c0b5f..94c1e33f 100644 --- a/test/src/models/language_list_test.dart +++ b/test/src/models/language_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = LanguageList.fromMap(map); - expect(result.total, 5); - expect(result.languages, []); - }); + expect(result.total, 5); + expect(result.languages, []); + }); }); } diff --git a/test/src/models/language_test.dart b/test/src/models/language_test.dart index 4a6c96c1..d4087d5e 100644 --- a/test/src/models/language_test.dart +++ b/test/src/models/language_test.dart @@ -13,9 +13,9 @@ void main() { final map = model.toMap(); final result = Language.fromMap(map); - expect(result.name, 'Italian'); - expect(result.code, 'it'); - expect(result.nativeName, 'Italiano'); - }); + expect(result.name, 'Italian'); + expect(result.code, 'it'); + expect(result.nativeName, 'Italiano'); + }); }); } diff --git a/test/src/models/locale_code_list_test.dart b/test/src/models/locale_code_list_test.dart index 65b44ad1..b6de5137 100644 --- a/test/src/models/locale_code_list_test.dart +++ b/test/src/models/locale_code_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = LocaleCodeList.fromMap(map); - expect(result.total, 5); - expect(result.localeCodes, []); - }); + expect(result.total, 5); + expect(result.localeCodes, []); + }); }); } diff --git a/test/src/models/locale_code_test.dart b/test/src/models/locale_code_test.dart index 88cf157b..f0fcdbce 100644 --- a/test/src/models/locale_code_test.dart +++ b/test/src/models/locale_code_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = LocaleCode.fromMap(map); - expect(result.code, 'en-us'); - expect(result.name, 'US'); - }); + expect(result.code, 'en-us'); + expect(result.name, 'US'); + }); }); } diff --git a/test/src/models/locale_test.dart b/test/src/models/locale_test.dart index 49cb1fc9..72102045 100644 --- a/test/src/models/locale_test.dart +++ b/test/src/models/locale_test.dart @@ -17,13 +17,13 @@ void main() { final map = model.toMap(); final result = Locale.fromMap(map); - expect(result.ip, '127.0.0.1'); - expect(result.countryCode, 'US'); - expect(result.country, 'United States'); - expect(result.continentCode, 'NA'); - expect(result.continent, 'North America'); - expect(result.eu, true); - expect(result.currency, 'USD'); - }); + expect(result.ip, '127.0.0.1'); + expect(result.countryCode, 'US'); + expect(result.country, 'United States'); + expect(result.continentCode, 'NA'); + expect(result.continent, 'North America'); + expect(result.eu, true); + expect(result.currency, 'USD'); + }); }); } diff --git a/test/src/models/log_list_test.dart b/test/src/models/log_list_test.dart index b07ca8ee..84c560c8 100644 --- a/test/src/models/log_list_test.dart +++ b/test/src/models/log_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = LogList.fromMap(map); - expect(result.total, 5); - expect(result.logs, []); - }); + expect(result.total, 5); + expect(result.logs, []); + }); }); } diff --git a/test/src/models/log_test.dart b/test/src/models/log_test.dart index c8211d3b..1b463633 100644 --- a/test/src/models/log_test.dart +++ b/test/src/models/log_test.dart @@ -32,28 +32,28 @@ void main() { final map = model.toMap(); final result = Log.fromMap(map); - expect(result.event, 'account.sessions.create'); - expect(result.userId, '610fc2f985ee0'); - expect(result.userEmail, 'john@appwrite.io'); - expect(result.userName, 'John Doe'); - expect(result.mode, 'admin'); - expect(result.userType, 'user'); - expect(result.ip, '127.0.0.1'); - expect(result.time, '2020-10-15T06:38:00.000+00:00'); - expect(result.osCode, 'Mac'); - expect(result.osName, 'Mac'); - expect(result.osVersion, 'Mac'); - expect(result.clientType, 'browser'); - expect(result.clientCode, 'CM'); - expect(result.clientName, 'Chrome Mobile iOS'); - expect(result.clientVersion, '84.0'); - expect(result.clientEngine, 'WebKit'); - expect(result.clientEngineVersion, '605.1.15'); - expect(result.deviceName, 'smartphone'); - expect(result.deviceBrand, 'Google'); - expect(result.deviceModel, 'Nexus 5'); - expect(result.countryCode, 'US'); - expect(result.countryName, 'United States'); - }); + expect(result.event, 'account.sessions.create'); + expect(result.userId, '610fc2f985ee0'); + expect(result.userEmail, 'john@appwrite.io'); + expect(result.userName, 'John Doe'); + expect(result.mode, 'admin'); + expect(result.userType, 'user'); + expect(result.ip, '127.0.0.1'); + expect(result.time, '2020-10-15T06:38:00.000+00:00'); + expect(result.osCode, 'Mac'); + expect(result.osName, 'Mac'); + expect(result.osVersion, 'Mac'); + expect(result.clientType, 'browser'); + expect(result.clientCode, 'CM'); + expect(result.clientName, 'Chrome Mobile iOS'); + expect(result.clientVersion, '84.0'); + expect(result.clientEngine, 'WebKit'); + expect(result.clientEngineVersion, '605.1.15'); + expect(result.deviceName, 'smartphone'); + expect(result.deviceBrand, 'Google'); + expect(result.deviceModel, 'Nexus 5'); + expect(result.countryCode, 'US'); + expect(result.countryName, 'United States'); + }); }); } diff --git a/test/src/models/membership_list_test.dart b/test/src/models/membership_list_test.dart index 4f30c48e..bb1f0946 100644 --- a/test/src/models/membership_list_test.dart +++ b/test/src/models/membership_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = MembershipList.fromMap(map); - expect(result.total, 5); - expect(result.memberships, []); - }); + expect(result.total, 5); + expect(result.memberships, []); + }); }); } diff --git a/test/src/models/membership_test.dart b/test/src/models/membership_test.dart index b2b8bd3d..ab136c24 100644 --- a/test/src/models/membership_test.dart +++ b/test/src/models/membership_test.dart @@ -25,21 +25,21 @@ void main() { final map = model.toMap(); final result = Membership.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5ea5c16897e'); - expect(result.userName, 'John Doe'); - expect(result.userEmail, 'john@appwrite.io'); - expect(result.userPhone, '+1 555 555 5555'); - expect(result.teamId, '5e5ea5c16897e'); - expect(result.teamName, 'VIP'); - expect(result.invited, '2020-10-15T06:38:00.000+00:00'); - expect(result.joined, '2020-10-15T06:38:00.000+00:00'); - expect(result.confirm, true); - expect(result.mfa, true); - expect(result.userAccessedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.roles, []); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5ea5c16897e'); + expect(result.userName, 'John Doe'); + expect(result.userEmail, 'john@appwrite.io'); + expect(result.userPhone, '+1 555 555 5555'); + expect(result.teamId, '5e5ea5c16897e'); + expect(result.teamName, 'VIP'); + expect(result.invited, '2020-10-15T06:38:00.000+00:00'); + expect(result.joined, '2020-10-15T06:38:00.000+00:00'); + expect(result.confirm, true); + expect(result.mfa, true); + expect(result.userAccessedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.roles, []); + }); }); } diff --git a/test/src/models/mfa_challenge_test.dart b/test/src/models/mfa_challenge_test.dart index 5d3febca..9410baa3 100644 --- a/test/src/models/mfa_challenge_test.dart +++ b/test/src/models/mfa_challenge_test.dart @@ -14,10 +14,10 @@ void main() { final map = model.toMap(); final result = MfaChallenge.fromMap(map); - expect(result.$id, 'bb8ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5ea5c168bb8'); - expect(result.expire, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, 'bb8ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5ea5c168bb8'); + expect(result.expire, '2020-10-15T06:38:00.000+00:00'); + }); }); } diff --git a/test/src/models/mfa_factors_test.dart b/test/src/models/mfa_factors_test.dart index 64cc55e4..ed6467d3 100644 --- a/test/src/models/mfa_factors_test.dart +++ b/test/src/models/mfa_factors_test.dart @@ -14,10 +14,10 @@ void main() { final map = model.toMap(); final result = MfaFactors.fromMap(map); - expect(result.totp, true); - expect(result.phone, true); - expect(result.email, true); - expect(result.recoveryCode, true); - }); + expect(result.totp, true); + expect(result.phone, true); + expect(result.email, true); + expect(result.recoveryCode, true); + }); }); } diff --git a/test/src/models/mfa_recovery_codes_test.dart b/test/src/models/mfa_recovery_codes_test.dart index 500913c8..fa097a49 100644 --- a/test/src/models/mfa_recovery_codes_test.dart +++ b/test/src/models/mfa_recovery_codes_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = MfaRecoveryCodes.fromMap(map); - expect(result.recoveryCodes, []); - }); + expect(result.recoveryCodes, []); + }); }); } diff --git a/test/src/models/mfa_type_test.dart b/test/src/models/mfa_type_test.dart index 81657394..3f45d288 100644 --- a/test/src/models/mfa_type_test.dart +++ b/test/src/models/mfa_type_test.dart @@ -6,16 +6,14 @@ void main() { test('model', () { final model = MfaType( secret: '[SHARED_SECRET]', - uri: - 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', + uri: 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', ); final map = model.toMap(); final result = MfaType.fromMap(map); - expect(result.secret, '[SHARED_SECRET]'); - expect(result.uri, - 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite'); - }); + expect(result.secret, '[SHARED_SECRET]'); + expect(result.uri, 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite'); + }); }); } diff --git a/test/src/models/phone_list_test.dart b/test/src/models/phone_list_test.dart index bf22a5c7..6ca46a63 100644 --- a/test/src/models/phone_list_test.dart +++ b/test/src/models/phone_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = PhoneList.fromMap(map); - expect(result.total, 5); - expect(result.phones, []); - }); + expect(result.total, 5); + expect(result.phones, []); + }); }); } diff --git a/test/src/models/phone_test.dart b/test/src/models/phone_test.dart index f70db0e3..d0e5333b 100644 --- a/test/src/models/phone_test.dart +++ b/test/src/models/phone_test.dart @@ -13,9 +13,9 @@ void main() { final map = model.toMap(); final result = Phone.fromMap(map); - expect(result.code, '+1'); - expect(result.countryCode, 'US'); - expect(result.countryName, 'United States'); - }); + expect(result.code, '+1'); + expect(result.countryCode, 'US'); + expect(result.countryName, 'United States'); + }); }); } diff --git a/test/src/models/preferences_test.dart b/test/src/models/preferences_test.dart index 9db30b03..acde349c 100644 --- a/test/src/models/preferences_test.dart +++ b/test/src/models/preferences_test.dart @@ -10,6 +10,7 @@ void main() { final map = model.toMap(); final result = Preferences.fromMap(map); + }); }); } diff --git a/test/src/models/presence_list_test.dart b/test/src/models/presence_list_test.dart index 46f69af6..57a86348 100644 --- a/test/src/models/presence_list_test.dart +++ b/test/src/models/presence_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = PresenceList.fromMap(map); - expect(result.total, 5); - expect(result.presences, []); - }); + expect(result.total, 5); + expect(result.presences, []); + }); }); } diff --git a/test/src/models/presence_test.dart b/test/src/models/presence_test.dart index ef2ebe31..edcfe5f5 100644 --- a/test/src/models/presence_test.dart +++ b/test/src/models/presence_test.dart @@ -16,12 +16,12 @@ void main() { final map = model.toMap(); final result = Presence.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - expect(result.userId, '674af8f3e12a5f9ac0be'); - expect(result.source, 'HTTP'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + expect(result.userId, '674af8f3e12a5f9ac0be'); + expect(result.source, 'HTTP'); + }); }); } diff --git a/test/src/models/row_list_test.dart b/test/src/models/row_list_test.dart index 12693926..d4900dd4 100644 --- a/test/src/models/row_list_test.dart +++ b/test/src/models/row_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = RowList.fromMap(map); - expect(result.total, 5); - expect(result.rows, []); - }); + expect(result.total, 5); + expect(result.rows, []); + }); }); } diff --git a/test/src/models/row_test.dart b/test/src/models/row_test.dart index 564bf303..4e72a449 100644 --- a/test/src/models/row_test.dart +++ b/test/src/models/row_test.dart @@ -18,13 +18,13 @@ void main() { final map = model.toMap(); final result = Row.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$sequence, '1'); - expect(result.$tableId, '5e5ea5c15117e'); - expect(result.$databaseId, '5e5ea5c15117e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$sequence, '1'); + expect(result.$tableId, '5e5ea5c15117e'); + expect(result.$databaseId, '5e5ea5c15117e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + }); }); } diff --git a/test/src/models/session_list_test.dart b/test/src/models/session_list_test.dart index 708e0583..eaab249e 100644 --- a/test/src/models/session_list_test.dart +++ b/test/src/models/session_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = SessionList.fromMap(map); - expect(result.total, 5); - expect(result.sessions, []); - }); + expect(result.total, 5); + expect(result.sessions, []); + }); }); } diff --git a/test/src/models/session_test.dart b/test/src/models/session_test.dart index 689e6048..0177e477 100644 --- a/test/src/models/session_test.dart +++ b/test/src/models/session_test.dart @@ -39,35 +39,35 @@ void main() { final map = model.toMap(); final result = Session.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5bb8c16897e'); - expect(result.expire, '2020-10-15T06:38:00.000+00:00'); - expect(result.provider, 'email'); - expect(result.providerUid, 'user@example.com'); - expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); - expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - expect(result.ip, '127.0.0.1'); - expect(result.osCode, 'Mac'); - expect(result.osName, 'Mac'); - expect(result.osVersion, 'Mac'); - expect(result.clientType, 'browser'); - expect(result.clientCode, 'CM'); - expect(result.clientName, 'Chrome Mobile iOS'); - expect(result.clientVersion, '84.0'); - expect(result.clientEngine, 'WebKit'); - expect(result.clientEngineVersion, '605.1.15'); - expect(result.deviceName, 'smartphone'); - expect(result.deviceBrand, 'Google'); - expect(result.deviceModel, 'Nexus 5'); - expect(result.countryCode, 'US'); - expect(result.countryName, 'United States'); - expect(result.current, true); - expect(result.factors, []); - expect(result.secret, '5e5bb8c16897e'); - expect(result.mfaUpdatedAt, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5bb8c16897e'); + expect(result.expire, '2020-10-15T06:38:00.000+00:00'); + expect(result.provider, 'email'); + expect(result.providerUid, 'user@example.com'); + expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); + expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + expect(result.ip, '127.0.0.1'); + expect(result.osCode, 'Mac'); + expect(result.osName, 'Mac'); + expect(result.osVersion, 'Mac'); + expect(result.clientType, 'browser'); + expect(result.clientCode, 'CM'); + expect(result.clientName, 'Chrome Mobile iOS'); + expect(result.clientVersion, '84.0'); + expect(result.clientEngine, 'WebKit'); + expect(result.clientEngineVersion, '605.1.15'); + expect(result.deviceName, 'smartphone'); + expect(result.deviceBrand, 'Google'); + expect(result.deviceModel, 'Nexus 5'); + expect(result.countryCode, 'US'); + expect(result.countryName, 'United States'); + expect(result.current, true); + expect(result.factors, []); + expect(result.secret, '5e5bb8c16897e'); + expect(result.mfaUpdatedAt, '2020-10-15T06:38:00.000+00:00'); + }); }); } diff --git a/test/src/models/subscriber_test.dart b/test/src/models/subscriber_test.dart index 7445514c..94c6a502 100644 --- a/test/src/models/subscriber_test.dart +++ b/test/src/models/subscriber_test.dart @@ -10,15 +10,15 @@ void main() { $updatedAt: '2020-10-15T06:38:00.000+00:00', targetId: '259125845563242502', target: Target( - $id: '259125845563242502', - $createdAt: '2020-10-15T06:38:00.000+00:00', - $updatedAt: '2020-10-15T06:38:00.000+00:00', - name: 'Apple iPhone 12', - userId: '259125845563242502', - providerType: 'email', - identifier: 'token', - expired: true, - ), + $id: '259125845563242502', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Apple iPhone 12', + userId: '259125845563242502', + providerType: 'email', + identifier: 'token', + expired: true, + ), userId: '5e5ea5c16897e', userName: 'Aegon Targaryen', topicId: '259125845563242502', @@ -28,14 +28,14 @@ void main() { final map = model.toMap(); final result = Subscriber.fromMap(map); - expect(result.$id, '259125845563242502'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.targetId, '259125845563242502'); - expect(result.userId, '5e5ea5c16897e'); - expect(result.userName, 'Aegon Targaryen'); - expect(result.topicId, '259125845563242502'); - expect(result.providerType, 'email'); - }); + expect(result.$id, '259125845563242502'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.targetId, '259125845563242502'); + expect(result.userId, '5e5ea5c16897e'); + expect(result.userName, 'Aegon Targaryen'); + expect(result.topicId, '259125845563242502'); + expect(result.providerType, 'email'); + }); }); } diff --git a/test/src/models/target_test.dart b/test/src/models/target_test.dart index 49f1e75e..a49f3def 100644 --- a/test/src/models/target_test.dart +++ b/test/src/models/target_test.dart @@ -18,14 +18,14 @@ void main() { final map = model.toMap(); final result = Target.fromMap(map); - expect(result.$id, '259125845563242502'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.name, 'Apple iPhone 12'); - expect(result.userId, '259125845563242502'); - expect(result.providerType, 'email'); - expect(result.identifier, 'token'); - expect(result.expired, true); - }); + expect(result.$id, '259125845563242502'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.name, 'Apple iPhone 12'); + expect(result.userId, '259125845563242502'); + expect(result.providerType, 'email'); + expect(result.identifier, 'token'); + expect(result.expired, true); + }); }); } diff --git a/test/src/models/team_list_test.dart b/test/src/models/team_list_test.dart index fe2f4a85..a19b667d 100644 --- a/test/src/models/team_list_test.dart +++ b/test/src/models/team_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = TeamList.fromMap(map); - expect(result.total, 5); - expect(result.teams, []); - }); + expect(result.total, 5); + expect(result.teams, []); + }); }); } diff --git a/test/src/models/team_test.dart b/test/src/models/team_test.dart index f652f2c1..43b2e45c 100644 --- a/test/src/models/team_test.dart +++ b/test/src/models/team_test.dart @@ -16,11 +16,11 @@ void main() { final map = model.toMap(); final result = Team.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.name, 'VIP'); - expect(result.total, 7); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.name, 'VIP'); + expect(result.total, 7); + }); }); } diff --git a/test/src/models/token_test.dart b/test/src/models/token_test.dart index 8f0957c9..7ee4b268 100644 --- a/test/src/models/token_test.dart +++ b/test/src/models/token_test.dart @@ -16,12 +16,12 @@ void main() { final map = model.toMap(); final result = Token.fromMap(map); - expect(result.$id, 'bb8ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5ea5c168bb8'); - expect(result.secret, ''); - expect(result.expire, '2020-10-15T06:38:00.000+00:00'); - expect(result.phrase, 'Golden Fox'); - }); + expect(result.$id, 'bb8ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5ea5c168bb8'); + expect(result.secret, ''); + expect(result.expire, '2020-10-15T06:38:00.000+00:00'); + expect(result.phrase, 'Golden Fox'); + }); }); } diff --git a/test/src/models/transaction_list_test.dart b/test/src/models/transaction_list_test.dart index a524ef71..68023e18 100644 --- a/test/src/models/transaction_list_test.dart +++ b/test/src/models/transaction_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = TransactionList.fromMap(map); - expect(result.total, 5); - expect(result.transactions, []); - }); + expect(result.total, 5); + expect(result.transactions, []); + }); }); } diff --git a/test/src/models/transaction_test.dart b/test/src/models/transaction_test.dart index 0169427f..723ebac2 100644 --- a/test/src/models/transaction_test.dart +++ b/test/src/models/transaction_test.dart @@ -16,12 +16,12 @@ void main() { final map = model.toMap(); final result = Transaction.fromMap(map); - expect(result.$id, '259125845563242502'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.status, 'pending'); - expect(result.operations, 5); - expect(result.expiresAt, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, '259125845563242502'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.status, 'pending'); + expect(result.operations, 5); + expect(result.expiresAt, '2020-10-15T06:38:00.000+00:00'); + }); }); } diff --git a/test/src/models/user_test.dart b/test/src/models/user_test.dart index 77c7dd97..c058ea26 100644 --- a/test/src/models/user_test.dart +++ b/test/src/models/user_test.dart @@ -26,21 +26,21 @@ void main() { final map = model.toMap(); final result = User.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.name, 'John Doe'); - expect(result.registration, '2020-10-15T06:38:00.000+00:00'); - expect(result.status, true); - expect(result.labels, []); - expect(result.passwordUpdate, '2020-10-15T06:38:00.000+00:00'); - expect(result.email, 'john@appwrite.io'); - expect(result.phone, '+4930901820'); - expect(result.emailVerification, true); - expect(result.phoneVerification, true); - expect(result.mfa, true); - expect(result.targets, []); - expect(result.accessedAt, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.name, 'John Doe'); + expect(result.registration, '2020-10-15T06:38:00.000+00:00'); + expect(result.status, true); + expect(result.labels, []); + expect(result.passwordUpdate, '2020-10-15T06:38:00.000+00:00'); + expect(result.email, 'john@appwrite.io'); + expect(result.phone, '+4930901820'); + expect(result.emailVerification, true); + expect(result.phoneVerification, true); + expect(result.mfa, true); + expect(result.targets, []); + expect(result.accessedAt, '2020-10-15T06:38:00.000+00:00'); + }); }); } From 6fcc8d3c2b497480b0364ac3bc80e880a9a40d37 Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Thu, 25 Jun 2026 04:50:47 +0000 Subject: [PATCH 6/8] Commit from GitHub Actions (Format and push) --- lib/appwrite.dart | 2 +- lib/channel.dart | 20 +- lib/client_browser.dart | 2 +- lib/client_io.dart | 2 +- lib/operator.dart | 11 +- lib/query.dart | 91 +- lib/realtime_browser.dart | 2 +- lib/realtime_io.dart | 2 +- lib/role.dart | 2 +- lib/services/account.dart | 1560 +++++----- lib/services/avatars.dart | 351 ++- lib/services/databases.dart | 603 ++-- lib/services/functions.dart | 115 +- lib/services/graphql.dart | 50 +- lib/services/locale.dart | 142 +- lib/services/messaging.dart | 70 +- lib/services/presences.dart | 182 +- lib/services/storage.dart | 342 ++- lib/services/tables_db.dart | 547 ++-- lib/services/teams.dart | 421 +-- lib/src/client.dart | 4 +- lib/src/client_base.dart | 7 + lib/src/client_browser.dart | 15 +- lib/src/client_io.dart | 15 +- lib/src/client_mixin.dart | 9 +- lib/src/enums/authentication_factor.dart | 18 +- lib/src/enums/authenticator_type.dart | 12 +- lib/src/enums/browser.dart | 38 +- lib/src/enums/browser_permission.dart | 50 +- lib/src/enums/browser_theme.dart | 14 +- lib/src/enums/credit_card.dart | 44 +- lib/src/enums/execution_method.dart | 24 +- lib/src/enums/execution_status.dart | 20 +- lib/src/enums/execution_trigger.dart | 16 +- 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 | 96 +- lib/src/enums/timezone.dart | 848 +++--- lib/src/exception.dart | 2 +- lib/src/models/algo_argon2.dart | 62 +- lib/src/models/algo_bcrypt.dart | 32 +- lib/src/models/algo_md5.dart | 32 +- lib/src/models/algo_phpass.dart | 32 +- lib/src/models/algo_scrypt.dart | 86 +- lib/src/models/algo_scrypt_modified.dart | 62 +- lib/src/models/algo_sha.dart | 32 +- lib/src/models/continent.dart | 42 +- lib/src/models/continent_list.dart | 43 +- lib/src/models/country.dart | 42 +- lib/src/models/country_list.dart | 43 +- lib/src/models/currency.dart | 110 +- lib/src/models/currency_list.dart | 43 +- lib/src/models/document.dart | 102 +- lib/src/models/document_list.dart | 47 +- lib/src/models/execution.dart | 246 +- lib/src/models/execution_list.dart | 43 +- lib/src/models/file.dart | 194 +- lib/src/models/file_list.dart | 42 +- lib/src/models/headers.dart | 42 +- lib/src/models/identity.dart | 122 +- lib/src/models/identity_list.dart | 43 +- lib/src/models/jwt.dart | 32 +- lib/src/models/language.dart | 52 +- lib/src/models/language_list.dart | 43 +- lib/src/models/locale.dart | 110 +- lib/src/models/locale_code.dart | 42 +- lib/src/models/locale_code_list.dart | 43 +- lib/src/models/log.dart | 290 +- lib/src/models/log_list.dart | 42 +- lib/src/models/membership.dart | 206 +- lib/src/models/membership_list.dart | 43 +- lib/src/models/mfa_challenge.dart | 62 +- lib/src/models/mfa_factors.dart | 62 +- lib/src/models/mfa_recovery_codes.dart | 32 +- lib/src/models/mfa_type.dart | 42 +- lib/src/models/model.dart | 2 +- lib/src/models/phone.dart | 52 +- lib/src/models/phone_list.dart | 42 +- lib/src/models/preferences.dart | 32 +- lib/src/models/presence.dart | 112 +- lib/src/models/presence_list.dart | 43 +- lib/src/models/row.dart | 102 +- lib/src/models/row_list.dart | 46 +- lib/src/models/session.dart | 360 +-- lib/src/models/session_list.dart | 43 +- lib/src/models/subscriber.dart | 112 +- lib/src/models/target.dart | 112 +- lib/src/models/team.dart | 98 +- lib/src/models/team_list.dart | 42 +- lib/src/models/token.dart | 98 +- lib/src/models/transaction.dart | 98 +- lib/src/models/transaction_list.dart | 43 +- lib/src/models/user.dart | 332 +- lib/src/realtime.dart | 6 +- lib/src/realtime_io.dart | 4 +- lib/src/realtime_message.dart | 2 +- lib/src/realtime_mixin.dart | 31 +- lib/src/realtime_response.dart | 10 +- lib/src/realtime_stub.dart | 4 +- test/channel_test.dart | 42 +- test/query_test.dart | 1 - test/services/account_test.dart | 2691 ++++++++--------- test/services/avatars_test.dart | 204 +- test/services/databases_test.dart | 585 ++-- test/services/functions_test.dart | 188 +- test/services/graphql_test.dart | 71 +- test/services/locale_test.dart | 253 +- test/services/messaging_test.dart | 122 +- test/services/presences_test.dart | 202 +- test/services/storage_test.dart | 341 +-- test/services/tables_db_test.dart | 585 ++-- test/services/teams_test.dart | 555 ++-- test/src/models/algo_argon2_test.dart | 10 +- test/src/models/algo_bcrypt_test.dart | 4 +- test/src/models/algo_md5_test.dart | 4 +- test/src/models/algo_phpass_test.dart | 4 +- .../src/models/algo_scrypt_modified_test.dart | 14 +- test/src/models/algo_scrypt_test.dart | 12 +- test/src/models/algo_sha_test.dart | 4 +- test/src/models/continent_list_test.dart | 6 +- test/src/models/continent_test.dart | 6 +- test/src/models/country_list_test.dart | 6 +- test/src/models/country_test.dart | 6 +- test/src/models/currency_list_test.dart | 6 +- test/src/models/currency_test.dart | 16 +- test/src/models/document_list_test.dart | 6 +- test/src/models/document_test.dart | 16 +- test/src/models/execution_list_test.dart | 6 +- test/src/models/execution_test.dart | 36 +- test/src/models/file_list_test.dart | 6 +- test/src/models/file_test.dart | 30 +- test/src/models/headers_test.dart | 6 +- test/src/models/identity_list_test.dart | 6 +- test/src/models/identity_test.dart | 22 +- test/src/models/jwt_test.dart | 8 +- test/src/models/language_list_test.dart | 6 +- test/src/models/language_test.dart | 8 +- test/src/models/locale_code_list_test.dart | 6 +- test/src/models/locale_code_test.dart | 6 +- test/src/models/locale_test.dart | 16 +- test/src/models/log_list_test.dart | 6 +- test/src/models/log_test.dart | 46 +- test/src/models/membership_list_test.dart | 6 +- test/src/models/membership_test.dart | 32 +- test/src/models/mfa_challenge_test.dart | 10 +- test/src/models/mfa_factors_test.dart | 10 +- test/src/models/mfa_recovery_codes_test.dart | 4 +- test/src/models/mfa_type_test.dart | 10 +- test/src/models/phone_list_test.dart | 6 +- test/src/models/phone_test.dart | 8 +- test/src/models/preferences_test.dart | 1 - test/src/models/presence_list_test.dart | 6 +- test/src/models/presence_test.dart | 14 +- test/src/models/row_list_test.dart | 6 +- test/src/models/row_test.dart | 16 +- test/src/models/session_list_test.dart | 6 +- test/src/models/session_test.dart | 60 +- test/src/models/subscriber_test.dart | 36 +- test/src/models/target_test.dart | 18 +- test/src/models/team_list_test.dart | 6 +- test/src/models/team_test.dart | 12 +- test/src/models/token_test.dart | 14 +- test/src/models/transaction_list_test.dart | 6 +- test/src/models/transaction_test.dart | 14 +- test/src/models/user_test.dart | 32 +- 166 files changed, 8516 insertions(+), 8661 deletions(-) diff --git a/lib/appwrite.dart b/lib/appwrite.dart index 6615de8a..ae51be5e 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.9.x. +/// This SDK is compatible with Appwrite server version 1.9.x. /// For older versions, please check /// [previous releases](https://github.com/appwrite/sdk-for-flutter/releases). library appwrite; diff --git a/lib/channel.dart b/lib/channel.dart index d511f5a4..afc68efa 100644 --- a/lib/channel.dart +++ b/lib/channel.dart @@ -2,19 +2,33 @@ part of appwrite; // Marker classes for type safety class _Root {} + class _Database {} + class _Collection {} + class _Document {} + class _TablesDB {} + class _Table {} + class _Row {} + class _Bucket {} + class _File {} + class _Func {} + class _Execution {} + class _Team {} + class _Membership {} + class _Presence {} + class _Resolved {} // Helper function for normalizing ID @@ -99,15 +113,15 @@ extension DatabaseChannel on Channel<_Database> { /// Only available on Channel<_Collection> extension CollectionChannel on Channel<_Collection> { - Channel<_Document> document([String? id]) => _next<_Document>('documents', id); + Channel<_Document> document([String? id]) => + _next<_Document>('documents', id); } // --- TABLESDB ROUTE --- /// Only available on Channel<_TablesDB> extension TablesDBChannel on Channel<_TablesDB> { - Channel<_Table> table(String id) => - _next<_Table>('tables', id); + Channel<_Table> table(String id) => _next<_Table>('tables', id); } /// Only available on Channel<_Table> 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/operator.dart b/lib/operator.dart index 9dd7f4c7..337dda30 100644 --- a/lib/operator.dart +++ b/lib/operator.dart @@ -31,7 +31,7 @@ class Operator { result['method'] = method; - if(values != null) { + if (values != null) { result['values'] = values is List ? values : [values]; } @@ -147,8 +147,7 @@ class Operator { Operator._('arrayRemove', [value]).toString(); /// Remove duplicate values from an array attribute. - static String arrayUnique() => - Operator._('arrayUnique', []).toString(); + static String arrayUnique() => Operator._('arrayUnique', []).toString(); /// Keep only values that exist in both the current array and the provided array. static String arrayIntersect(List values) => @@ -173,8 +172,7 @@ class Operator { Operator._('stringReplace', [search, replace]).toString(); /// Toggle a boolean attribute. - static String toggle() => - Operator._('toggle', []).toString(); + static String toggle() => Operator._('toggle', []).toString(); /// Add days to a date attribute. static String dateAddDays(int days) => @@ -185,6 +183,5 @@ class Operator { Operator._('dateSubDays', [days]).toString(); /// Set a date attribute to the current date and time. - static String dateSetNow() => - Operator._('dateSetNow', []).toString(); + static String dateSetNow() => Operator._('dateSetNow', []).toString(); } diff --git a/lib/query.dart b/lib/query.dart index 95365bf7..3693dce6 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. @@ -140,50 +140,46 @@ class Query { Query._('notEndsWith', attribute, value).toString(); /// Filter resources where document was created before [value]. - static String createdBefore(String value) => - lessThan('\$createdAt', value); + static String createdBefore(String value) => lessThan('\$createdAt', value); /// Filter resources where document was created after [value]. - static String createdAfter(String value) => - greaterThan('\$createdAt', value); + static String createdAfter(String value) => greaterThan('\$createdAt', value); /// Filter resources where document was created between [start] and [end] (inclusive). static String createdBetween(String start, String end) => between('\$createdAt', start, end); /// Filter resources where document was updated before [value]. - static String updatedBefore(String value) => - lessThan('\$updatedAt', value); + static String updatedBefore(String value) => lessThan('\$updatedAt', value); /// Filter resources where document was updated after [value]. - static String updatedAfter(String value) => - greaterThan('\$updatedAt', value); + static String updatedAfter(String value) => greaterThan('\$updatedAt', value); /// Filter resources where document was updated between [start] and [end] (inclusive). static String updatedBetween(String start, String end) => between('\$updatedAt', start, end); static String or(List queries) => Query._( - 'or', - null, - queries.map((query) => jsonDecode(query)).toList(), - ).toString(); + 'or', + null, + queries.map((query) => jsonDecode(query)).toList(), + ).toString(); static String and(List queries) => Query._( - 'and', - null, - queries.map((query) => jsonDecode(query)).toList(), - ).toString(); + 'and', + null, + queries.map((query) => jsonDecode(query)).toList(), + ).toString(); /// Filter array elements where at least one element matches all the specified queries. /// /// [attribute] The attribute containing the array to filter on. /// [queries] The list of query strings to match against array elements. static String elemMatch(String attribute, List queries) => Query._( - 'elemMatch', - attribute, - queries.map((query) => jsonDecode(query)).toList(), - ).toString(); + 'elemMatch', + attribute, + queries.map((query) => jsonDecode(query)).toList(), + ).toString(); /// Specify which attributes should be returned by the API call. static String select(List attributes) => @@ -198,18 +194,17 @@ class Query { Query._('orderDesc', attribute).toString(); /// Sort results randomly. - static String orderRandom() => - Query._('orderRandom').toString(); + static String orderRandom() => Query._('orderRandom').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) => @@ -219,27 +214,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) => @@ -272,4 +283,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 9c021e93..48b60041 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 { final String apiPath = '/account'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -30,29 +29,30 @@ 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 { final String apiPath = '/account'; - final Map apiParams = { - 'userId': userId, - - 'email': email, - - 'password': password, - - if (name != null) 'name': name, - - }; + final Map apiParams = { + 'userId': userId, + 'email': email, + 'password': password, + if (name != null) 'name': name, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - 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 @@ -62,66 +62,65 @@ 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 { final String apiPath = '/account/email'; - final Map apiParams = { - 'email': email, - - 'password': password, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + 'email': email, + 'password': password, + }; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 list of identities for the currently logged in user. - Future listIdentities({List? queries, bool? total}) async { + Future listIdentities( + {List? queries, bool? total}) async { final String apiPath = '/account/identities'; - final Map apiParams = { - if (queries != null) 'queries': queries, + final Map apiParams = { + if (queries != null) 'queries': queries, + if (total != null) 'total': total, + }; - if (total != null) 'total': total, + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: 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 Map apiParams = { - }; + final String apiPath = '/account/identities/{identityId}' + .replaceAll('{identityId}', identityId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - 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 @@ -132,20 +131,20 @@ class Account extends Service { Future createJWT({int? duration}) async { final String apiPath = '/account/jwts'; - final Map apiParams = { - if (duration != null) 'duration': duration, + final Map apiParams = { + if (duration != null) 'duration': duration, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - 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 @@ -153,212 +152,224 @@ class Account extends Service { Future listLogs({List? queries, bool? total}) async { final String apiPath = '/account/logs'; - final Map apiParams = { - if (queries != null) 'queries': queries, - - if (total != null) 'total': total, - - }; + final Map apiParams = { + if (queries != null) 'queries': queries, + if (total != null) 'total': total, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 { final String apiPath = '/account/mfa'; - final Map apiParams = { - 'mfa': mfa, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + 'mfa': mfa, + }; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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); + @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 apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.MfaType.fromMap(res.data); + 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 = { - }; + Future createMFAAuthenticator( + {required enums.AuthenticatorType type}) async { + final String apiPath = + '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - return models.MfaType.fromMap(res.data); + 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, - - }; + Future updateMFAAuthenticator( + {required enums.AuthenticatorType type, required String otp}) async { + final String apiPath = + '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + 'otp': otp, + }; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - return models.User.fromMap(res.data); + 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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 { final String apiPath = '/account/mfa/challenges'; - final Map apiParams = { - 'factor': factor.value, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + 'factor': factor.value, + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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); } /// 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 { final String apiPath = '/account/mfa/challenges'; - final Map apiParams = { - 'factor': factor.value, + final Map apiParams = { + 'factor': factor.value, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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); } /// Complete the MFA challenge by providing the one-time password. Finish the @@ -366,26 +377,27 @@ 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 { final String apiPath = '/account/mfa/challenges'; - final Map apiParams = { - 'challengeId': challengeId, - - 'otp': otp, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 @@ -393,84 +405,83 @@ 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 { final String apiPath = '/account/mfa/challenges'; - final Map apiParams = { - 'challengeId': challengeId, + final Map apiParams = { + 'challengeId': challengeId, + 'otp': otp, + }; - 'otp': otp, + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 { final String apiPath = '/account/mfa/factors'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 { final String apiPath = '/account/mfa/factors'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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); } /// 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 { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -480,18 +491,17 @@ class Account extends Service { Future getMFARecoveryCodes() async { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -499,22 +509,23 @@ 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 { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 @@ -525,40 +536,41 @@ class Account extends Service { Future createMFARecoveryCodes() async { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 @@ -568,62 +580,62 @@ class Account extends Service { Future updateMFARecoveryCodes() async { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - 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 { final String apiPath = '/account/name'; - final Map apiParams = { - 'name': name, - - }; + final Map apiParams = { + 'name': name, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 { final String apiPath = '/account/password'; - final Map apiParams = { - 'password': password, - - if (oldPassword != null) 'oldPassword': oldPassword, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + 'password': password, + if (oldPassword != null) 'oldPassword': oldPassword, + }; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 @@ -631,43 +643,42 @@ 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 { final String apiPath = '/account/phone'; - final Map apiParams = { - 'phone': phone, + final Map apiParams = { + 'phone': phone, + 'password': password, + }; - 'password': password, + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 preferences as a key-value object for the currently logged in user. Future getPrefs() async { final String apiPath = '/account/prefs'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -676,20 +687,20 @@ class Account extends Service { Future updatePrefs({required Map prefs}) async { final String apiPath = '/account/prefs'; - final Map apiParams = { - 'prefs': prefs, + final Map apiParams = { + 'prefs': prefs, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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. @@ -700,25 +711,25 @@ 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 { final String apiPath = '/account/recovery'; - final Map apiParams = { - 'email': email, - - 'url': url, - - }; + final Map apiParams = { + 'email': email, + 'url': url, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 account password reset. Both the @@ -726,32 +737,33 @@ 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 { final 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - 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 @@ -759,18 +771,17 @@ class Account extends Service { Future listSessions() async { final String apiPath = '/account/sessions'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -778,18 +789,17 @@ class Account extends Service { Future deleteSessions() async { final String apiPath = '/account/sessions'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - 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 @@ -802,213 +812,216 @@ class Account extends Service { Future createAnonymousSession() async { final String apiPath = '/account/sessions/anonymous'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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); } /// 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 { final String apiPath = '/account/sessions/email'; - final Map apiParams = { - 'email': email, - - 'password': password, + final Map apiParams = { + 'email': email, + 'password': password, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 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 { final String apiPath = '/account/sessions/magic-url'; - final Map apiParams = { - 'userId': userId, - - 'secret': secret, - - }; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 = { - - if (success != null) 'success': success, - - if (failure != null) 'failure': failure, - - if (scopes != null) 'scopes': scopes, - - - 'project': client.config['project'], - }; - - final List query = []; - - params.forEach((key, value) { - if (value is List) { - for (var item in value) { - query.add( + /// + 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 = { + if (success != null) 'success': success, + if (failure != null) 'failure': failure, + if (scopes != null) '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); + } + } 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 { final String apiPath = '/account/sessions/phone'; - final Map apiParams = { - 'userId': userId, - - 'secret': secret, + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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); } /// 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 { final String apiPath = '/account/sessions/token'; - final Map apiParams = { - 'userId': userId, - - 'secret': secret, - - }; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 String apiPath = + '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, @@ -1017,20 +1030,20 @@ 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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 @@ -1039,18 +1052,18 @@ class Account extends Service { Future updateStatus() async { final String apiPath = '/account/status'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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); } /// Use this endpoint to register a device for push notifications. Provide a @@ -1058,27 +1071,28 @@ 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 { final String apiPath = '/account/targets/push'; - final Map apiParams = { - 'targetId': targetId, - - 'identifier': identifier, - - if (providerId != null) 'providerId': providerId, - - }; + final Map apiParams = { + 'targetId': targetId, + 'identifier': identifier, + if (providerId != null) 'providerId': providerId, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 @@ -1086,43 +1100,45 @@ 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, + 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Target.fromMap(res.data); + 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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 @@ -1134,32 +1150,31 @@ 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 { final String apiPath = '/account/tokens/email'; - final Map apiParams = { - 'userId': userId, + final Map apiParams = { + 'userId': userId, + 'email': email, + if (phrase != null) 'phrase': phrase, + }; - 'email': email, + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - if (phrase != null) 'phrase': phrase, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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); } /// Sends the user an email with a secret key for creating a session. If the @@ -1171,87 +1186,88 @@ 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 { final String apiPath = '/account/tokens/magic-url'; - final Map apiParams = { - 'userId': userId, - - 'email': email, - - if (url != null) 'url': url, - - if (phrase != null) 'phrase': phrase, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + 'userId': userId, + 'email': email, + if (url != null) 'url': url, + if (phrase != null) 'phrase': phrase, + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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); } /// 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 = { - - if (success != null) 'success': success, - - if (failure != null) 'failure': failure, - - if (scopes != null) 'scopes': scopes, - - - 'project': client.config['project'], - }; - - final List query = []; - - params.forEach((key, value) { - if (value is List) { - for (var item in value) { - query.add( + 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 = { + if (success != null) 'success': success, + if (failure != null) 'failure': failure, + if (scopes != null) '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); + } + } 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 @@ -1260,29 +1276,29 @@ 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 { final String apiPath = '/account/tokens/phone'; - final Map apiParams = { - 'userId': userId, - - 'phone': phone, + final Map apiParams = { + 'userId': userId, + 'phone': phone, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 @@ -1294,29 +1310,29 @@ 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 createEmailVerification({required String url}) async { final String apiPath = '/account/verifications/email'; - final Map apiParams = { - 'url': url, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + 'url': url, + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 send a verification message to your user email address @@ -1328,81 +1344,83 @@ 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. - /// - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.createEmailVerification` instead.') + /// + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.createEmailVerification` instead.') Future createVerification({required String url}) async { final String apiPath = '/account/verifications/email'; - final Map apiParams = { - 'url': url, + final Map apiParams = { + 'url': url, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 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 updateEmailVerification({required String userId, required String secret}) async { + Future updateEmailVerification( + {required String userId, required String secret}) async { final String apiPath = '/account/verifications/email'; - final Map apiParams = { - 'userId': userId, - - 'secret': secret, - - }; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - 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 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. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.updateEmailVerification` instead.') - Future updateVerification({required String userId, required String secret}) async { + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.updateEmailVerification` instead.') + Future updateVerification( + {required String userId, required String secret}) async { final String apiPath = '/account/verifications/email'; - final Map apiParams = { - 'userId': userId, - - 'secret': secret, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 @@ -1416,42 +1434,42 @@ class Account extends Service { Future createPhoneVerification() async { final String apiPath = '/account/verifications/phone'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 { final String apiPath = '/account/verifications/phone'; - final Map apiParams = { - 'userId': userId, - - 'secret': secret, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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); } } diff --git a/lib/services/avatars.dart b/lib/services/avatars.dart index 4dca3b16..cdd93e6e 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,139 +11,134 @@ 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 = { - - if (width != null) 'width': width, - - if (height != null) 'height': height, - - if (quality != null) 'quality': quality, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + if (width != null) 'width': width, + if (height != null) 'height': height, + if (quality != null) 'quality': quality, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 = { - - if (width != null) 'width': width, - - if (height != null) 'height': height, - - if (quality != null) 'quality': quality, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + if (width != null) 'width': width, + if (height != null) 'height': height, + if (quality != null) 'quality': quality, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 { final String apiPath = '/avatars/favicon'; - final Map params = { - - 'url': url, + final Map params = { + 'url': url, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { - - if (width != null) 'width': width, - - if (height != null) 'height': height, - - if (quality != null) 'quality': quality, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + if (width != null) 'width': width, + if (height != null) 'height': height, + if (quality != null) 'quality': quality, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 { final String apiPath = '/avatars/image'; - final Map params = { - - 'url': url, - - if (width != null) 'width': width, - - if (height != null) 'height': height, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + 'url': url, + if (width != null) 'width': width, + if (height != null) 'height': height, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 @@ -151,125 +146,117 @@ 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 { final String apiPath = '/avatars/initials'; - final Map params = { - - if (name != null) 'name': name, - - if (width != null) 'width': width, - - if (height != null) 'height': height, - - if (background != null) 'background': background, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + if (name != null) 'name': name, + if (width != null) 'width': width, + if (height != null) 'height': height, + if (background != null) 'background': background, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 { final String apiPath = '/avatars/qr'; - final Map params = { - - 'text': text, - - if (size != null) 'size': size, - - if (margin != null) 'margin': margin, - - if (download != null) 'download': download, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + 'text': text, + if (size != null) 'size': size, + if (margin != null) 'margin': margin, + if (download != null) 'download': download, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + final res = await client.call(HttpMethod.get, + path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// Use this endpoint to capture a screenshot of any website URL. This endpoint /// uses a headless browser to render the webpage and capture it as an image. - /// + /// /// You can configure the browser viewport size, theme, user agent, /// geolocation, permissions, and more. Capture either just the viewport or the /// full page scroll. - /// + /// /// When width and height are specified, the image is resized accordingly. If /// both dimensions are 0, the API provides an image at original size. If /// dimensions are not specified, the default viewport size is 1280x720px. - Future getScreenshot({required String url, Map? headers, int? viewportWidth, int? viewportHeight, double? scale, enums.BrowserTheme? theme, String? userAgent, bool? fullpage, String? locale, enums.Timezone? timezone, double? latitude, double? longitude, double? accuracy, bool? touch, List? permissions, int? sleep, int? width, int? height, int? quality, enums.ImageFormat? output}) async { + Future getScreenshot( + {required String url, + Map? headers, + int? viewportWidth, + int? viewportHeight, + double? scale, + enums.BrowserTheme? theme, + String? userAgent, + bool? fullpage, + String? locale, + enums.Timezone? timezone, + double? latitude, + double? longitude, + double? accuracy, + bool? touch, + List? permissions, + int? sleep, + int? width, + int? height, + int? quality, + enums.ImageFormat? output}) async { final String apiPath = '/avatars/screenshots'; - final Map params = { - - 'url': url, - - if (headers != null) 'headers': headers, - - if (viewportWidth != null) 'viewportWidth': viewportWidth, - - if (viewportHeight != null) 'viewportHeight': viewportHeight, - - if (scale != null) 'scale': scale, - - if (theme != null) 'theme': theme.value, - - if (userAgent != null) 'userAgent': userAgent, - - if (fullpage != null) 'fullpage': fullpage, - - if (locale != null) 'locale': locale, - - if (timezone != null) 'timezone': timezone.value, - - if (latitude != null) 'latitude': latitude, - - if (longitude != null) 'longitude': longitude, - - if (accuracy != null) 'accuracy': accuracy, - - if (touch != null) 'touch': touch, - - if (permissions != null) 'permissions': permissions.map((e) => e.value).toList(), - - if (sleep != null) 'sleep': sleep, - - if (width != null) 'width': width, - - if (height != null) 'height': height, - - if (quality != null) 'quality': quality, - - if (output != null) 'output': output.value, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + 'url': url, + if (headers != null) 'headers': headers, + if (viewportWidth != null) 'viewportWidth': viewportWidth, + if (viewportHeight != null) 'viewportHeight': viewportHeight, + if (scale != null) 'scale': scale, + if (theme != null) 'theme': theme.value, + if (userAgent != null) 'userAgent': userAgent, + if (fullpage != null) 'fullpage': fullpage, + if (locale != null) 'locale': locale, + if (timezone != null) 'timezone': timezone.value, + if (latitude != null) 'latitude': latitude, + if (longitude != null) 'longitude': longitude, + if (accuracy != null) 'accuracy': accuracy, + if (touch != null) 'touch': touch, + if (permissions != null) + 'permissions': permissions.map((e) => e.value).toList(), + if (sleep != null) 'sleep': sleep, + if (width != null) 'width': width, + if (height != null) 'height': height, + if (quality != null) 'quality': quality, + if (output != null) 'output': output.value, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + final res = await client.call(HttpMethod.get, + path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } } diff --git a/lib/services/databases.dart b/lib/services/databases.dart index 0bfd935a..0ff3fb72 100644 --- a/lib/services/databases.dart +++ b/lib/services/databases.dart @@ -1,339 +1,418 @@ 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); /// List transactions across all databases. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.listTransactions` instead.') - Future listTransactions({List? queries}) async { + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.listTransactions` instead.') + Future listTransactions( + {List? queries}) async { final String apiPath = '/databases/transactions'; - final Map apiParams = { - if (queries != null) 'queries': queries, + final Map apiParams = { + if (queries != null) 'queries': queries, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.TransactionList.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.TransactionList.fromMap(res.data); } /// Create a new transaction. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.createTransaction` instead.') + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.createTransaction` instead.') Future createTransaction({int? ttl}) async { final String apiPath = '/databases/transactions'; - final Map apiParams = { - if (ttl != null) 'ttl': ttl, - - }; + final Map apiParams = { + if (ttl != null) 'ttl': ttl, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Transaction.fromMap(res.data); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.Transaction.fromMap(res.data); } /// Get a transaction by its unique ID. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.getTransaction` instead.') - Future getTransaction({required String transactionId}) async { - final String apiPath = '/databases/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - }; + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.getTransaction` instead.') + Future getTransaction( + {required String transactionId}) async { + final String apiPath = '/databases/transactions/{transactionId}' + .replaceAll('{transactionId}', transactionId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - return models.Transaction.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.Transaction.fromMap(res.data); } /// Update a transaction, to either commit or roll back its operations. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.updateTransaction` instead.') - Future updateTransaction({required String transactionId, bool? commit, bool? rollback}) async { - final String apiPath = '/databases/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - if (commit != null) 'commit': commit, - - if (rollback != null) 'rollback': rollback, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Transaction.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.updateTransaction` instead.') + Future updateTransaction( + {required String transactionId, bool? commit, bool? rollback}) async { + final String apiPath = '/databases/transactions/{transactionId}' + .replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + if (commit != null) 'commit': commit, + if (rollback != null) 'rollback': rollback, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Transaction.fromMap(res.data); } /// Delete a transaction by its unique ID. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.deleteTransaction` instead.') + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.deleteTransaction` instead.') Future deleteTransaction({required String transactionId}) async { - final String apiPath = '/databases/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - }; + final String apiPath = '/databases/transactions/{transactionId}' + .replaceAll('{transactionId}', transactionId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - return res.data; + final res = await client.call(HttpMethod.delete, + path: apiPath, params: apiParams, headers: apiHeaders); + return res.data; } /// Create multiple operations in a single transaction. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.createOperations` instead.') - Future createOperations({required String transactionId, List? operations}) async { - final String apiPath = '/databases/transactions/{transactionId}/operations'.replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - if (operations != null) 'operations': operations, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Transaction.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.createOperations` instead.') + Future createOperations( + {required String transactionId, List? operations}) async { + final String apiPath = '/databases/transactions/{transactionId}/operations' + .replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + if (operations != null) 'operations': operations, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Transaction.fromMap(res.data); } /// 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, String? transactionId, bool? total, int? ttl}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - - if (transactionId != null) 'transactionId': transactionId, - - if (total != null) 'total': total, - - if (ttl != null) 'ttl': ttl, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, + String? transactionId, + bool? total, + int? ttl}) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + if (transactionId != null) 'transactionId': transactionId, + if (total != null) 'total': total, + if (ttl != null) 'ttl': ttl, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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, String? transactionId}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); - - final Map apiParams = { - 'documentId': documentId, - - 'data': data, - - 'permissions': permissions, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + String? transactionId}) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId); + + final Map apiParams = { + 'documentId': documentId, + 'data': data, + 'permissions': permissions, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, String? transactionId}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - - if (transactionId != null) 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, + String? transactionId}) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + if (transactionId != null) 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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, Map? data, List? permissions, String? transactionId}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - - final Map apiParams = { - if (data != null) 'data': data, - - 'permissions': permissions, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + Map? data, + List? permissions, + String? transactionId}) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId); + + final Map apiParams = { + if (data != null) 'data': data, + 'permissions': permissions, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, String? transactionId}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - - final Map apiParams = { - if (data != null) 'data': data, - - 'permissions': permissions, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + String? transactionId}) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId); + + final Map apiParams = { + if (data != null) 'data': data, + 'permissions': permissions, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, String? transactionId}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - - final Map apiParams = { - if (transactionId != null) 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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, + String? transactionId}) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId); + + final Map apiParams = { + if (transactionId != null) 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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, String? transactionId}) 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 = { - if (value != null) 'value': value, - - 'min': min, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + String? transactionId}) 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 = { + if (value != null) 'value': value, + 'min': min, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, String? transactionId}) 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 = { - if (value != null) 'value': value, - - 'max': max, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + String? transactionId}) 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 = { + if (value != null) 'value': value, + 'max': max, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); } } diff --git a/lib/services/functions.dart b/lib/services/functions.dart index 0640f80f..ed97921b 100644 --- a/lib/services/functions.dart +++ b/lib/services/functions.dart @@ -1,82 +1,87 @@ 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, bool? total}) async { - final String apiPath = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); + Future listExecutions( + {required String functionId, List? queries, bool? total}) async { + final String apiPath = '/functions/{functionId}/executions' + .replaceAll('{functionId}', functionId); - final Map apiParams = { - if (queries != null) 'queries': queries, + final Map apiParams = { + if (queries != null) 'queries': queries, + if (total != null) 'total': total, + }; - if (total != null) 'total': total, + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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 = { - if (body != null) 'body': body, - - if (xasync != null) 'async': xasync, - - if (path != null) 'path': path, - - if (method != null) 'method': method.value, - - if (headers != null) 'headers': headers, - - 'scheduledAt': scheduledAt, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + if (body != null) 'body': body, + if (xasync != null) 'async': xasync, + if (path != null) 'path': path, + if (method != null) 'method': method.value, + if (headers != null) 'headers': headers, + 'scheduledAt': scheduledAt, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 = { - }; + Future getExecution( + {required String functionId, required String executionId}) async { + final String apiPath = '/functions/{functionId}/executions/{executionId}' + .replaceAll('{functionId}', functionId) + .replaceAll('{executionId}', executionId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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); } } diff --git a/lib/services/graphql.dart b/lib/services/graphql.dart index 978331fa..c86f3719 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,39 +10,41 @@ class Graphql extends Service { Future query({required Map query}) async { final String apiPath = '/graphql'; - final Map apiParams = { - 'query': query, + final Map apiParams = { + 'query': query, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'x-sdk-graphql': 'true', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'x-sdk-graphql': 'true', 'content-type': 'application/json', 'accept': '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 { final String apiPath = '/graphql/mutation'; - final Map apiParams = { - 'query': query, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'x-sdk-graphql': 'true', 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + 'query': query, + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'x-sdk-graphql': 'true', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - return res.data; + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); + return res.data; } } diff --git a/lib/services/locale.dart b/lib/services/locale.dart index c45a1269..87ea162e 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 { final String apiPath = '/locale'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -34,18 +33,17 @@ class Locale extends Service { Future listCodes() async { final String apiPath = '/locale/codes'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -53,18 +51,17 @@ class Locale extends Service { Future listContinents() async { final String apiPath = '/locale/continents'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -72,18 +69,17 @@ class Locale extends Service { Future listCountries() async { final String apiPath = '/locale/countries'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -91,18 +87,17 @@ class Locale extends Service { Future listCountriesEU() async { final String apiPath = '/locale/countries/eu'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -110,18 +105,17 @@ class Locale extends Service { Future listCountriesPhones() async { final String apiPath = '/locale/countries/phones'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -130,18 +124,17 @@ class Locale extends Service { Future listCurrencies() async { final String apiPath = '/locale/currencies'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -149,17 +142,16 @@ class Locale extends Service { Future listLanguages() async { final String apiPath = '/locale/languages'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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); } } diff --git a/lib/services/messaging.dart b/lib/services/messaging.dart index 3dffe41b..61ecefee 100644 --- a/lib/services/messaging.dart +++ b/lib/services/messaging.dart @@ -1,48 +1,54 @@ 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - return res.data; + final res = await client.call(HttpMethod.delete, + path: apiPath, params: apiParams, headers: apiHeaders); + return res.data; } } diff --git a/lib/services/presences.dart b/lib/services/presences.dart index 088700cb..1c9b651b 100644 --- a/lib/services/presences.dart +++ b/lib/services/presences.dart @@ -5,123 +5,127 @@ class Presences extends Service { Presences(super.client); /// List presence logs. Expired entries are filtered out automatically. - /// - Future list({List? queries, bool? total, int? ttl}) async { + /// + Future list( + {List? queries, bool? total, int? ttl}) async { final String apiPath = '/presences'; - final Map apiParams = { - if (queries != null) 'queries': queries, + final Map apiParams = { + if (queries != null) 'queries': queries, + if (total != null) 'total': total, + if (ttl != null) 'ttl': ttl, + }; - if (total != null) 'total': total, + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - if (ttl != null) 'ttl': ttl, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.PresenceList.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.PresenceList.fromMap(res.data); } /// Get a presence log by its unique ID. Entries whose `expiresAt` is in the /// past are treated as not found. - /// + /// Future get({required String presenceId}) async { - final String apiPath = '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); + final String apiPath = + '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Presence.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.Presence.fromMap(res.data); } /// Create or update a presence log by its user ID. - /// - Future upsert({required String presenceId, required String status, List? permissions, String? expiresAt, Map? metadata}) async { - final String apiPath = '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); - - final Map apiParams = { - 'status': status, - - if (permissions != null) 'permissions': permissions, - - if (expiresAt != null) 'expiresAt': expiresAt, - - if (metadata != null) 'metadata': metadata, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Presence.fromMap(res.data); - + /// + Future upsert( + {required String presenceId, + required String status, + List? permissions, + String? expiresAt, + Map? metadata}) async { + final String apiPath = + '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); + + final Map apiParams = { + 'status': status, + if (permissions != null) 'permissions': permissions, + if (expiresAt != null) 'expiresAt': expiresAt, + if (metadata != null) 'metadata': metadata, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Presence.fromMap(res.data); } /// Update a presence log by its unique ID. Using the patch method you can pass /// only specific fields that will get updated. - /// - Future update({required String presenceId, String? status, String? expiresAt, Map? metadata, List? permissions, bool? purge}) async { - final String apiPath = '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); - - final Map apiParams = { - if (status != null) 'status': status, - - if (expiresAt != null) 'expiresAt': expiresAt, - - if (metadata != null) 'metadata': metadata, - - if (permissions != null) 'permissions': permissions, - - if (purge != null) 'purge': purge, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Presence.fromMap(res.data); - + /// + Future update( + {required String presenceId, + String? status, + String? expiresAt, + Map? metadata, + List? permissions, + bool? purge}) async { + final String apiPath = + '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); + + final Map apiParams = { + if (status != null) 'status': status, + if (expiresAt != null) 'expiresAt': expiresAt, + if (metadata != null) 'metadata': metadata, + if (permissions != null) 'permissions': permissions, + if (purge != null) 'purge': purge, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Presence.fromMap(res.data); } /// Delete a presence log by its unique ID. - /// + /// Future delete({required String presenceId}) async { - final String apiPath = '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); - - final Map apiParams = { - }; + final String apiPath = + '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - return res.data; + final res = await client.call(HttpMethod.delete, + path: apiPath, params: apiParams, headers: apiHeaders); + return res.data; } } diff --git a/lib/services/storage.dart b/lib/services/storage.dart index c9499a99..cdb626de 100644 --- a/lib/services/storage.dart +++ b/lib/services/storage.dart @@ -1,166 +1,178 @@ 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, bool? total}) async { - final String apiPath = '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - - if (search != null) 'search': search, - - if (total != null) 'total': total, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, + bool? total}) async { + final String apiPath = + '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + if (search != null) 'search': search, + if (total != null) 'total': total, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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, - - if (permissions != null) 'permissions': permissions, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'multipart/form-data', 'accept': 'application/json', - }; - - 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, + if (permissions != null) 'permissions': permissions, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'multipart/form-data', + 'accept': 'application/json', + }; + + 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); + 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 apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.File.fromMap(res.data); + 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 = { - if (name != null) 'name': name, - - 'permissions': permissions, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + if (name != null) 'name': name, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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 = { - - if (token != null) 'token': token, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + if (token != null) 'token': token, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 @@ -168,60 +180,64 @@ 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 = { - - if (width != null) 'width': width, - - if (height != null) 'height': height, - - if (gravity != null) 'gravity': gravity.value, - - if (quality != null) 'quality': quality, - - if (borderWidth != null) 'borderWidth': borderWidth, - - if (borderColor != null) 'borderColor': borderColor, - - if (borderRadius != null) 'borderRadius': borderRadius, - - if (opacity != null) 'opacity': opacity, - - if (rotation != null) 'rotation': rotation, - - if (background != null) 'background': background, - - if (output != null) 'output': output.value, - - if (token != null) 'token': token, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + if (width != null) 'width': width, + if (height != null) 'height': height, + if (gravity != null) 'gravity': gravity.value, + if (quality != null) 'quality': quality, + if (borderWidth != null) 'borderWidth': borderWidth, + if (borderColor != null) 'borderColor': borderColor, + if (borderRadius != null) 'borderRadius': borderRadius, + if (opacity != null) 'opacity': opacity, + if (rotation != null) 'rotation': rotation, + if (background != null) 'background': background, + if (output != null) 'output': output.value, + if (token != null) 'token': token, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 = { - - if (token != null) 'token': token, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + if (token != null) 'token': token, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + final res = await client.call(HttpMethod.get, + path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } } diff --git a/lib/services/tables_db.dart b/lib/services/tables_db.dart index 42572021..8b6284b3 100644 --- a/lib/services/tables_db.dart +++ b/lib/services/tables_db.dart @@ -5,319 +5,382 @@ class TablesDB extends Service { TablesDB(super.client); /// List transactions across all databases. - Future listTransactions({List? queries}) async { + Future listTransactions( + {List? queries}) async { final String apiPath = '/tablesdb/transactions'; - final Map apiParams = { - if (queries != null) 'queries': queries, + final Map apiParams = { + if (queries != null) 'queries': queries, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.TransactionList.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.TransactionList.fromMap(res.data); } /// Create a new transaction. Future createTransaction({int? ttl}) async { final String apiPath = '/tablesdb/transactions'; - final Map apiParams = { - if (ttl != null) 'ttl': ttl, - - }; + final Map apiParams = { + if (ttl != null) 'ttl': ttl, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Transaction.fromMap(res.data); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.Transaction.fromMap(res.data); } /// Get a transaction by its unique ID. - Future getTransaction({required String transactionId}) async { - final String apiPath = '/tablesdb/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - }; + Future getTransaction( + {required String transactionId}) async { + final String apiPath = '/tablesdb/transactions/{transactionId}' + .replaceAll('{transactionId}', transactionId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - return models.Transaction.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.Transaction.fromMap(res.data); } /// Update a transaction, to either commit or roll back its operations. - Future updateTransaction({required String transactionId, bool? commit, bool? rollback}) async { - final String apiPath = '/tablesdb/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - if (commit != null) 'commit': commit, - - if (rollback != null) 'rollback': rollback, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Transaction.fromMap(res.data); - + Future updateTransaction( + {required String transactionId, bool? commit, bool? rollback}) async { + final String apiPath = '/tablesdb/transactions/{transactionId}' + .replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + if (commit != null) 'commit': commit, + if (rollback != null) 'rollback': rollback, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Transaction.fromMap(res.data); } /// Delete a transaction by its unique ID. Future deleteTransaction({required String transactionId}) async { - final String apiPath = '/tablesdb/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - }; + final String apiPath = '/tablesdb/transactions/{transactionId}' + .replaceAll('{transactionId}', transactionId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - return res.data; + final res = await client.call(HttpMethod.delete, + path: apiPath, params: apiParams, headers: apiHeaders); + return res.data; } /// Create multiple operations in a single transaction. - Future createOperations({required String transactionId, List? operations}) async { - final String apiPath = '/tablesdb/transactions/{transactionId}/operations'.replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - if (operations != null) 'operations': operations, - - }; + Future createOperations( + {required String transactionId, List? operations}) async { + final String apiPath = '/tablesdb/transactions/{transactionId}/operations' + .replaceAll('{transactionId}', transactionId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + if (operations != null) 'operations': operations, + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - return models.Transaction.fromMap(res.data); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.Transaction.fromMap(res.data); } /// 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, String? transactionId, bool? total, int? ttl}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - - if (transactionId != null) 'transactionId': transactionId, - - if (total != null) 'total': total, - - if (ttl != null) 'ttl': ttl, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, + String? transactionId, + bool? total, + int? ttl}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + if (transactionId != null) 'transactionId': transactionId, + if (total != null) 'total': total, + if (ttl != null) 'ttl': ttl, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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/references/cloud/server-dart/tablesDB#createTable) /// API or directly from your database console. - Future createRow({required String databaseId, required String tableId, required String rowId, required Map data, List? permissions, String? transactionId}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); - - final Map apiParams = { - 'rowId': rowId, - - 'data': data, - - 'permissions': permissions, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + String? transactionId}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId); + + final Map apiParams = { + 'rowId': rowId, + 'data': data, + 'permissions': permissions, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, String? transactionId}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - - if (transactionId != null) 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, + String? transactionId}) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + if (transactionId != null) 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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/references/cloud/server-dart/tablesDB#createTable) /// API or directly from your database console. - Future upsertRow({required String databaseId, required String tableId, required String rowId, Map? data, List? permissions, String? transactionId}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - if (data != null) 'data': data, - - 'permissions': permissions, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + String? transactionId}) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId); + + final Map apiParams = { + if (data != null) 'data': data, + 'permissions': permissions, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, String? transactionId}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - if (data != null) 'data': data, - - 'permissions': permissions, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + String? transactionId}) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId); + + final Map apiParams = { + if (data != null) 'data': data, + 'permissions': permissions, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, String? transactionId}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - if (transactionId != null) 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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, + String? transactionId}) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId); + + final Map apiParams = { + if (transactionId != null) 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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, String? transactionId}) 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 = { - if (value != null) 'value': value, - - 'min': min, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + String? transactionId}) 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 = { + if (value != null) 'value': value, + 'min': min, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, String? transactionId}) 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 = { - if (value != null) 'value': value, - - 'max': max, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + String? transactionId}) 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 = { + if (value != null) 'value': value, + 'max': max, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); } } diff --git a/lib/services/teams.dart b/lib/services/teams.dart index 27bc561e..1f4022f6 100644 --- a/lib/services/teams.dart +++ b/lib/services/teams.dart @@ -1,98 +1,97 @@ 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); /// Get a list of all the teams in which the current user is a member. You can /// use the parameters to filter your results. - Future list({List? queries, String? search, bool? total}) async { + Future list( + {List? queries, String? search, bool? total}) async { final String apiPath = '/teams'; - final Map apiParams = { - if (queries != null) 'queries': queries, + final Map apiParams = { + if (queries != null) 'queries': queries, + if (search != null) 'search': search, + if (total != null) 'total': total, + }; - if (search != null) 'search': search, + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - if (total != null) 'total': total, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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 { final String apiPath = '/teams'; - final Map apiParams = { - 'teamId': teamId, - - 'name': name, - - if (roles != null) 'roles': roles, - - }; + final Map apiParams = { + 'teamId': teamId, + 'name': name, + if (roles != null) 'roles': roles, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 apiParams = { + 'name': name, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - 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 @@ -100,44 +99,45 @@ class Teams extends Service { Future delete({required String teamId}) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - 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, bool? total}) async { - final String apiPath = '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - - if (search != null) 'search': search, - - if (total != null) 'total': total, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, + bool? total}) async { + final String apiPath = + '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + if (search != null) 'search': search, + if (total != null) 'total': total, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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 @@ -146,180 +146,199 @@ 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 = { - if (email != null) 'email': email, - - if (userId != null) 'userId': userId, - - if (phone != null) 'phone': phone, - - 'roles': roles, - - if (url != null) 'url': url, - - if (name != null) 'name': name, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + if (email != null) 'email': email, + if (userId != null) 'userId': userId, + if (phone != null) 'phone': phone, + 'roles': roles, + if (url != null) 'url': url, + if (name != null) 'name': name, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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); + 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 apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 = { - }; + Future deleteMembership( + {required String teamId, required String membershipId}) async { + final String apiPath = '/teams/{teamId}/memberships/{membershipId}' + .replaceAll('{teamId}', teamId) + .replaceAll('{membershipId}', membershipId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + 'prefs': prefs, + }; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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); } } diff --git a/lib/src/client.dart b/lib/src/client.dart index 65b2f044..cc077e56 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -27,7 +27,8 @@ abstract class Client { factory Client({ String endPoint = 'https://cloud.appwrite.io/v1', bool selfSigned = false, - }) => createClient(endPoint: endPoint, selfSigned: selfSigned); + }) => + createClient(endPoint: endPoint, selfSigned: selfSigned); /// Handle OAuth2 session creation. Future webAuth(Uri url, {String? callbackUrlScheme}); @@ -107,7 +108,6 @@ abstract class Client { /// Send a ping to project as part of onboarding. Future ping(); - /// Send the API request. Future call( HttpMethod method, { diff --git a/lib/src/client_base.dart b/lib/src/client_base.dart index 9e964a79..da1a5225 100644 --- a/lib/src/client_base.dart +++ b/lib/src/client_base.dart @@ -6,26 +6,33 @@ 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); + /// The user cookie to authenticate with. Used by SDKs that forward an incoming Cookie header in server-side runtimes. @override ClientBase setCookie(value); + /// Impersonate a user by ID @override ClientBase setImpersonateUserId(value); + /// Impersonate a user by email @override ClientBase setImpersonateUserEmail(value); + /// Impersonate a user by phone @override ClientBase setImpersonateUserPhone(value); diff --git a/lib/src/client_browser.dart b/lib/src/client_browser.dart index 2f4c7b48..32945efd 100644 --- a/lib/src/client_browser.dart +++ b/lib/src/client_browser.dart @@ -62,6 +62,7 @@ class ClientBrowser extends ClientBase with ClientMixin { config['project'] = value; return this; } + /// Your secret JSON Web Token @override ClientBrowser setJWT(value) { @@ -69,12 +70,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) { @@ -82,6 +85,7 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Session', value); return this; } + /// Your secret dev API key @override ClientBrowser setDevKey(value) { @@ -89,6 +93,7 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Dev-Key', value); return this; } + /// The user cookie to authenticate with. Used by SDKs that forward an incoming Cookie header in server-side runtimes. @override ClientBrowser setCookie(value) { @@ -96,6 +101,7 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('Cookie', value); return this; } + /// Impersonate a user by ID @override ClientBrowser setImpersonateUserId(value) { @@ -103,6 +109,7 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Impersonate-User-Id', value); return this; } + /// Impersonate a user by email @override ClientBrowser setImpersonateUserEmail(value) { @@ -110,6 +117,7 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Impersonate-User-Email', value); return this; } + /// Impersonate a user by phone @override ClientBrowser setImpersonateUserPhone(value) { @@ -219,7 +227,8 @@ class ClientBrowser extends ClientBase with ClientMixin { final totalChunks = (size / chunkSize).ceil(); - Future uploadChunk(int index, int start, int end, String? id) async { + Future uploadChunk( + int index, int start, int end, String? id) async { List chunk = []; chunk = file.bytes!.getRange(start, end).toList(); @@ -257,7 +266,9 @@ class ClientBrowser extends ClientBase with ClientMixin { bool isUploadComplete(Response response) { final chunksUploaded = response.data['chunksUploaded']; final chunksTotal = response.data['chunksTotal'] ?? totalChunks; - return chunksUploaded is num && chunksTotal is num && chunksUploaded >= chunksTotal; + return chunksUploaded is num && + chunksTotal is num && + chunksUploaded >= chunksTotal; } final progress = UploadProgress( diff --git a/lib/src/client_io.dart b/lib/src/client_io.dart index 6e6e2ee8..78a368ae 100644 --- a/lib/src/client_io.dart +++ b/lib/src/client_io.dart @@ -88,6 +88,7 @@ class ClientIO extends ClientBase with ClientMixin { config['project'] = value; return this; } + /// Your secret JSON Web Token @override ClientIO setJWT(value) { @@ -95,12 +96,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) { @@ -108,6 +111,7 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Session', value); return this; } + /// Your secret dev API key @override ClientIO setDevKey(value) { @@ -115,6 +119,7 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Dev-Key', value); return this; } + /// The user cookie to authenticate with. Used by SDKs that forward an incoming Cookie header in server-side runtimes. @override ClientIO setCookie(value) { @@ -122,6 +127,7 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('Cookie', value); return this; } + /// Impersonate a user by ID @override ClientIO setImpersonateUserId(value) { @@ -129,6 +135,7 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Impersonate-User-Id', value); return this; } + /// Impersonate a user by email @override ClientIO setImpersonateUserEmail(value) { @@ -136,6 +143,7 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Impersonate-User-Email', value); return this; } + /// Impersonate a user by phone @override ClientIO setImpersonateUserPhone(value) { @@ -394,7 +402,9 @@ class ClientIO extends ClientBase with ClientMixin { bool isUploadComplete(Response response) { final chunksUploaded = response.data['chunksUploaded']; final chunksTotal = response.data['chunksTotal'] ?? totalChunks; - return chunksUploaded is num && chunksTotal is num && chunksUploaded >= chunksTotal; + return chunksUploaded is num && + chunksTotal is num && + chunksUploaded >= chunksTotal; } final progress = UploadProgress( @@ -418,7 +428,8 @@ class ClientIO extends ClientBase with ClientMixin { var nextChunk = 0; Future uploadNext() async { - final raf = file.bytes == null ? await iofile!.open(mode: FileMode.read) : null; + final raf = + file.bytes == null ? await iofile!.open(mode: FileMode.read) : null; try { while (nextChunk < chunks.length) { final chunk = chunks[nextChunk++]; diff --git a/lib/src/client_mixin.dart b/lib/src/client_mixin.dart index 40484946..89aad359 100644 --- a/lib/src/client_mixin.dart +++ b/lib/src/client_mixin.dart @@ -12,7 +12,6 @@ mixin ClientMixin { required Map headers, required Map params, }) { - http.BaseRequest request = http.Request(method.name(), uri); if (headers['content-type'] == 'multipart/form-data') { request = http.MultipartRequest(method.name(), uri); @@ -128,9 +127,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/browser_permission.dart b/lib/src/enums/browser_permission.dart index 765b3e0c..fb4983db 100644 --- a/lib/src/enums/browser_permission.dart +++ b/lib/src/enums/browser_permission.dart @@ -1,32 +1,30 @@ part of '../../enums.dart'; enum BrowserPermission { - geolocation(value: 'geolocation'), - camera(value: 'camera'), - microphone(value: 'microphone'), - notifications(value: 'notifications'), - midi(value: 'midi'), - push(value: 'push'), - clipboardRead(value: 'clipboard-read'), - clipboardWrite(value: 'clipboard-write'), - paymentHandler(value: 'payment-handler'), - usb(value: 'usb'), - bluetooth(value: 'bluetooth'), - accelerometer(value: 'accelerometer'), - gyroscope(value: 'gyroscope'), - magnetometer(value: 'magnetometer'), - ambientLightSensor(value: 'ambient-light-sensor'), - backgroundSync(value: 'background-sync'), - persistentStorage(value: 'persistent-storage'), - screenWakeLock(value: 'screen-wake-lock'), - webShare(value: 'web-share'), - xrSpatialTracking(value: 'xr-spatial-tracking'); + geolocation(value: 'geolocation'), + camera(value: 'camera'), + microphone(value: 'microphone'), + notifications(value: 'notifications'), + midi(value: 'midi'), + push(value: 'push'), + clipboardRead(value: 'clipboard-read'), + clipboardWrite(value: 'clipboard-write'), + paymentHandler(value: 'payment-handler'), + usb(value: 'usb'), + bluetooth(value: 'bluetooth'), + accelerometer(value: 'accelerometer'), + gyroscope(value: 'gyroscope'), + magnetometer(value: 'magnetometer'), + ambientLightSensor(value: 'ambient-light-sensor'), + backgroundSync(value: 'background-sync'), + persistentStorage(value: 'persistent-storage'), + screenWakeLock(value: 'screen-wake-lock'), + webShare(value: 'web-share'), + xrSpatialTracking(value: 'xr-spatial-tracking'); - const BrowserPermission({ - required this.value - }); + const BrowserPermission({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_theme.dart b/lib/src/enums/browser_theme.dart index e81a0f68..1e059c2c 100644 --- a/lib/src/enums/browser_theme.dart +++ b/lib/src/enums/browser_theme.dart @@ -1,14 +1,12 @@ part of '../../enums.dart'; enum BrowserTheme { - light(value: 'light'), - dark(value: 'dark'); + light(value: 'light'), + dark(value: 'dark'); - const BrowserTheme({ - required this.value - }); + const BrowserTheme({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/execution_status.dart b/lib/src/enums/execution_status.dart index f54859c9..7ea9865e 100644 --- a/lib/src/enums/execution_status.dart +++ b/lib/src/enums/execution_status.dart @@ -1,17 +1,15 @@ part of '../../enums.dart'; enum ExecutionStatus { - waiting(value: 'waiting'), - processing(value: 'processing'), - completed(value: 'completed'), - failed(value: 'failed'), - scheduled(value: 'scheduled'); + waiting(value: 'waiting'), + processing(value: 'processing'), + completed(value: 'completed'), + failed(value: 'failed'), + scheduled(value: 'scheduled'); - const ExecutionStatus({ - required this.value - }); + const ExecutionStatus({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_trigger.dart b/lib/src/enums/execution_trigger.dart index 8a14ae60..fb05eb7d 100644 --- a/lib/src/enums/execution_trigger.dart +++ b/lib/src/enums/execution_trigger.dart @@ -1,15 +1,13 @@ part of '../../enums.dart'; enum ExecutionTrigger { - http(value: 'http'), - schedule(value: 'schedule'), - event(value: 'event'); + http(value: 'http'), + schedule(value: 'schedule'), + event(value: 'event'); - const ExecutionTrigger({ - required this.value - }); + const ExecutionTrigger({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 8ed7ecff..b88e0a55 100644 --- a/lib/src/enums/o_auth_provider.dart +++ b/lib/src/enums/o_auth_provider.dart @@ -1,55 +1,53 @@ 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'), - fusionauth(value: 'fusionauth'), - github(value: 'github'), - gitlab(value: 'gitlab'), - google(value: 'google'), - keycloak(value: 'keycloak'), - kick(value: 'kick'), - 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'), - x(value: 'x'), - yahoo(value: 'yahoo'), - yammer(value: 'yammer'), - yandex(value: 'yandex'), - zoho(value: 'zoho'), - zoom(value: 'zoom'); + 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'), + fusionauth(value: 'fusionauth'), + github(value: 'github'), + gitlab(value: 'gitlab'), + google(value: 'google'), + keycloak(value: 'keycloak'), + kick(value: 'kick'), + 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'), + x(value: 'x'), + yahoo(value: 'yahoo'), + yammer(value: 'yammer'), + yandex(value: 'yandex'), + zoho(value: 'zoho'), + zoom(value: 'zoom'); - 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/enums/timezone.dart b/lib/src/enums/timezone.dart index 4a8de1ce..d5d8d94a 100644 --- a/lib/src/enums/timezone.dart +++ b/lib/src/enums/timezone.dart @@ -1,431 +1,429 @@ part of '../../enums.dart'; enum Timezone { - africaAbidjan(value: 'africa/abidjan'), - africaAccra(value: 'africa/accra'), - africaAddisAbaba(value: 'africa/addis_ababa'), - africaAlgiers(value: 'africa/algiers'), - africaAsmara(value: 'africa/asmara'), - africaBamako(value: 'africa/bamako'), - africaBangui(value: 'africa/bangui'), - africaBanjul(value: 'africa/banjul'), - africaBissau(value: 'africa/bissau'), - africaBlantyre(value: 'africa/blantyre'), - africaBrazzaville(value: 'africa/brazzaville'), - africaBujumbura(value: 'africa/bujumbura'), - africaCairo(value: 'africa/cairo'), - africaCasablanca(value: 'africa/casablanca'), - africaCeuta(value: 'africa/ceuta'), - africaConakry(value: 'africa/conakry'), - africaDakar(value: 'africa/dakar'), - africaDarEsSalaam(value: 'africa/dar_es_salaam'), - africaDjibouti(value: 'africa/djibouti'), - africaDouala(value: 'africa/douala'), - africaElAaiun(value: 'africa/el_aaiun'), - africaFreetown(value: 'africa/freetown'), - africaGaborone(value: 'africa/gaborone'), - africaHarare(value: 'africa/harare'), - africaJohannesburg(value: 'africa/johannesburg'), - africaJuba(value: 'africa/juba'), - africaKampala(value: 'africa/kampala'), - africaKhartoum(value: 'africa/khartoum'), - africaKigali(value: 'africa/kigali'), - africaKinshasa(value: 'africa/kinshasa'), - africaLagos(value: 'africa/lagos'), - africaLibreville(value: 'africa/libreville'), - africaLome(value: 'africa/lome'), - africaLuanda(value: 'africa/luanda'), - africaLubumbashi(value: 'africa/lubumbashi'), - africaLusaka(value: 'africa/lusaka'), - africaMalabo(value: 'africa/malabo'), - africaMaputo(value: 'africa/maputo'), - africaMaseru(value: 'africa/maseru'), - africaMbabane(value: 'africa/mbabane'), - africaMogadishu(value: 'africa/mogadishu'), - africaMonrovia(value: 'africa/monrovia'), - africaNairobi(value: 'africa/nairobi'), - africaNdjamena(value: 'africa/ndjamena'), - africaNiamey(value: 'africa/niamey'), - africaNouakchott(value: 'africa/nouakchott'), - africaOuagadougou(value: 'africa/ouagadougou'), - africaPortoNovo(value: 'africa/porto-novo'), - africaSaoTome(value: 'africa/sao_tome'), - africaTripoli(value: 'africa/tripoli'), - africaTunis(value: 'africa/tunis'), - africaWindhoek(value: 'africa/windhoek'), - americaAdak(value: 'america/adak'), - americaAnchorage(value: 'america/anchorage'), - americaAnguilla(value: 'america/anguilla'), - americaAntigua(value: 'america/antigua'), - americaAraguaina(value: 'america/araguaina'), - americaArgentinaBuenosAires(value: 'america/argentina/buenos_aires'), - americaArgentinaCatamarca(value: 'america/argentina/catamarca'), - americaArgentinaCordoba(value: 'america/argentina/cordoba'), - americaArgentinaJujuy(value: 'america/argentina/jujuy'), - americaArgentinaLaRioja(value: 'america/argentina/la_rioja'), - americaArgentinaMendoza(value: 'america/argentina/mendoza'), - americaArgentinaRioGallegos(value: 'america/argentina/rio_gallegos'), - americaArgentinaSalta(value: 'america/argentina/salta'), - americaArgentinaSanJuan(value: 'america/argentina/san_juan'), - americaArgentinaSanLuis(value: 'america/argentina/san_luis'), - americaArgentinaTucuman(value: 'america/argentina/tucuman'), - americaArgentinaUshuaia(value: 'america/argentina/ushuaia'), - americaAruba(value: 'america/aruba'), - americaAsuncion(value: 'america/asuncion'), - americaAtikokan(value: 'america/atikokan'), - americaBahia(value: 'america/bahia'), - americaBahiaBanderas(value: 'america/bahia_banderas'), - americaBarbados(value: 'america/barbados'), - americaBelem(value: 'america/belem'), - americaBelize(value: 'america/belize'), - americaBlancSablon(value: 'america/blanc-sablon'), - americaBoaVista(value: 'america/boa_vista'), - americaBogota(value: 'america/bogota'), - americaBoise(value: 'america/boise'), - americaCambridgeBay(value: 'america/cambridge_bay'), - americaCampoGrande(value: 'america/campo_grande'), - americaCancun(value: 'america/cancun'), - americaCaracas(value: 'america/caracas'), - americaCayenne(value: 'america/cayenne'), - americaCayman(value: 'america/cayman'), - americaChicago(value: 'america/chicago'), - americaChihuahua(value: 'america/chihuahua'), - americaCiudadJuarez(value: 'america/ciudad_juarez'), - americaCostaRica(value: 'america/costa_rica'), - americaCoyhaique(value: 'america/coyhaique'), - americaCreston(value: 'america/creston'), - americaCuiaba(value: 'america/cuiaba'), - americaCuracao(value: 'america/curacao'), - americaDanmarkshavn(value: 'america/danmarkshavn'), - americaDawson(value: 'america/dawson'), - americaDawsonCreek(value: 'america/dawson_creek'), - americaDenver(value: 'america/denver'), - americaDetroit(value: 'america/detroit'), - americaDominica(value: 'america/dominica'), - americaEdmonton(value: 'america/edmonton'), - americaEirunepe(value: 'america/eirunepe'), - americaElSalvador(value: 'america/el_salvador'), - americaFortNelson(value: 'america/fort_nelson'), - americaFortaleza(value: 'america/fortaleza'), - americaGlaceBay(value: 'america/glace_bay'), - americaGooseBay(value: 'america/goose_bay'), - americaGrandTurk(value: 'america/grand_turk'), - americaGrenada(value: 'america/grenada'), - americaGuadeloupe(value: 'america/guadeloupe'), - americaGuatemala(value: 'america/guatemala'), - americaGuayaquil(value: 'america/guayaquil'), - americaGuyana(value: 'america/guyana'), - americaHalifax(value: 'america/halifax'), - americaHavana(value: 'america/havana'), - americaHermosillo(value: 'america/hermosillo'), - americaIndianaIndianapolis(value: 'america/indiana/indianapolis'), - americaIndianaKnox(value: 'america/indiana/knox'), - americaIndianaMarengo(value: 'america/indiana/marengo'), - americaIndianaPetersburg(value: 'america/indiana/petersburg'), - americaIndianaTellCity(value: 'america/indiana/tell_city'), - americaIndianaVevay(value: 'america/indiana/vevay'), - americaIndianaVincennes(value: 'america/indiana/vincennes'), - americaIndianaWinamac(value: 'america/indiana/winamac'), - americaInuvik(value: 'america/inuvik'), - americaIqaluit(value: 'america/iqaluit'), - americaJamaica(value: 'america/jamaica'), - americaJuneau(value: 'america/juneau'), - americaKentuckyLouisville(value: 'america/kentucky/louisville'), - americaKentuckyMonticello(value: 'america/kentucky/monticello'), - americaKralendijk(value: 'america/kralendijk'), - americaLaPaz(value: 'america/la_paz'), - americaLima(value: 'america/lima'), - americaLosAngeles(value: 'america/los_angeles'), - americaLowerPrinces(value: 'america/lower_princes'), - americaMaceio(value: 'america/maceio'), - americaManagua(value: 'america/managua'), - americaManaus(value: 'america/manaus'), - americaMarigot(value: 'america/marigot'), - americaMartinique(value: 'america/martinique'), - americaMatamoros(value: 'america/matamoros'), - americaMazatlan(value: 'america/mazatlan'), - americaMenominee(value: 'america/menominee'), - americaMerida(value: 'america/merida'), - americaMetlakatla(value: 'america/metlakatla'), - americaMexicoCity(value: 'america/mexico_city'), - americaMiquelon(value: 'america/miquelon'), - americaMoncton(value: 'america/moncton'), - americaMonterrey(value: 'america/monterrey'), - americaMontevideo(value: 'america/montevideo'), - americaMontserrat(value: 'america/montserrat'), - americaNassau(value: 'america/nassau'), - americaNewYork(value: 'america/new_york'), - americaNome(value: 'america/nome'), - americaNoronha(value: 'america/noronha'), - americaNorthDakotaBeulah(value: 'america/north_dakota/beulah'), - americaNorthDakotaCenter(value: 'america/north_dakota/center'), - americaNorthDakotaNewSalem(value: 'america/north_dakota/new_salem'), - americaNuuk(value: 'america/nuuk'), - americaOjinaga(value: 'america/ojinaga'), - americaPanama(value: 'america/panama'), - americaParamaribo(value: 'america/paramaribo'), - americaPhoenix(value: 'america/phoenix'), - americaPortAuPrince(value: 'america/port-au-prince'), - americaPortOfSpain(value: 'america/port_of_spain'), - americaPortoVelho(value: 'america/porto_velho'), - americaPuertoRico(value: 'america/puerto_rico'), - americaPuntaArenas(value: 'america/punta_arenas'), - americaRankinInlet(value: 'america/rankin_inlet'), - americaRecife(value: 'america/recife'), - americaRegina(value: 'america/regina'), - americaResolute(value: 'america/resolute'), - americaRioBranco(value: 'america/rio_branco'), - americaSantarem(value: 'america/santarem'), - americaSantiago(value: 'america/santiago'), - americaSantoDomingo(value: 'america/santo_domingo'), - americaSaoPaulo(value: 'america/sao_paulo'), - americaScoresbysund(value: 'america/scoresbysund'), - americaSitka(value: 'america/sitka'), - americaStBarthelemy(value: 'america/st_barthelemy'), - americaStJohns(value: 'america/st_johns'), - americaStKitts(value: 'america/st_kitts'), - americaStLucia(value: 'america/st_lucia'), - americaStThomas(value: 'america/st_thomas'), - americaStVincent(value: 'america/st_vincent'), - americaSwiftCurrent(value: 'america/swift_current'), - americaTegucigalpa(value: 'america/tegucigalpa'), - americaThule(value: 'america/thule'), - americaTijuana(value: 'america/tijuana'), - americaToronto(value: 'america/toronto'), - americaTortola(value: 'america/tortola'), - americaVancouver(value: 'america/vancouver'), - americaWhitehorse(value: 'america/whitehorse'), - americaWinnipeg(value: 'america/winnipeg'), - americaYakutat(value: 'america/yakutat'), - antarcticaCasey(value: 'antarctica/casey'), - antarcticaDavis(value: 'antarctica/davis'), - antarcticaDumontdurville(value: 'antarctica/dumontdurville'), - antarcticaMacquarie(value: 'antarctica/macquarie'), - antarcticaMawson(value: 'antarctica/mawson'), - antarcticaMcmurdo(value: 'antarctica/mcmurdo'), - antarcticaPalmer(value: 'antarctica/palmer'), - antarcticaRothera(value: 'antarctica/rothera'), - antarcticaSyowa(value: 'antarctica/syowa'), - antarcticaTroll(value: 'antarctica/troll'), - antarcticaVostok(value: 'antarctica/vostok'), - arcticLongyearbyen(value: 'arctic/longyearbyen'), - asiaAden(value: 'asia/aden'), - asiaAlmaty(value: 'asia/almaty'), - asiaAmman(value: 'asia/amman'), - asiaAnadyr(value: 'asia/anadyr'), - asiaAqtau(value: 'asia/aqtau'), - asiaAqtobe(value: 'asia/aqtobe'), - asiaAshgabat(value: 'asia/ashgabat'), - asiaAtyrau(value: 'asia/atyrau'), - asiaBaghdad(value: 'asia/baghdad'), - asiaBahrain(value: 'asia/bahrain'), - asiaBaku(value: 'asia/baku'), - asiaBangkok(value: 'asia/bangkok'), - asiaBarnaul(value: 'asia/barnaul'), - asiaBeirut(value: 'asia/beirut'), - asiaBishkek(value: 'asia/bishkek'), - asiaBrunei(value: 'asia/brunei'), - asiaChita(value: 'asia/chita'), - asiaColombo(value: 'asia/colombo'), - asiaDamascus(value: 'asia/damascus'), - asiaDhaka(value: 'asia/dhaka'), - asiaDili(value: 'asia/dili'), - asiaDubai(value: 'asia/dubai'), - asiaDushanbe(value: 'asia/dushanbe'), - asiaFamagusta(value: 'asia/famagusta'), - asiaGaza(value: 'asia/gaza'), - asiaHebron(value: 'asia/hebron'), - asiaHoChiMinh(value: 'asia/ho_chi_minh'), - asiaHongKong(value: 'asia/hong_kong'), - asiaHovd(value: 'asia/hovd'), - asiaIrkutsk(value: 'asia/irkutsk'), - asiaJakarta(value: 'asia/jakarta'), - asiaJayapura(value: 'asia/jayapura'), - asiaJerusalem(value: 'asia/jerusalem'), - asiaKabul(value: 'asia/kabul'), - asiaKamchatka(value: 'asia/kamchatka'), - asiaKarachi(value: 'asia/karachi'), - asiaKathmandu(value: 'asia/kathmandu'), - asiaKhandyga(value: 'asia/khandyga'), - asiaKolkata(value: 'asia/kolkata'), - asiaKrasnoyarsk(value: 'asia/krasnoyarsk'), - asiaKualaLumpur(value: 'asia/kuala_lumpur'), - asiaKuching(value: 'asia/kuching'), - asiaKuwait(value: 'asia/kuwait'), - asiaMacau(value: 'asia/macau'), - asiaMagadan(value: 'asia/magadan'), - asiaMakassar(value: 'asia/makassar'), - asiaManila(value: 'asia/manila'), - asiaMuscat(value: 'asia/muscat'), - asiaNicosia(value: 'asia/nicosia'), - asiaNovokuznetsk(value: 'asia/novokuznetsk'), - asiaNovosibirsk(value: 'asia/novosibirsk'), - asiaOmsk(value: 'asia/omsk'), - asiaOral(value: 'asia/oral'), - asiaPhnomPenh(value: 'asia/phnom_penh'), - asiaPontianak(value: 'asia/pontianak'), - asiaPyongyang(value: 'asia/pyongyang'), - asiaQatar(value: 'asia/qatar'), - asiaQostanay(value: 'asia/qostanay'), - asiaQyzylorda(value: 'asia/qyzylorda'), - asiaRiyadh(value: 'asia/riyadh'), - asiaSakhalin(value: 'asia/sakhalin'), - asiaSamarkand(value: 'asia/samarkand'), - asiaSeoul(value: 'asia/seoul'), - asiaShanghai(value: 'asia/shanghai'), - asiaSingapore(value: 'asia/singapore'), - asiaSrednekolymsk(value: 'asia/srednekolymsk'), - asiaTaipei(value: 'asia/taipei'), - asiaTashkent(value: 'asia/tashkent'), - asiaTbilisi(value: 'asia/tbilisi'), - asiaTehran(value: 'asia/tehran'), - asiaThimphu(value: 'asia/thimphu'), - asiaTokyo(value: 'asia/tokyo'), - asiaTomsk(value: 'asia/tomsk'), - asiaUlaanbaatar(value: 'asia/ulaanbaatar'), - asiaUrumqi(value: 'asia/urumqi'), - asiaUstNera(value: 'asia/ust-nera'), - asiaVientiane(value: 'asia/vientiane'), - asiaVladivostok(value: 'asia/vladivostok'), - asiaYakutsk(value: 'asia/yakutsk'), - asiaYangon(value: 'asia/yangon'), - asiaYekaterinburg(value: 'asia/yekaterinburg'), - asiaYerevan(value: 'asia/yerevan'), - atlanticAzores(value: 'atlantic/azores'), - atlanticBermuda(value: 'atlantic/bermuda'), - atlanticCanary(value: 'atlantic/canary'), - atlanticCapeVerde(value: 'atlantic/cape_verde'), - atlanticFaroe(value: 'atlantic/faroe'), - atlanticMadeira(value: 'atlantic/madeira'), - atlanticReykjavik(value: 'atlantic/reykjavik'), - atlanticSouthGeorgia(value: 'atlantic/south_georgia'), - atlanticStHelena(value: 'atlantic/st_helena'), - atlanticStanley(value: 'atlantic/stanley'), - australiaAdelaide(value: 'australia/adelaide'), - australiaBrisbane(value: 'australia/brisbane'), - australiaBrokenHill(value: 'australia/broken_hill'), - australiaDarwin(value: 'australia/darwin'), - australiaEucla(value: 'australia/eucla'), - australiaHobart(value: 'australia/hobart'), - australiaLindeman(value: 'australia/lindeman'), - australiaLordHowe(value: 'australia/lord_howe'), - australiaMelbourne(value: 'australia/melbourne'), - australiaPerth(value: 'australia/perth'), - australiaSydney(value: 'australia/sydney'), - europeAmsterdam(value: 'europe/amsterdam'), - europeAndorra(value: 'europe/andorra'), - europeAstrakhan(value: 'europe/astrakhan'), - europeAthens(value: 'europe/athens'), - europeBelgrade(value: 'europe/belgrade'), - europeBerlin(value: 'europe/berlin'), - europeBratislava(value: 'europe/bratislava'), - europeBrussels(value: 'europe/brussels'), - europeBucharest(value: 'europe/bucharest'), - europeBudapest(value: 'europe/budapest'), - europeBusingen(value: 'europe/busingen'), - europeChisinau(value: 'europe/chisinau'), - europeCopenhagen(value: 'europe/copenhagen'), - europeDublin(value: 'europe/dublin'), - europeGibraltar(value: 'europe/gibraltar'), - europeGuernsey(value: 'europe/guernsey'), - europeHelsinki(value: 'europe/helsinki'), - europeIsleOfMan(value: 'europe/isle_of_man'), - europeIstanbul(value: 'europe/istanbul'), - europeJersey(value: 'europe/jersey'), - europeKaliningrad(value: 'europe/kaliningrad'), - europeKirov(value: 'europe/kirov'), - europeKyiv(value: 'europe/kyiv'), - europeLisbon(value: 'europe/lisbon'), - europeLjubljana(value: 'europe/ljubljana'), - europeLondon(value: 'europe/london'), - europeLuxembourg(value: 'europe/luxembourg'), - europeMadrid(value: 'europe/madrid'), - europeMalta(value: 'europe/malta'), - europeMariehamn(value: 'europe/mariehamn'), - europeMinsk(value: 'europe/minsk'), - europeMonaco(value: 'europe/monaco'), - europeMoscow(value: 'europe/moscow'), - europeOslo(value: 'europe/oslo'), - europeParis(value: 'europe/paris'), - europePodgorica(value: 'europe/podgorica'), - europePrague(value: 'europe/prague'), - europeRiga(value: 'europe/riga'), - europeRome(value: 'europe/rome'), - europeSamara(value: 'europe/samara'), - europeSanMarino(value: 'europe/san_marino'), - europeSarajevo(value: 'europe/sarajevo'), - europeSaratov(value: 'europe/saratov'), - europeSimferopol(value: 'europe/simferopol'), - europeSkopje(value: 'europe/skopje'), - europeSofia(value: 'europe/sofia'), - europeStockholm(value: 'europe/stockholm'), - europeTallinn(value: 'europe/tallinn'), - europeTirane(value: 'europe/tirane'), - europeUlyanovsk(value: 'europe/ulyanovsk'), - europeVaduz(value: 'europe/vaduz'), - europeVatican(value: 'europe/vatican'), - europeVienna(value: 'europe/vienna'), - europeVilnius(value: 'europe/vilnius'), - europeVolgograd(value: 'europe/volgograd'), - europeWarsaw(value: 'europe/warsaw'), - europeZagreb(value: 'europe/zagreb'), - europeZurich(value: 'europe/zurich'), - indianAntananarivo(value: 'indian/antananarivo'), - indianChagos(value: 'indian/chagos'), - indianChristmas(value: 'indian/christmas'), - indianCocos(value: 'indian/cocos'), - indianComoro(value: 'indian/comoro'), - indianKerguelen(value: 'indian/kerguelen'), - indianMahe(value: 'indian/mahe'), - indianMaldives(value: 'indian/maldives'), - indianMauritius(value: 'indian/mauritius'), - indianMayotte(value: 'indian/mayotte'), - indianReunion(value: 'indian/reunion'), - pacificApia(value: 'pacific/apia'), - pacificAuckland(value: 'pacific/auckland'), - pacificBougainville(value: 'pacific/bougainville'), - pacificChatham(value: 'pacific/chatham'), - pacificChuuk(value: 'pacific/chuuk'), - pacificEaster(value: 'pacific/easter'), - pacificEfate(value: 'pacific/efate'), - pacificFakaofo(value: 'pacific/fakaofo'), - pacificFiji(value: 'pacific/fiji'), - pacificFunafuti(value: 'pacific/funafuti'), - pacificGalapagos(value: 'pacific/galapagos'), - pacificGambier(value: 'pacific/gambier'), - pacificGuadalcanal(value: 'pacific/guadalcanal'), - pacificGuam(value: 'pacific/guam'), - pacificHonolulu(value: 'pacific/honolulu'), - pacificKanton(value: 'pacific/kanton'), - pacificKiritimati(value: 'pacific/kiritimati'), - pacificKosrae(value: 'pacific/kosrae'), - pacificKwajalein(value: 'pacific/kwajalein'), - pacificMajuro(value: 'pacific/majuro'), - pacificMarquesas(value: 'pacific/marquesas'), - pacificMidway(value: 'pacific/midway'), - pacificNauru(value: 'pacific/nauru'), - pacificNiue(value: 'pacific/niue'), - pacificNorfolk(value: 'pacific/norfolk'), - pacificNoumea(value: 'pacific/noumea'), - pacificPagoPago(value: 'pacific/pago_pago'), - pacificPalau(value: 'pacific/palau'), - pacificPitcairn(value: 'pacific/pitcairn'), - pacificPohnpei(value: 'pacific/pohnpei'), - pacificPortMoresby(value: 'pacific/port_moresby'), - pacificRarotonga(value: 'pacific/rarotonga'), - pacificSaipan(value: 'pacific/saipan'), - pacificTahiti(value: 'pacific/tahiti'), - pacificTarawa(value: 'pacific/tarawa'), - pacificTongatapu(value: 'pacific/tongatapu'), - pacificWake(value: 'pacific/wake'), - pacificWallis(value: 'pacific/wallis'), - utc(value: 'utc'); + africaAbidjan(value: 'africa/abidjan'), + africaAccra(value: 'africa/accra'), + africaAddisAbaba(value: 'africa/addis_ababa'), + africaAlgiers(value: 'africa/algiers'), + africaAsmara(value: 'africa/asmara'), + africaBamako(value: 'africa/bamako'), + africaBangui(value: 'africa/bangui'), + africaBanjul(value: 'africa/banjul'), + africaBissau(value: 'africa/bissau'), + africaBlantyre(value: 'africa/blantyre'), + africaBrazzaville(value: 'africa/brazzaville'), + africaBujumbura(value: 'africa/bujumbura'), + africaCairo(value: 'africa/cairo'), + africaCasablanca(value: 'africa/casablanca'), + africaCeuta(value: 'africa/ceuta'), + africaConakry(value: 'africa/conakry'), + africaDakar(value: 'africa/dakar'), + africaDarEsSalaam(value: 'africa/dar_es_salaam'), + africaDjibouti(value: 'africa/djibouti'), + africaDouala(value: 'africa/douala'), + africaElAaiun(value: 'africa/el_aaiun'), + africaFreetown(value: 'africa/freetown'), + africaGaborone(value: 'africa/gaborone'), + africaHarare(value: 'africa/harare'), + africaJohannesburg(value: 'africa/johannesburg'), + africaJuba(value: 'africa/juba'), + africaKampala(value: 'africa/kampala'), + africaKhartoum(value: 'africa/khartoum'), + africaKigali(value: 'africa/kigali'), + africaKinshasa(value: 'africa/kinshasa'), + africaLagos(value: 'africa/lagos'), + africaLibreville(value: 'africa/libreville'), + africaLome(value: 'africa/lome'), + africaLuanda(value: 'africa/luanda'), + africaLubumbashi(value: 'africa/lubumbashi'), + africaLusaka(value: 'africa/lusaka'), + africaMalabo(value: 'africa/malabo'), + africaMaputo(value: 'africa/maputo'), + africaMaseru(value: 'africa/maseru'), + africaMbabane(value: 'africa/mbabane'), + africaMogadishu(value: 'africa/mogadishu'), + africaMonrovia(value: 'africa/monrovia'), + africaNairobi(value: 'africa/nairobi'), + africaNdjamena(value: 'africa/ndjamena'), + africaNiamey(value: 'africa/niamey'), + africaNouakchott(value: 'africa/nouakchott'), + africaOuagadougou(value: 'africa/ouagadougou'), + africaPortoNovo(value: 'africa/porto-novo'), + africaSaoTome(value: 'africa/sao_tome'), + africaTripoli(value: 'africa/tripoli'), + africaTunis(value: 'africa/tunis'), + africaWindhoek(value: 'africa/windhoek'), + americaAdak(value: 'america/adak'), + americaAnchorage(value: 'america/anchorage'), + americaAnguilla(value: 'america/anguilla'), + americaAntigua(value: 'america/antigua'), + americaAraguaina(value: 'america/araguaina'), + americaArgentinaBuenosAires(value: 'america/argentina/buenos_aires'), + americaArgentinaCatamarca(value: 'america/argentina/catamarca'), + americaArgentinaCordoba(value: 'america/argentina/cordoba'), + americaArgentinaJujuy(value: 'america/argentina/jujuy'), + americaArgentinaLaRioja(value: 'america/argentina/la_rioja'), + americaArgentinaMendoza(value: 'america/argentina/mendoza'), + americaArgentinaRioGallegos(value: 'america/argentina/rio_gallegos'), + americaArgentinaSalta(value: 'america/argentina/salta'), + americaArgentinaSanJuan(value: 'america/argentina/san_juan'), + americaArgentinaSanLuis(value: 'america/argentina/san_luis'), + americaArgentinaTucuman(value: 'america/argentina/tucuman'), + americaArgentinaUshuaia(value: 'america/argentina/ushuaia'), + americaAruba(value: 'america/aruba'), + americaAsuncion(value: 'america/asuncion'), + americaAtikokan(value: 'america/atikokan'), + americaBahia(value: 'america/bahia'), + americaBahiaBanderas(value: 'america/bahia_banderas'), + americaBarbados(value: 'america/barbados'), + americaBelem(value: 'america/belem'), + americaBelize(value: 'america/belize'), + americaBlancSablon(value: 'america/blanc-sablon'), + americaBoaVista(value: 'america/boa_vista'), + americaBogota(value: 'america/bogota'), + americaBoise(value: 'america/boise'), + americaCambridgeBay(value: 'america/cambridge_bay'), + americaCampoGrande(value: 'america/campo_grande'), + americaCancun(value: 'america/cancun'), + americaCaracas(value: 'america/caracas'), + americaCayenne(value: 'america/cayenne'), + americaCayman(value: 'america/cayman'), + americaChicago(value: 'america/chicago'), + americaChihuahua(value: 'america/chihuahua'), + americaCiudadJuarez(value: 'america/ciudad_juarez'), + americaCostaRica(value: 'america/costa_rica'), + americaCoyhaique(value: 'america/coyhaique'), + americaCreston(value: 'america/creston'), + americaCuiaba(value: 'america/cuiaba'), + americaCuracao(value: 'america/curacao'), + americaDanmarkshavn(value: 'america/danmarkshavn'), + americaDawson(value: 'america/dawson'), + americaDawsonCreek(value: 'america/dawson_creek'), + americaDenver(value: 'america/denver'), + americaDetroit(value: 'america/detroit'), + americaDominica(value: 'america/dominica'), + americaEdmonton(value: 'america/edmonton'), + americaEirunepe(value: 'america/eirunepe'), + americaElSalvador(value: 'america/el_salvador'), + americaFortNelson(value: 'america/fort_nelson'), + americaFortaleza(value: 'america/fortaleza'), + americaGlaceBay(value: 'america/glace_bay'), + americaGooseBay(value: 'america/goose_bay'), + americaGrandTurk(value: 'america/grand_turk'), + americaGrenada(value: 'america/grenada'), + americaGuadeloupe(value: 'america/guadeloupe'), + americaGuatemala(value: 'america/guatemala'), + americaGuayaquil(value: 'america/guayaquil'), + americaGuyana(value: 'america/guyana'), + americaHalifax(value: 'america/halifax'), + americaHavana(value: 'america/havana'), + americaHermosillo(value: 'america/hermosillo'), + americaIndianaIndianapolis(value: 'america/indiana/indianapolis'), + americaIndianaKnox(value: 'america/indiana/knox'), + americaIndianaMarengo(value: 'america/indiana/marengo'), + americaIndianaPetersburg(value: 'america/indiana/petersburg'), + americaIndianaTellCity(value: 'america/indiana/tell_city'), + americaIndianaVevay(value: 'america/indiana/vevay'), + americaIndianaVincennes(value: 'america/indiana/vincennes'), + americaIndianaWinamac(value: 'america/indiana/winamac'), + americaInuvik(value: 'america/inuvik'), + americaIqaluit(value: 'america/iqaluit'), + americaJamaica(value: 'america/jamaica'), + americaJuneau(value: 'america/juneau'), + americaKentuckyLouisville(value: 'america/kentucky/louisville'), + americaKentuckyMonticello(value: 'america/kentucky/monticello'), + americaKralendijk(value: 'america/kralendijk'), + americaLaPaz(value: 'america/la_paz'), + americaLima(value: 'america/lima'), + americaLosAngeles(value: 'america/los_angeles'), + americaLowerPrinces(value: 'america/lower_princes'), + americaMaceio(value: 'america/maceio'), + americaManagua(value: 'america/managua'), + americaManaus(value: 'america/manaus'), + americaMarigot(value: 'america/marigot'), + americaMartinique(value: 'america/martinique'), + americaMatamoros(value: 'america/matamoros'), + americaMazatlan(value: 'america/mazatlan'), + americaMenominee(value: 'america/menominee'), + americaMerida(value: 'america/merida'), + americaMetlakatla(value: 'america/metlakatla'), + americaMexicoCity(value: 'america/mexico_city'), + americaMiquelon(value: 'america/miquelon'), + americaMoncton(value: 'america/moncton'), + americaMonterrey(value: 'america/monterrey'), + americaMontevideo(value: 'america/montevideo'), + americaMontserrat(value: 'america/montserrat'), + americaNassau(value: 'america/nassau'), + americaNewYork(value: 'america/new_york'), + americaNome(value: 'america/nome'), + americaNoronha(value: 'america/noronha'), + americaNorthDakotaBeulah(value: 'america/north_dakota/beulah'), + americaNorthDakotaCenter(value: 'america/north_dakota/center'), + americaNorthDakotaNewSalem(value: 'america/north_dakota/new_salem'), + americaNuuk(value: 'america/nuuk'), + americaOjinaga(value: 'america/ojinaga'), + americaPanama(value: 'america/panama'), + americaParamaribo(value: 'america/paramaribo'), + americaPhoenix(value: 'america/phoenix'), + americaPortAuPrince(value: 'america/port-au-prince'), + americaPortOfSpain(value: 'america/port_of_spain'), + americaPortoVelho(value: 'america/porto_velho'), + americaPuertoRico(value: 'america/puerto_rico'), + americaPuntaArenas(value: 'america/punta_arenas'), + americaRankinInlet(value: 'america/rankin_inlet'), + americaRecife(value: 'america/recife'), + americaRegina(value: 'america/regina'), + americaResolute(value: 'america/resolute'), + americaRioBranco(value: 'america/rio_branco'), + americaSantarem(value: 'america/santarem'), + americaSantiago(value: 'america/santiago'), + americaSantoDomingo(value: 'america/santo_domingo'), + americaSaoPaulo(value: 'america/sao_paulo'), + americaScoresbysund(value: 'america/scoresbysund'), + americaSitka(value: 'america/sitka'), + americaStBarthelemy(value: 'america/st_barthelemy'), + americaStJohns(value: 'america/st_johns'), + americaStKitts(value: 'america/st_kitts'), + americaStLucia(value: 'america/st_lucia'), + americaStThomas(value: 'america/st_thomas'), + americaStVincent(value: 'america/st_vincent'), + americaSwiftCurrent(value: 'america/swift_current'), + americaTegucigalpa(value: 'america/tegucigalpa'), + americaThule(value: 'america/thule'), + americaTijuana(value: 'america/tijuana'), + americaToronto(value: 'america/toronto'), + americaTortola(value: 'america/tortola'), + americaVancouver(value: 'america/vancouver'), + americaWhitehorse(value: 'america/whitehorse'), + americaWinnipeg(value: 'america/winnipeg'), + americaYakutat(value: 'america/yakutat'), + antarcticaCasey(value: 'antarctica/casey'), + antarcticaDavis(value: 'antarctica/davis'), + antarcticaDumontdurville(value: 'antarctica/dumontdurville'), + antarcticaMacquarie(value: 'antarctica/macquarie'), + antarcticaMawson(value: 'antarctica/mawson'), + antarcticaMcmurdo(value: 'antarctica/mcmurdo'), + antarcticaPalmer(value: 'antarctica/palmer'), + antarcticaRothera(value: 'antarctica/rothera'), + antarcticaSyowa(value: 'antarctica/syowa'), + antarcticaTroll(value: 'antarctica/troll'), + antarcticaVostok(value: 'antarctica/vostok'), + arcticLongyearbyen(value: 'arctic/longyearbyen'), + asiaAden(value: 'asia/aden'), + asiaAlmaty(value: 'asia/almaty'), + asiaAmman(value: 'asia/amman'), + asiaAnadyr(value: 'asia/anadyr'), + asiaAqtau(value: 'asia/aqtau'), + asiaAqtobe(value: 'asia/aqtobe'), + asiaAshgabat(value: 'asia/ashgabat'), + asiaAtyrau(value: 'asia/atyrau'), + asiaBaghdad(value: 'asia/baghdad'), + asiaBahrain(value: 'asia/bahrain'), + asiaBaku(value: 'asia/baku'), + asiaBangkok(value: 'asia/bangkok'), + asiaBarnaul(value: 'asia/barnaul'), + asiaBeirut(value: 'asia/beirut'), + asiaBishkek(value: 'asia/bishkek'), + asiaBrunei(value: 'asia/brunei'), + asiaChita(value: 'asia/chita'), + asiaColombo(value: 'asia/colombo'), + asiaDamascus(value: 'asia/damascus'), + asiaDhaka(value: 'asia/dhaka'), + asiaDili(value: 'asia/dili'), + asiaDubai(value: 'asia/dubai'), + asiaDushanbe(value: 'asia/dushanbe'), + asiaFamagusta(value: 'asia/famagusta'), + asiaGaza(value: 'asia/gaza'), + asiaHebron(value: 'asia/hebron'), + asiaHoChiMinh(value: 'asia/ho_chi_minh'), + asiaHongKong(value: 'asia/hong_kong'), + asiaHovd(value: 'asia/hovd'), + asiaIrkutsk(value: 'asia/irkutsk'), + asiaJakarta(value: 'asia/jakarta'), + asiaJayapura(value: 'asia/jayapura'), + asiaJerusalem(value: 'asia/jerusalem'), + asiaKabul(value: 'asia/kabul'), + asiaKamchatka(value: 'asia/kamchatka'), + asiaKarachi(value: 'asia/karachi'), + asiaKathmandu(value: 'asia/kathmandu'), + asiaKhandyga(value: 'asia/khandyga'), + asiaKolkata(value: 'asia/kolkata'), + asiaKrasnoyarsk(value: 'asia/krasnoyarsk'), + asiaKualaLumpur(value: 'asia/kuala_lumpur'), + asiaKuching(value: 'asia/kuching'), + asiaKuwait(value: 'asia/kuwait'), + asiaMacau(value: 'asia/macau'), + asiaMagadan(value: 'asia/magadan'), + asiaMakassar(value: 'asia/makassar'), + asiaManila(value: 'asia/manila'), + asiaMuscat(value: 'asia/muscat'), + asiaNicosia(value: 'asia/nicosia'), + asiaNovokuznetsk(value: 'asia/novokuznetsk'), + asiaNovosibirsk(value: 'asia/novosibirsk'), + asiaOmsk(value: 'asia/omsk'), + asiaOral(value: 'asia/oral'), + asiaPhnomPenh(value: 'asia/phnom_penh'), + asiaPontianak(value: 'asia/pontianak'), + asiaPyongyang(value: 'asia/pyongyang'), + asiaQatar(value: 'asia/qatar'), + asiaQostanay(value: 'asia/qostanay'), + asiaQyzylorda(value: 'asia/qyzylorda'), + asiaRiyadh(value: 'asia/riyadh'), + asiaSakhalin(value: 'asia/sakhalin'), + asiaSamarkand(value: 'asia/samarkand'), + asiaSeoul(value: 'asia/seoul'), + asiaShanghai(value: 'asia/shanghai'), + asiaSingapore(value: 'asia/singapore'), + asiaSrednekolymsk(value: 'asia/srednekolymsk'), + asiaTaipei(value: 'asia/taipei'), + asiaTashkent(value: 'asia/tashkent'), + asiaTbilisi(value: 'asia/tbilisi'), + asiaTehran(value: 'asia/tehran'), + asiaThimphu(value: 'asia/thimphu'), + asiaTokyo(value: 'asia/tokyo'), + asiaTomsk(value: 'asia/tomsk'), + asiaUlaanbaatar(value: 'asia/ulaanbaatar'), + asiaUrumqi(value: 'asia/urumqi'), + asiaUstNera(value: 'asia/ust-nera'), + asiaVientiane(value: 'asia/vientiane'), + asiaVladivostok(value: 'asia/vladivostok'), + asiaYakutsk(value: 'asia/yakutsk'), + asiaYangon(value: 'asia/yangon'), + asiaYekaterinburg(value: 'asia/yekaterinburg'), + asiaYerevan(value: 'asia/yerevan'), + atlanticAzores(value: 'atlantic/azores'), + atlanticBermuda(value: 'atlantic/bermuda'), + atlanticCanary(value: 'atlantic/canary'), + atlanticCapeVerde(value: 'atlantic/cape_verde'), + atlanticFaroe(value: 'atlantic/faroe'), + atlanticMadeira(value: 'atlantic/madeira'), + atlanticReykjavik(value: 'atlantic/reykjavik'), + atlanticSouthGeorgia(value: 'atlantic/south_georgia'), + atlanticStHelena(value: 'atlantic/st_helena'), + atlanticStanley(value: 'atlantic/stanley'), + australiaAdelaide(value: 'australia/adelaide'), + australiaBrisbane(value: 'australia/brisbane'), + australiaBrokenHill(value: 'australia/broken_hill'), + australiaDarwin(value: 'australia/darwin'), + australiaEucla(value: 'australia/eucla'), + australiaHobart(value: 'australia/hobart'), + australiaLindeman(value: 'australia/lindeman'), + australiaLordHowe(value: 'australia/lord_howe'), + australiaMelbourne(value: 'australia/melbourne'), + australiaPerth(value: 'australia/perth'), + australiaSydney(value: 'australia/sydney'), + europeAmsterdam(value: 'europe/amsterdam'), + europeAndorra(value: 'europe/andorra'), + europeAstrakhan(value: 'europe/astrakhan'), + europeAthens(value: 'europe/athens'), + europeBelgrade(value: 'europe/belgrade'), + europeBerlin(value: 'europe/berlin'), + europeBratislava(value: 'europe/bratislava'), + europeBrussels(value: 'europe/brussels'), + europeBucharest(value: 'europe/bucharest'), + europeBudapest(value: 'europe/budapest'), + europeBusingen(value: 'europe/busingen'), + europeChisinau(value: 'europe/chisinau'), + europeCopenhagen(value: 'europe/copenhagen'), + europeDublin(value: 'europe/dublin'), + europeGibraltar(value: 'europe/gibraltar'), + europeGuernsey(value: 'europe/guernsey'), + europeHelsinki(value: 'europe/helsinki'), + europeIsleOfMan(value: 'europe/isle_of_man'), + europeIstanbul(value: 'europe/istanbul'), + europeJersey(value: 'europe/jersey'), + europeKaliningrad(value: 'europe/kaliningrad'), + europeKirov(value: 'europe/kirov'), + europeKyiv(value: 'europe/kyiv'), + europeLisbon(value: 'europe/lisbon'), + europeLjubljana(value: 'europe/ljubljana'), + europeLondon(value: 'europe/london'), + europeLuxembourg(value: 'europe/luxembourg'), + europeMadrid(value: 'europe/madrid'), + europeMalta(value: 'europe/malta'), + europeMariehamn(value: 'europe/mariehamn'), + europeMinsk(value: 'europe/minsk'), + europeMonaco(value: 'europe/monaco'), + europeMoscow(value: 'europe/moscow'), + europeOslo(value: 'europe/oslo'), + europeParis(value: 'europe/paris'), + europePodgorica(value: 'europe/podgorica'), + europePrague(value: 'europe/prague'), + europeRiga(value: 'europe/riga'), + europeRome(value: 'europe/rome'), + europeSamara(value: 'europe/samara'), + europeSanMarino(value: 'europe/san_marino'), + europeSarajevo(value: 'europe/sarajevo'), + europeSaratov(value: 'europe/saratov'), + europeSimferopol(value: 'europe/simferopol'), + europeSkopje(value: 'europe/skopje'), + europeSofia(value: 'europe/sofia'), + europeStockholm(value: 'europe/stockholm'), + europeTallinn(value: 'europe/tallinn'), + europeTirane(value: 'europe/tirane'), + europeUlyanovsk(value: 'europe/ulyanovsk'), + europeVaduz(value: 'europe/vaduz'), + europeVatican(value: 'europe/vatican'), + europeVienna(value: 'europe/vienna'), + europeVilnius(value: 'europe/vilnius'), + europeVolgograd(value: 'europe/volgograd'), + europeWarsaw(value: 'europe/warsaw'), + europeZagreb(value: 'europe/zagreb'), + europeZurich(value: 'europe/zurich'), + indianAntananarivo(value: 'indian/antananarivo'), + indianChagos(value: 'indian/chagos'), + indianChristmas(value: 'indian/christmas'), + indianCocos(value: 'indian/cocos'), + indianComoro(value: 'indian/comoro'), + indianKerguelen(value: 'indian/kerguelen'), + indianMahe(value: 'indian/mahe'), + indianMaldives(value: 'indian/maldives'), + indianMauritius(value: 'indian/mauritius'), + indianMayotte(value: 'indian/mayotte'), + indianReunion(value: 'indian/reunion'), + pacificApia(value: 'pacific/apia'), + pacificAuckland(value: 'pacific/auckland'), + pacificBougainville(value: 'pacific/bougainville'), + pacificChatham(value: 'pacific/chatham'), + pacificChuuk(value: 'pacific/chuuk'), + pacificEaster(value: 'pacific/easter'), + pacificEfate(value: 'pacific/efate'), + pacificFakaofo(value: 'pacific/fakaofo'), + pacificFiji(value: 'pacific/fiji'), + pacificFunafuti(value: 'pacific/funafuti'), + pacificGalapagos(value: 'pacific/galapagos'), + pacificGambier(value: 'pacific/gambier'), + pacificGuadalcanal(value: 'pacific/guadalcanal'), + pacificGuam(value: 'pacific/guam'), + pacificHonolulu(value: 'pacific/honolulu'), + pacificKanton(value: 'pacific/kanton'), + pacificKiritimati(value: 'pacific/kiritimati'), + pacificKosrae(value: 'pacific/kosrae'), + pacificKwajalein(value: 'pacific/kwajalein'), + pacificMajuro(value: 'pacific/majuro'), + pacificMarquesas(value: 'pacific/marquesas'), + pacificMidway(value: 'pacific/midway'), + pacificNauru(value: 'pacific/nauru'), + pacificNiue(value: 'pacific/niue'), + pacificNorfolk(value: 'pacific/norfolk'), + pacificNoumea(value: 'pacific/noumea'), + pacificPagoPago(value: 'pacific/pago_pago'), + pacificPalau(value: 'pacific/palau'), + pacificPitcairn(value: 'pacific/pitcairn'), + pacificPohnpei(value: 'pacific/pohnpei'), + pacificPortMoresby(value: 'pacific/port_moresby'), + pacificRarotonga(value: 'pacific/rarotonga'), + pacificSaipan(value: 'pacific/saipan'), + pacificTahiti(value: 'pacific/tahiti'), + pacificTarawa(value: 'pacific/tarawa'), + pacificTongatapu(value: 'pacific/tongatapu'), + pacificWake(value: 'pacific/wake'), + pacificWallis(value: 'pacific/wallis'), + utc(value: 'utc'); - const Timezone({ - required this.value - }); + const Timezone({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 f80fa854..344a8770 100644 --- a/lib/src/models/algo_argon2.dart +++ b/lib/src/models/algo_argon2.dart @@ -2,41 +2,41 @@ 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'], + ); + } - @override - Map toMap() { - return { - "type": type, - "memoryCost": memoryCost, - "timeCost": timeCost, - "threads": threads, - }; - } + @override + 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 c51da4bb..9909265e 100644 --- a/lib/src/models/algo_bcrypt.dart +++ b/lib/src/models/algo_bcrypt.dart @@ -2,23 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return { - "type": type, - }; - } + @override + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_md5.dart b/lib/src/models/algo_md5.dart index 43523ab1..746fbd52 100644 --- a/lib/src/models/algo_md5.dart +++ b/lib/src/models/algo_md5.dart @@ -2,23 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return { - "type": type, - }; - } + @override + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_phpass.dart b/lib/src/models/algo_phpass.dart index 8562c4e3..cab45e49 100644 --- a/lib/src/models/algo_phpass.dart +++ b/lib/src/models/algo_phpass.dart @@ -2,23 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return { - "type": type, - }; - } + @override + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_scrypt.dart b/lib/src/models/algo_scrypt.dart index 8e844839..a1648843 100644 --- a/lib/src/models/algo_scrypt.dart +++ b/lib/src/models/algo_scrypt.dart @@ -2,47 +2,47 @@ 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'], - ); - } - - @override - 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'], + ); + } + + @override + 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 5202db05..33ef4a6f 100644 --- a/lib/src/models/algo_scrypt_modified.dart +++ b/lib/src/models/algo_scrypt_modified.dart @@ -2,41 +2,41 @@ 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(), + ); + } - @override - Map toMap() { - return { - "type": type, - "salt": salt, - "saltSeparator": saltSeparator, - "signerKey": signerKey, - }; - } + @override + 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 3d08af9f..4984df75 100644 --- a/lib/src/models/algo_sha.dart +++ b/lib/src/models/algo_sha.dart @@ -2,23 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return { - "type": type, - }; - } + @override + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/continent.dart b/lib/src/models/continent.dart index 930900bf..ec3c41be 100644 --- a/lib/src/models/continent.dart +++ b/lib/src/models/continent.dart @@ -2,29 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return { - "name": name, - "code": code, - }; - } + @override + Map toMap() { + return { + "name": name, + "code": code, + }; + } } diff --git a/lib/src/models/continent_list.dart b/lib/src/models/continent_list.dart index 753bcacc..df28f04b 100644 --- a/lib/src/models/continent_list.dart +++ b/lib/src/models/continent_list.dart @@ -2,29 +2,30 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "continents": continents.map((p) => p.toMap()).toList(), - }; - } + @override + 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 c4838ba3..3bcbb76d 100644 --- a/lib/src/models/country.dart +++ b/lib/src/models/country.dart @@ -2,29 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return { - "name": name, - "code": code, - }; - } + @override + Map toMap() { + return { + "name": name, + "code": code, + }; + } } diff --git a/lib/src/models/country_list.dart b/lib/src/models/country_list.dart index f363a54b..79cb1256 100644 --- a/lib/src/models/country_list.dart +++ b/lib/src/models/country_list.dart @@ -2,29 +2,30 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "countries": countries.map((p) => p.toMap()).toList(), - }; - } + @override + 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 b6bb455f..f2b18093 100644 --- a/lib/src/models/currency.dart +++ b/lib/src/models/currency.dart @@ -2,59 +2,59 @@ 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(), - ); - } - - @override - 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(), + ); + } + + @override + 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 eb2bad19..6c39ae2e 100644 --- a/lib/src/models/currency_list.dart +++ b/lib/src/models/currency_list.dart @@ -2,29 +2,30 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "currencies": currencies.map((p) => p.toMap()).toList(), - }; - } + @override + 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 0d1fdeb0..be08d599 100644 --- a/lib/src/models/document.dart +++ b/lib/src/models/document.dart @@ -2,66 +2,66 @@ part of '../../models.dart'; /// Document class Document implements Model { - /// Document ID. - final String $id; + /// Document ID. + final String $id; - /// Document sequence ID. - final String $sequence; + /// Document sequence ID. + final String $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'].toString(), - $collectionId: map['\$collectionId'].toString(), - $databaseId: map['\$databaseId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - data: map["data"] ?? map, - ); - } + factory Document.fromMap(Map map) { + return Document( + $id: map['\$id'].toString(), + $sequence: map['\$sequence'].toString(), + $collectionId: map['\$collectionId'].toString(), + $databaseId: map['\$databaseId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + data: map["data"] ?? map, + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$sequence": $sequence, - "\$collectionId": $collectionId, - "\$databaseId": $databaseId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "data": data, - }; - } + @override + 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 0e30844a..76a07309 100644 --- a/lib/src/models/document_list.dart +++ b/lib/src/models/document_list.dart @@ -2,32 +2,33 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "documents": documents.map((p) => p.toMap()).toList(), - }; - } + @override + 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 3e767ca3..3629e1d6 100644 --- a/lib/src/models/execution.dart +++ b/lib/src/models/execution.dart @@ -2,125 +2,129 @@ 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 enums.ExecutionTrigger trigger; - - /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, `failed`, or `scheduled`. - final enums.ExecutionStatus status; - - /// HTTP request method type. - final String requestMethod; - - /// HTTP request path and query. - final String requestPath; - - /// HTTP request 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: enums.ExecutionTrigger.values.firstWhere((e) => e.value == map['trigger']), - status: enums.ExecutionStatus.values.firstWhere((e) => e.value == map['status']), - 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(), - ); - } - - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "functionId": functionId, - "deploymentId": deploymentId, - "trigger": trigger.value, - "status": status.value, - "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 enums.ExecutionTrigger trigger; + + /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, `failed`, or `scheduled`. + final enums.ExecutionStatus status; + + /// HTTP request method type. + final String requestMethod; + + /// HTTP request path and query. + final String requestPath; + + /// HTTP request 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: enums.ExecutionTrigger.values + .firstWhere((e) => e.value == map['trigger']), + status: enums.ExecutionStatus.values + .firstWhere((e) => e.value == map['status']), + 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(), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "functionId": functionId, + "deploymentId": deploymentId, + "trigger": trigger.value, + "status": status.value, + "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 45b60682..63c2ad7e 100644 --- a/lib/src/models/execution_list.dart +++ b/lib/src/models/execution_list.dart @@ -2,29 +2,30 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "executions": executions.map((p) => p.toMap()).toList(), - }; - } + @override + 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 9e5f9eb1..01cdcb3a 100644 --- a/lib/src/models/file.dart +++ b/lib/src/models/file.dart @@ -2,101 +2,101 @@ part of '../../models.dart'; /// File class File implements Model { - /// File ID. - final String $id; - - /// Bucket ID. - final String bucketId; - - /// File creation date in ISO 8601 format. - final String $createdAt; - - /// 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 name. - final String name; - - /// File MD5 signature. - final String signature; - - /// File mime type. - final String mimeType; - - /// File original size in bytes. - final int sizeOriginal; - - /// File actual stored size in bytes after compression and/or encryption. - final int sizeActual; - - /// Total number of chunks available - final int chunksTotal; - - /// Total number of chunks uploaded - final int chunksUploaded; - - /// Whether file contents are encrypted at rest. - final bool encryption; - - /// Compression algorithm used for the file. Will be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd). - final String compression; - - 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.sizeActual, - required this.chunksTotal, - required this.chunksUploaded, - required this.encryption, - required this.compression, - }); - - 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'], - sizeActual: map['sizeActual'], - chunksTotal: map['chunksTotal'], - chunksUploaded: map['chunksUploaded'], - encryption: map['encryption'], - compression: map['compression'].toString(), - ); - } - - @override - Map toMap() { - return { - "\$id": $id, - "bucketId": bucketId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "name": name, - "signature": signature, - "mimeType": mimeType, - "sizeOriginal": sizeOriginal, - "sizeActual": sizeActual, - "chunksTotal": chunksTotal, - "chunksUploaded": chunksUploaded, - "encryption": encryption, - "compression": compression, - }; - } + /// File ID. + final String $id; + + /// Bucket ID. + final String bucketId; + + /// File creation date in ISO 8601 format. + final String $createdAt; + + /// 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 name. + final String name; + + /// File MD5 signature. + final String signature; + + /// File mime type. + final String mimeType; + + /// File original size in bytes. + final int sizeOriginal; + + /// File actual stored size in bytes after compression and/or encryption. + final int sizeActual; + + /// Total number of chunks available + final int chunksTotal; + + /// Total number of chunks uploaded + final int chunksUploaded; + + /// Whether file contents are encrypted at rest. + final bool encryption; + + /// Compression algorithm used for the file. Will be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd). + final String compression; + + 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.sizeActual, + required this.chunksTotal, + required this.chunksUploaded, + required this.encryption, + required this.compression, + }); + + 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'], + sizeActual: map['sizeActual'], + chunksTotal: map['chunksTotal'], + chunksUploaded: map['chunksUploaded'], + encryption: map['encryption'], + compression: map['compression'].toString(), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "bucketId": bucketId, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "name": name, + "signature": signature, + "mimeType": mimeType, + "sizeOriginal": sizeOriginal, + "sizeActual": sizeActual, + "chunksTotal": chunksTotal, + "chunksUploaded": chunksUploaded, + "encryption": encryption, + "compression": compression, + }; + } } diff --git a/lib/src/models/file_list.dart b/lib/src/models/file_list.dart index 84c54b2e..1157554a 100644 --- a/lib/src/models/file_list.dart +++ b/lib/src/models/file_list.dart @@ -2,29 +2,29 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "files": files.map((p) => p.toMap()).toList(), - }; - } + @override + 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 bbccf88a..fa054420 100644 --- a/lib/src/models/headers.dart +++ b/lib/src/models/headers.dart @@ -2,29 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return { - "name": name, - "value": value, - }; - } + @override + Map toMap() { + return { + "name": name, + "value": value, + }; + } } diff --git a/lib/src/models/identity.dart b/lib/src/models/identity.dart index 7e90020c..cc659043 100644 --- a/lib/src/models/identity.dart +++ b/lib/src/models/identity.dart @@ -2,77 +2,77 @@ 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(), + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "userId": userId, - "provider": provider, - "providerUid": providerUid, - "providerEmail": providerEmail, - "providerAccessToken": providerAccessToken, - "providerAccessTokenExpiry": providerAccessTokenExpiry, - "providerRefreshToken": providerRefreshToken, - }; - } + @override + 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 d9cc09a2..a5d39ea0 100644 --- a/lib/src/models/identity_list.dart +++ b/lib/src/models/identity_list.dart @@ -2,29 +2,30 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "identities": identities.map((p) => p.toMap()).toList(), - }; - } + @override + 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 2000acb6..cda66c70 100644 --- a/lib/src/models/jwt.dart +++ b/lib/src/models/jwt.dart @@ -2,23 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return { - "jwt": jwt, - }; - } + @override + Map toMap() { + return { + "jwt": jwt, + }; + } } diff --git a/lib/src/models/language.dart b/lib/src/models/language.dart index 1422d065..87dc3606 100644 --- a/lib/src/models/language.dart +++ b/lib/src/models/language.dart @@ -2,35 +2,35 @@ 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(), + ); + } - @override - Map toMap() { - return { - "name": name, - "code": code, - "nativeName": nativeName, - }; - } + @override + 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 5d78a367..6198d61e 100644 --- a/lib/src/models/language_list.dart +++ b/lib/src/models/language_list.dart @@ -2,29 +2,30 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "languages": languages.map((p) => p.toMap()).toList(), - }; - } + @override + 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 3292a896..54dd0c29 100644 --- a/lib/src/models/locale.dart +++ b/lib/src/models/locale.dart @@ -2,59 +2,59 @@ 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(), - ); - } - - @override - 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(), + ); + } + + @override + 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 49ef3b0b..21405aff 100644 --- a/lib/src/models/locale_code.dart +++ b/lib/src/models/locale_code.dart @@ -2,29 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return { - "code": code, - "name": name, - }; - } + @override + 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 a3a26b61..202355a4 100644 --- a/lib/src/models/locale_code_list.dart +++ b/lib/src/models/locale_code_list.dart @@ -2,29 +2,30 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "localeCodes": localeCodes.map((p) => p.toMap()).toList(), - }; - } + @override + 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 406fcbcf..572cce50 100644 --- a/lib/src/models/log.dart +++ b/lib/src/models/log.dart @@ -2,149 +2,149 @@ part of '../../models.dart'; /// Log class Log implements Model { - /// Event name. - final String event; - - /// User ID of the actor recorded for this log. During impersonation, this is the original impersonator, not the impersonated target user. - final String userId; - - /// User email of the actor recorded for this log. During impersonation, this is the original impersonator. - final String userEmail; - - /// User name of the actor recorded for this log. During impersonation, this is the original impersonator. - final String userName; - - /// API mode when event triggered. - final String mode; - - /// User type who triggered the audit log. Possible values: user, admin, guest, keyProject, keyAccount, keyOrganization. - final String userType; - - /// 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.userType, - 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(), - userType: map['userType'].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(), - ); - } - - @override - Map toMap() { - return { - "event": event, - "userId": userId, - "userEmail": userEmail, - "userName": userName, - "mode": mode, - "userType": userType, - "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 of the actor recorded for this log. During impersonation, this is the original impersonator, not the impersonated target user. + final String userId; + + /// User email of the actor recorded for this log. During impersonation, this is the original impersonator. + final String userEmail; + + /// User name of the actor recorded for this log. During impersonation, this is the original impersonator. + final String userName; + + /// API mode when event triggered. + final String mode; + + /// User type who triggered the audit log. Possible values: user, admin, guest, keyProject, keyAccount, keyOrganization. + final String userType; + + /// 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.userType, + 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(), + userType: map['userType'].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(), + ); + } + + @override + Map toMap() { + return { + "event": event, + "userId": userId, + "userEmail": userEmail, + "userName": userName, + "mode": mode, + "userType": userType, + "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 ebf593c2..3494b111 100644 --- a/lib/src/models/log_list.dart +++ b/lib/src/models/log_list.dart @@ -2,29 +2,29 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "logs": logs.map((p) => p.toMap()).toList(), - }; - } + @override + 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 4baffb71..4d8a2f9b 100644 --- a/lib/src/models/membership.dart +++ b/lib/src/models/membership.dart @@ -2,107 +2,107 @@ 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; - - /// User phone number. Hide this attribute by toggling membership privacy in the Console. - final String userPhone; - - /// 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; - - /// Most recent access date in ISO 8601 format. Show this attribute by toggling membership privacy in the Console. - final String userAccessedAt; - - /// 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.userPhone, - required this.teamId, - required this.teamName, - required this.invited, - required this.joined, - required this.confirm, - required this.mfa, - required this.userAccessedAt, - 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(), - userPhone: map['userPhone'].toString(), - teamId: map['teamId'].toString(), - teamName: map['teamName'].toString(), - invited: map['invited'].toString(), - joined: map['joined'].toString(), - confirm: map['confirm'], - mfa: map['mfa'], - userAccessedAt: map['userAccessedAt'].toString(), - roles: List.from(map['roles'] ?? []), - ); - } - - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "userId": userId, - "userName": userName, - "userEmail": userEmail, - "userPhone": userPhone, - "teamId": teamId, - "teamName": teamName, - "invited": invited, - "joined": joined, - "confirm": confirm, - "mfa": mfa, - "userAccessedAt": userAccessedAt, - "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; + + /// User phone number. Hide this attribute by toggling membership privacy in the Console. + final String userPhone; + + /// 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; + + /// Most recent access date in ISO 8601 format. Show this attribute by toggling membership privacy in the Console. + final String userAccessedAt; + + /// 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.userPhone, + required this.teamId, + required this.teamName, + required this.invited, + required this.joined, + required this.confirm, + required this.mfa, + required this.userAccessedAt, + 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(), + userPhone: map['userPhone'].toString(), + teamId: map['teamId'].toString(), + teamName: map['teamName'].toString(), + invited: map['invited'].toString(), + joined: map['joined'].toString(), + confirm: map['confirm'], + mfa: map['mfa'], + userAccessedAt: map['userAccessedAt'].toString(), + roles: List.from(map['roles'] ?? []), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "userId": userId, + "userName": userName, + "userEmail": userEmail, + "userPhone": userPhone, + "teamId": teamId, + "teamName": teamName, + "invited": invited, + "joined": joined, + "confirm": confirm, + "mfa": mfa, + "userAccessedAt": userAccessedAt, + "roles": roles, + }; + } } diff --git a/lib/src/models/membership_list.dart b/lib/src/models/membership_list.dart index a0641a28..cc664c9f 100644 --- a/lib/src/models/membership_list.dart +++ b/lib/src/models/membership_list.dart @@ -2,29 +2,30 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "memberships": memberships.map((p) => p.toMap()).toList(), - }; - } + @override + 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 3d2e2335..fa385541 100644 --- a/lib/src/models/mfa_challenge.dart +++ b/lib/src/models/mfa_challenge.dart @@ -2,41 +2,41 @@ 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(), + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "userId": userId, - "expire": expire, - }; - } + @override + 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 a7e5fefc..2777de7f 100644 --- a/lib/src/models/mfa_factors.dart +++ b/lib/src/models/mfa_factors.dart @@ -2,41 +2,41 @@ 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'], + ); + } - @override - Map toMap() { - return { - "totp": totp, - "phone": phone, - "email": email, - "recoveryCode": recoveryCode, - }; - } + @override + 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 33036476..864a5db8 100644 --- a/lib/src/models/mfa_recovery_codes.dart +++ b/lib/src/models/mfa_recovery_codes.dart @@ -2,23 +2,23 @@ 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'] ?? []), + ); + } - @override - Map toMap() { - return { - "recoveryCodes": recoveryCodes, - }; - } + @override + Map toMap() { + return { + "recoveryCodes": recoveryCodes, + }; + } } diff --git a/lib/src/models/mfa_type.dart b/lib/src/models/mfa_type.dart index 05cab363..fe5327fc 100644 --- a/lib/src/models/mfa_type.dart +++ b/lib/src/models/mfa_type.dart @@ -2,29 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return { - "secret": secret, - "uri": uri, - }; - } + @override + 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 7ac578e2..60e2abd9 100644 --- a/lib/src/models/phone.dart +++ b/lib/src/models/phone.dart @@ -2,35 +2,35 @@ 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(), + ); + } - @override - Map toMap() { - return { - "code": code, - "countryCode": countryCode, - "countryName": countryName, - }; - } + @override + 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 9791d590..1a197fc7 100644 --- a/lib/src/models/phone_list.dart +++ b/lib/src/models/phone_list.dart @@ -2,29 +2,29 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "phones": phones.map((p) => p.toMap()).toList(), - }; - } + @override + 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 b107afe5..3ca04118 100644 --- a/lib/src/models/preferences.dart +++ b/lib/src/models/preferences.dart @@ -2,24 +2,24 @@ 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["data"] ?? map, - ); - } + factory Preferences.fromMap(Map map) { + return Preferences( + data: map["data"] ?? map, + ); + } - @override - Map toMap() { - return { - "data": data, - }; - } + @override + 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/presence.dart b/lib/src/models/presence.dart index 133fe66d..d31911de 100644 --- a/lib/src/models/presence.dart +++ b/lib/src/models/presence.dart @@ -2,71 +2,71 @@ part of '../../models.dart'; /// Presence class Presence implements Model { - /// Presence ID. - final String $id; + /// Presence ID. + final String $id; - /// Presence creation date in ISO 8601 format. - final String $createdAt; + /// Presence creation date in ISO 8601 format. + final String $createdAt; - /// Presence update date in ISO 8601 format. - final String $updatedAt; + /// Presence update date in ISO 8601 format. + final String $updatedAt; - /// Presence permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; + /// Presence permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Presence status. - final String? status; + /// Presence status. + final String? status; - /// Presence source. - final String source; + /// Presence source. + final String source; - /// Presence expiry date in ISO 8601 format. - final String? expiresAt; + /// Presence expiry date in ISO 8601 format. + final String? expiresAt; - /// Presence metadata. - final Map? metadata; + /// Presence metadata. + final Map? metadata; - Presence({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.userId, - this.status, - required this.source, - this.expiresAt, - this.metadata, - }); + Presence({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.userId, + this.status, + required this.source, + this.expiresAt, + this.metadata, + }); - factory Presence.fromMap(Map map) { - return Presence( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - userId: map['userId'].toString(), - status: map['status']?.toString(), - source: map['source'].toString(), - expiresAt: map['expiresAt']?.toString(), - metadata: map['metadata'], - ); - } + factory Presence.fromMap(Map map) { + return Presence( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + userId: map['userId'].toString(), + status: map['status']?.toString(), + source: map['source'].toString(), + expiresAt: map['expiresAt']?.toString(), + metadata: map['metadata'], + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "userId": userId, - "status": status, - "source": source, - "expiresAt": expiresAt, - "metadata": metadata, - }; - } + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "userId": userId, + "status": status, + "source": source, + "expiresAt": expiresAt, + "metadata": metadata, + }; + } } diff --git a/lib/src/models/presence_list.dart b/lib/src/models/presence_list.dart index aebbe880..3d010b1c 100644 --- a/lib/src/models/presence_list.dart +++ b/lib/src/models/presence_list.dart @@ -2,29 +2,30 @@ part of '../../models.dart'; /// Presences List class PresenceList implements Model { - /// Total number of presences that matched your query. - final int total; + /// Total number of presences that matched your query. + final int total; - /// List of presences. - final List presences; + /// List of presences. + final List presences; - PresenceList({ - required this.total, - required this.presences, - }); + PresenceList({ + required this.total, + required this.presences, + }); - factory PresenceList.fromMap(Map map) { - return PresenceList( - total: map['total'], - presences: List.from(map['presences'].map((p) => Presence.fromMap(p))), - ); - } + factory PresenceList.fromMap(Map map) { + return PresenceList( + total: map['total'], + presences: + List.from(map['presences'].map((p) => Presence.fromMap(p))), + ); + } - @override - Map toMap() { - return { - "total": total, - "presences": presences.map((p) => p.toMap()).toList(), - }; - } + @override + Map toMap() { + return { + "total": total, + "presences": presences.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/row.dart b/lib/src/models/row.dart index c5f233b4..a825eab0 100644 --- a/lib/src/models/row.dart +++ b/lib/src/models/row.dart @@ -2,66 +2,66 @@ part of '../../models.dart'; /// Row class Row implements Model { - /// Row ID. - final String $id; + /// Row ID. + final String $id; - /// Row sequence ID. - final String $sequence; + /// Row sequence ID. + final String $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'].toString(), - $tableId: map['\$tableId'].toString(), - $databaseId: map['\$databaseId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - data: map["data"] ?? map, - ); - } + factory Row.fromMap(Map map) { + return Row( + $id: map['\$id'].toString(), + $sequence: map['\$sequence'].toString(), + $tableId: map['\$tableId'].toString(), + $databaseId: map['\$databaseId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + data: map["data"] ?? map, + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$sequence": $sequence, - "\$tableId": $tableId, - "\$databaseId": $databaseId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "data": data, - }; - } + @override + 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 90efa95f..5023c633 100644 --- a/lib/src/models/row_list.dart +++ b/lib/src/models/row_list.dart @@ -2,32 +2,32 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "rows": rows.map((p) => p.toMap()).toList(), - }; - } + @override + 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 c37de95a..92e4034e 100644 --- a/lib/src/models/session.dart +++ b/lib/src/models/session.dart @@ -2,191 +2,191 @@ 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(), - ); - } - - @override - 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(), + ); + } + + @override + 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 d823d0e6..4ea12394 100644 --- a/lib/src/models/session_list.dart +++ b/lib/src/models/session_list.dart @@ -2,29 +2,30 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "sessions": sessions.map((p) => p.toMap()).toList(), - }; - } + @override + 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 850ab8d2..450aafd1 100644 --- a/lib/src/models/subscriber.dart +++ b/lib/src/models/subscriber.dart @@ -2,71 +2,71 @@ 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(), + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "targetId": targetId, - "target": target.toMap(), - "userId": userId, - "userName": userName, - "topicId": topicId, - "providerType": providerType, - }; - } + @override + 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 742e7590..c2e8c4dc 100644 --- a/lib/src/models/target.dart +++ b/lib/src/models/target.dart @@ -2,71 +2,71 @@ 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'], + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "userId": userId, - "providerId": providerId, - "providerType": providerType, - "identifier": identifier, - "expired": expired, - }; - } + @override + 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 21e65e95..91b888b9 100644 --- a/lib/src/models/team.dart +++ b/lib/src/models/team.dart @@ -2,53 +2,53 @@ 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']), - ); - } - - @override - 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']), + ); + } + + @override + 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 ffca5e98..e8f1c621 100644 --- a/lib/src/models/team_list.dart +++ b/lib/src/models/team_list.dart @@ -2,29 +2,29 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "teams": teams.map((p) => p.toMap()).toList(), - }; - } + @override + 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 b05320da..b5ea87c8 100644 --- a/lib/src/models/token.dart +++ b/lib/src/models/token.dart @@ -2,53 +2,53 @@ 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(), - ); - } - - @override - 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(), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "userId": userId, + "secret": secret, + "expire": expire, + "phrase": phrase, + }; + } } diff --git a/lib/src/models/transaction.dart b/lib/src/models/transaction.dart index e3f3e43d..b0606dd8 100644 --- a/lib/src/models/transaction.dart +++ b/lib/src/models/transaction.dart @@ -2,53 +2,53 @@ part of '../../models.dart'; /// Transaction class Transaction implements Model { - /// Transaction ID. - final String $id; - - /// Transaction creation time in ISO 8601 format. - final String $createdAt; - - /// Transaction update date in ISO 8601 format. - final String $updatedAt; - - /// Current status of the transaction. One of: pending, committing, committed, rolled_back, failed. - final String status; - - /// Number of operations in the transaction. - final int operations; - - /// Expiration time in ISO 8601 format. - final String expiresAt; - - Transaction({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.status, - required this.operations, - required this.expiresAt, - }); - - factory Transaction.fromMap(Map map) { - return Transaction( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - status: map['status'].toString(), - operations: map['operations'], - expiresAt: map['expiresAt'].toString(), - ); - } - - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "status": status, - "operations": operations, - "expiresAt": expiresAt, - }; - } + /// Transaction ID. + final String $id; + + /// Transaction creation time in ISO 8601 format. + final String $createdAt; + + /// Transaction update date in ISO 8601 format. + final String $updatedAt; + + /// Current status of the transaction. One of: pending, committing, committed, rolled_back, failed. + final String status; + + /// Number of operations in the transaction. + final int operations; + + /// Expiration time in ISO 8601 format. + final String expiresAt; + + Transaction({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.status, + required this.operations, + required this.expiresAt, + }); + + factory Transaction.fromMap(Map map) { + return Transaction( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + status: map['status'].toString(), + operations: map['operations'], + expiresAt: map['expiresAt'].toString(), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "status": status, + "operations": operations, + "expiresAt": expiresAt, + }; + } } diff --git a/lib/src/models/transaction_list.dart b/lib/src/models/transaction_list.dart index 19ea651d..7f321175 100644 --- a/lib/src/models/transaction_list.dart +++ b/lib/src/models/transaction_list.dart @@ -2,29 +2,30 @@ part of '../../models.dart'; /// Transaction List class TransactionList implements Model { - /// Total number of transactions that matched your query. - final int total; + /// Total number of transactions that matched your query. + final int total; - /// List of transactions. - final List transactions; + /// List of transactions. + final List transactions; - TransactionList({ - required this.total, - required this.transactions, - }); + TransactionList({ + required this.total, + required this.transactions, + }); - factory TransactionList.fromMap(Map map) { - return TransactionList( - total: map['total'], - transactions: List.from(map['transactions'].map((p) => Transaction.fromMap(p))), - ); - } + factory TransactionList.fromMap(Map map) { + return TransactionList( + total: map['total'], + transactions: List.from( + map['transactions'].map((p) => Transaction.fromMap(p))), + ); + } - @override - Map toMap() { - return { - "total": total, - "transactions": transactions.map((p) => p.toMap()).toList(), - }; - } + @override + Map toMap() { + return { + "total": total, + "transactions": transactions.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/user.dart b/lib/src/models/user.dart index e3b9536b..5a6cad30 100644 --- a/lib/src/models/user.dart +++ b/lib/src/models/user.dart @@ -2,173 +2,173 @@ part of '../../models.dart'; /// User class User implements Model { - /// User ID. - final String $id; + /// User ID. + final String $id; - /// User creation date in ISO 8601 format. - final String $createdAt; + /// User creation date in ISO 8601 format. + final String $createdAt; - /// User update date in ISO 8601 format. - final String $updatedAt; + /// 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; - - /// Canonical form of the user email address. - final String? emailCanonical; - - /// Whether the user email is from a free email provider. - final bool? emailIsFree; - - /// Whether the user email is from a disposable email provider. - final bool? emailIsDisposable; - - /// Whether the user email is from a corporate domain. - final bool? emailIsCorporate; - - /// Whether the user email is in its canonical form. - final bool? emailIsCanonical; - - /// 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; - - /// Whether the user can impersonate other users. - final bool? impersonator; - - /// ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data. - final String? impersonatorUserId; - - 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, - this.emailCanonical, - this.emailIsFree, - this.emailIsDisposable, - this.emailIsCorporate, - this.emailIsCanonical, - required this.phoneVerification, - required this.mfa, - required this.prefs, - required this.targets, - required this.accessedAt, - this.impersonator, - this.impersonatorUserId, - }); - - 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'], - emailCanonical: map['emailCanonical']?.toString(), - emailIsFree: map['emailIsFree'], - emailIsDisposable: map['emailIsDisposable'], - emailIsCorporate: map['emailIsCorporate'], - emailIsCanonical: map['emailIsCanonical'], - 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(), - impersonator: map['impersonator'], - impersonatorUserId: map['impersonatorUserId']?.toString(), - ); - } - - @override - 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, - "emailCanonical": emailCanonical, - "emailIsFree": emailIsFree, - "emailIsDisposable": emailIsDisposable, - "emailIsCorporate": emailIsCorporate, - "emailIsCanonical": emailIsCanonical, - "phoneVerification": phoneVerification, - "mfa": mfa, - "prefs": prefs.toMap(), - "targets": targets.map((p) => p.toMap()).toList(), - "accessedAt": accessedAt, - "impersonator": impersonator, - "impersonatorUserId": impersonatorUserId, - }; - } + /// 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; + + /// Canonical form of the user email address. + final String? emailCanonical; + + /// Whether the user email is from a free email provider. + final bool? emailIsFree; + + /// Whether the user email is from a disposable email provider. + final bool? emailIsDisposable; + + /// Whether the user email is from a corporate domain. + final bool? emailIsCorporate; + + /// Whether the user email is in its canonical form. + final bool? emailIsCanonical; + + /// 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; + + /// Whether the user can impersonate other users. + final bool? impersonator; + + /// ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data. + final String? impersonatorUserId; + + 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, + this.emailCanonical, + this.emailIsFree, + this.emailIsDisposable, + this.emailIsCorporate, + this.emailIsCanonical, + required this.phoneVerification, + required this.mfa, + required this.prefs, + required this.targets, + required this.accessedAt, + this.impersonator, + this.impersonatorUserId, + }); + + 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'], + emailCanonical: map['emailCanonical']?.toString(), + emailIsFree: map['emailIsFree'], + emailIsDisposable: map['emailIsDisposable'], + emailIsCorporate: map['emailIsCorporate'], + emailIsCanonical: map['emailIsCanonical'], + 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(), + impersonator: map['impersonator'], + impersonatorUserId: map['impersonatorUserId']?.toString(), + ); + } + + @override + 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, + "emailCanonical": emailCanonical, + "emailIsFree": emailIsFree, + "emailIsDisposable": emailIsDisposable, + "emailIsCorporate": emailIsCorporate, + "emailIsCanonical": emailIsCanonical, + "phoneVerification": phoneVerification, + "mfa": mfa, + "prefs": prefs.toMap(), + "targets": targets.map((p) => p.toMap()).toList(), + "accessedAt": accessedAt, + "impersonator": impersonator, + "impersonatorUserId": impersonatorUserId, + }; + } } diff --git a/lib/src/realtime.dart b/lib/src/realtime.dart index 7a5e6303..28e4c43d 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(); /// ``` - /// + /// /// You can also use Channel builders: /// ```dart /// final subscription = realtime.subscribe([ diff --git a/lib/src/realtime_io.dart b/lib/src/realtime_io.dart index 83f01b4c..0ed367a6 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 6cebb5b1..72edf5ee 100644 --- a/lib/src/realtime_mixin.dart +++ b/lib/src/realtime_mixin.dart @@ -58,9 +58,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"})); } }); } @@ -140,9 +138,11 @@ mixin RealtimeMixin { case 'event': final messageData = data.data as Map; final message = RealtimeMessage.fromMap(messageData); - final subscriptions = (messageData['subscriptions'] as List?) - ?.map((x) => x.toString()) - .toList() ?? []; + final subscriptions = + (messageData['subscriptions'] as List?) + ?.map((x) => x.toString()) + .toList() ?? + []; if (subscriptions.isEmpty) { break; @@ -209,13 +209,15 @@ mixin RealtimeMixin { "Please set endPointRealtime to connect to realtime server"); } var uri = Uri.parse(client.endPointRealtime!); - - var queryParams = "project=${Uri.encodeComponent(client.config['project']!)}"; + + var queryParams = + "project=${Uri.encodeComponent(client.config['project']!)}"; final portPart = (uri.hasPort && uri.port != 80 && uri.port != 443) ? ':${uri.port}' : ''; - return Uri.parse("${uri.scheme}://${uri.host}$portPart${uri.path}/realtime?$queryParams"); + return Uri.parse( + "${uri.scheme}://${uri.host}$portPart${uri.path}/realtime?$queryParams"); } void _sendUnsubscribeMessage(List subscriptionIds) { @@ -310,9 +312,11 @@ mixin RealtimeMixin { return channel is String ? channel : channel.toString(); } - RealtimeSubscription subscribeTo(List channels, [List queries = const []]) { + RealtimeSubscription subscribeTo(List channels, + [List queries = const []]) { StreamController controller = StreamController.broadcast(); - final channelStrings = channels.map((ch) => _channelToString(ch)).toList().cast(); + final channelStrings = + channels.map((ch) => _channelToString(ch)).toList().cast(); final queryStrings = List.from(queries); final subscriptionId = _generateUniqueSubscriptionId(); @@ -329,8 +333,7 @@ mixin RealtimeMixin { _sendUnsubscribeMessage([subscriptionId]); } - Future update( - {List? channels, List? queries}) async { + Future update({List? channels, List? queries}) async { final current = _subscriptions[subscriptionId]; if (current == null) { return; @@ -417,4 +420,4 @@ mixin RealtimeMixin { // until the application-level handshake completes. _flushPendingPresence(); } -} \ 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 diff --git a/lib/src/realtime_stub.dart b/lib/src/realtime_stub.dart index ce0b7e95..3aab4e03 100644 --- a/lib/src/realtime_stub.dart +++ b/lib/src/realtime_stub.dart @@ -3,5 +3,5 @@ import 'client.dart'; /// Implemented in `realtime_browser.dart` and `realtime_io.dart`. RealtimeBase createRealtime(Client client) => throw UnsupportedError( - 'Cannot create a client without dart:html or dart:io.', -); + 'Cannot create a client without dart:html or dart:io.', + ); diff --git a/test/channel_test.dart b/test/channel_test.dart index 62031aec..9e0e11d3 100644 --- a/test/channel_test.dart +++ b/test/channel_test.dart @@ -13,12 +13,22 @@ void main() { }); test('returns database channel with action', () { - expect(Channel.database('db1').collection('col1').document('doc1').create().toString(), + expect( + Channel.database('db1') + .collection('col1') + .document('doc1') + .create() + .toString(), 'databases.db1.collections.col1.documents.doc1.create'); }); test('returns database channel with upsert action', () { - expect(Channel.database('db1').collection('col1').document('doc1').upsert().toString(), + expect( + Channel.database('db1') + .collection('col1') + .document('doc1') + .upsert() + .toString(), 'databases.db1.collections.col1.documents.doc1.upsert'); }); }); @@ -34,7 +44,12 @@ void main() { }); test('returns tablesdb channel with action', () { - expect(Channel.tablesdb('db1').table('table1').row('row1').update().toString(), + expect( + Channel.tablesdb('db1') + .table('table1') + .row('row1') + .update() + .toString(), 'tablesdb.db1.tables.table1.rows.row1.update'); }); }); @@ -47,16 +62,16 @@ void main() { group('bucket()', () { test('throws when bucket id is missing', () { - expect(() => Channel.bucket(''), throwsArgumentError); + expect(() => Channel.bucket(''), throwsArgumentError); }); test('returns buckets channel with specific IDs', () { - expect(Channel.bucket('bucket1').file().toString(), - 'buckets.bucket1.files'); + expect( + Channel.bucket('bucket1').file().toString(), 'buckets.bucket1.files'); }); test('returns buckets channel with action', () { - expect(Channel.bucket('bucket1').file('file1').delete().toString(), + expect(Channel.bucket('bucket1').file('file1').delete().toString(), 'buckets.bucket1.files.file1.delete'); }); }); @@ -83,29 +98,30 @@ void main() { group('teams()', () { test('throws when team id is missing', () { - expect(() => Channel.team(''), throwsArgumentError); + expect(() => Channel.team(''), throwsArgumentError); }); test('returns teams channel with specific team ID', () { - expect(Channel.team('team1').toString(), 'teams.team1'); + expect(Channel.team('team1').toString(), 'teams.team1'); }); test('returns teams channel with action', () { - expect(Channel.team('team1').create().toString(), 'teams.team1.create'); + expect(Channel.team('team1').create().toString(), 'teams.team1.create'); }); }); group('memberships()', () { test('throws when membership id is missing', () { - expect(() => Channel.membership(''), throwsArgumentError); + expect(() => Channel.membership(''), throwsArgumentError); }); test('returns memberships channel with specific membership ID', () { - expect(Channel.membership('membership1').toString(), 'memberships.membership1'); + expect(Channel.membership('membership1').toString(), + 'memberships.membership1'); }); test('returns memberships channel with action', () { - expect(Channel.membership('membership1').update().toString(), + expect(Channel.membership('membership1').update().toString(), 'memberships.membership1.update'); }); }); diff --git a/test/query_test.dart b/test/query_test.dart index 25388fad..db7b9214 100644 --- a/test/query_test.dart +++ b/test/query_test.dart @@ -354,4 +354,3 @@ void main() { expect(query['method'], 'between'); }); } - diff --git a/test/services/account_test.dart b/test/services/account_test.dart index bd65aa32..d5d61fe7 100644 --- a/test/services/account_test.dart +++ b/test/services/account_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,1540 +40,1356 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Account test', () { - late MockClient client; - late Account account; - - setUp(() { - client = MockClient(); - account = Account(client); - }); - - test('test method get()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.get( - ); - expect(response, isA()); - - }); - - test('test method create()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.create( - userId: '', - email: 'email@example.com', - password: 'password', - ); - expect(response, isA()); - - }); - - test('test method updateEmail()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateEmail( - email: 'email@example.com', - password: 'password', - ); - expect(response, isA()); - - }); - - test('test method listIdentities()', () async { - - final Map data = { - 'total': 5, - 'identities': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.listIdentities( - ); - expect(response, isA()); - - }); - - test('test method deleteIdentity()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.deleteIdentity( - identityId: '', - ); - }); - - test('test method createJWT()', () async { - - final Map data = { - 'jwt': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createJWT( - ); - expect(response, isA()); - - }); - - test('test method listLogs()', () async { - - final Map data = { - 'total': 5, - 'logs': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.listLogs( - ); - expect(response, isA()); - - }); - - test('test method updateMFA()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateMFA( - mfa: true, - ); - expect(response, isA()); - - }); - - test('test method createMfaAuthenticator()', () async { - - final Map data = { - 'secret': '[SHARED_SECRET]', - 'uri': 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createMfaAuthenticator( - type: enums.AuthenticatorType.totp, - ); - expect(response, isA()); - - }); - - test('test method createMFAAuthenticator()', () async { - - final Map data = { - 'secret': '[SHARED_SECRET]', - 'uri': 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createMFAAuthenticator( - type: enums.AuthenticatorType.totp, - ); - expect(response, isA()); - - }); - - test('test method updateMfaAuthenticator()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateMfaAuthenticator( - type: enums.AuthenticatorType.totp, - otp: '', - ); - expect(response, isA()); - - }); - - test('test method updateMFAAuthenticator()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateMFAAuthenticator( - type: enums.AuthenticatorType.totp, - otp: '', - ); - expect(response, isA()); - - }); - - test('test method deleteMfaAuthenticator()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.deleteMfaAuthenticator( - type: enums.AuthenticatorType.totp, - ); - }); - - test('test method deleteMFAAuthenticator()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.deleteMFAAuthenticator( - type: enums.AuthenticatorType.totp, - ); - }); - - test('test method createMfaChallenge()', () async { - - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'expire': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createMfaChallenge( - factor: enums.AuthenticationFactor.email, - ); - expect(response, isA()); - - }); - - test('test method createMFAChallenge()', () async { - - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'expire': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createMFAChallenge( - factor: enums.AuthenticationFactor.email, - ); - expect(response, isA()); - - }); - - test('test method updateMfaChallenge()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateMfaChallenge( - challengeId: '', - otp: '', - ); - expect(response, isA()); - - }); - - test('test method updateMFAChallenge()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateMFAChallenge( - challengeId: '', - otp: '', - ); - expect(response, isA()); - - }); - - test('test method listMfaFactors()', () async { - - final Map data = { - 'totp': true, - 'phone': true, - 'email': true, - 'recoveryCode': true,}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.listMfaFactors( - ); - expect(response, isA()); - - }); - - test('test method listMFAFactors()', () async { - - final Map data = { - 'totp': true, - 'phone': true, - 'email': true, - 'recoveryCode': true,}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.listMFAFactors( - ); - expect(response, isA()); - - }); - - test('test method getMfaRecoveryCodes()', () async { - - final Map data = { - 'recoveryCodes': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.getMfaRecoveryCodes( - ); - expect(response, isA()); - - }); - - test('test method getMFARecoveryCodes()', () async { - - final Map data = { - 'recoveryCodes': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.getMFARecoveryCodes( - ); - expect(response, isA()); - - }); - - test('test method createMfaRecoveryCodes()', () async { - - final Map data = { - 'recoveryCodes': [],}; - + group('Account test', () { + late MockClient client; + late Account account; - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createMfaRecoveryCodes( - ); - expect(response, isA()); - - }); - - test('test method createMFARecoveryCodes()', () async { - - final Map data = { - 'recoveryCodes': [],}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createMFARecoveryCodes( - ); - expect(response, isA()); - - }); - - test('test method updateMfaRecoveryCodes()', () async { - - final Map data = { - 'recoveryCodes': [],}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateMfaRecoveryCodes( - ); - expect(response, isA()); - - }); - - test('test method updateMFARecoveryCodes()', () async { - - final Map data = { - 'recoveryCodes': [],}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateMFARecoveryCodes( - ); - expect(response, isA()); - - }); - - test('test method updateName()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateName( - name: '', - ); - expect(response, isA()); - - }); - - test('test method updatePassword()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updatePassword( - password: 'password', - ); - expect(response, isA()); - - }); - - test('test method updatePhone()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updatePhone( - phone: '+12065550100', - password: 'password', - ); - expect(response, isA()); - - }); - - test('test method getPrefs()', () async { - - final Map data = {}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.getPrefs( - ); - expect(response, isA()); - - }); - - test('test method updatePrefs()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updatePrefs( - prefs: {}, - ); - expect(response, isA()); - - }); - - test('test method createRecovery()', () async { - - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createRecovery( - email: 'email@example.com', - url: 'https://example.com', - ); - expect(response, isA()); - - }); - - test('test method updateRecovery()', () async { - - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + setUp(() { + client = MockClient(); + account = Account(client); + }); + test('test method get()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.get(); + expect(response, isA()); + }); - final response = await account.updateRecovery( - userId: '', - secret: '', - password: 'password', - ); - expect(response, isA()); + test('test method create()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.create( + userId: '', + email: 'email@example.com', + password: 'password', + ); + expect(response, isA()); + }); - }); + test('test method updateEmail()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateEmail( + email: 'email@example.com', + password: 'password', + ); + expect(response, isA()); + }); - test('test method listSessions()', () async { - - final Map data = { - 'total': 5, - 'sessions': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.listSessions( - ); - expect(response, isA()); - - }); - - test('test method deleteSessions()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.deleteSessions( - ); - }); - - test('test method createAnonymousSession()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createAnonymousSession( - ); - expect(response, isA()); - - }); - - test('test method createEmailPasswordSession()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createEmailPasswordSession( - email: 'email@example.com', - password: 'password', - ); - expect(response, isA()); - - }); - - test('test method updateMagicURLSession()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateMagicURLSession( - userId: '', - secret: '', - ); - expect(response, isA()); - - }); - - test('test method createOAuth2Session()', () async { - - - when(client.webAuth( - argThat(isNotNull), - )).thenAnswer((_) async => 'done'); - - - final response = await account.createOAuth2Session( - provider: enums.OAuthProvider.amazon, - ); - expect(response, equals('done')); - - }); - - test('test method updatePhoneSession()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updatePhoneSession( - userId: '', - secret: '', - ); - expect(response, isA()); - - }); - - test('test method createSession()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createSession( - userId: '', - secret: '', - ); - expect(response, isA()); - - }); - - test('test method getSession()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.getSession( - sessionId: '', - ); - expect(response, isA()); - - }); - - test('test method updateSession()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateSession( - sessionId: '', - ); - expect(response, isA()); - - }); - - test('test method deleteSession()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.deleteSession( - sessionId: '', - ); - }); - - test('test method updateStatus()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + test('test method listIdentities()', () async { + final Map data = { + 'total': 5, + 'identities': [], + }; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + final response = await account.listIdentities(); + expect(response, isA()); + }); + test('test method deleteIdentity()', () async { + final data = ''; - final response = await account.updateStatus( - ); - expect(response, isA()); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await account.deleteIdentity( + identityId: '', + ); + }); - test('test method createPushTarget()', () async { + test('test method createJWT()', () async { + final Map data = { + 'jwt': + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', + }; - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'Apple iPhone 12', - 'userId': '259125845563242502', - 'providerType': 'email', - 'identifier': 'token', - 'expired': true,}; + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + final response = await account.createJWT(); + expect(response, isA()); + }); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + test('test method listLogs()', () async { + final Map data = { + 'total': 5, + 'logs': [], + }; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await account.createPushTarget( - targetId: '', - identifier: '', - ); - expect(response, isA()); + final response = await account.listLogs(); + expect(response, isA()); + }); - }); + test('test method updateMFA()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateMFA( + mfa: true, + ); + expect(response, isA()); + }); - test('test method updatePushTarget()', () async { + test('test method createMfaAuthenticator()', () async { + final Map data = { + 'secret': '[SHARED_SECRET]', + 'uri': + 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createMfaAuthenticator( + type: enums.AuthenticatorType.totp, + ); + expect(response, isA()); + }); - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'Apple iPhone 12', - 'userId': '259125845563242502', - 'providerType': 'email', - 'identifier': 'token', - 'expired': true,}; + test('test method createMFAAuthenticator()', () async { + final Map data = { + 'secret': '[SHARED_SECRET]', + 'uri': + 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createMFAAuthenticator( + type: enums.AuthenticatorType.totp, + ); + expect(response, isA()); + }); + test('test method updateMfaAuthenticator()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateMfaAuthenticator( + type: enums.AuthenticatorType.totp, + otp: '', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + test('test method updateMFAAuthenticator()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateMFAAuthenticator( + type: enums.AuthenticatorType.totp, + otp: '', + ); + expect(response, isA()); + }); + test('test method deleteMfaAuthenticator()', () async { + final data = ''; - final response = await account.updatePushTarget( - targetId: '', - identifier: '', - ); - expect(response, isA()); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await account.deleteMfaAuthenticator( + type: enums.AuthenticatorType.totp, + ); + }); - test('test method deletePushTarget()', () async { + test('test method deleteMFAAuthenticator()', () async { + final data = ''; - final data = ''; + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + final response = await account.deleteMFAAuthenticator( + type: enums.AuthenticatorType.totp, + ); + }); + test('test method createMfaChallenge()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'expire': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createMfaChallenge( + factor: enums.AuthenticationFactor.email, + ); + expect(response, isA()); + }); - final response = await account.deletePushTarget( - targetId: '', - ); - }); + test('test method createMFAChallenge()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'expire': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createMFAChallenge( + factor: enums.AuthenticationFactor.email, + ); + expect(response, isA()); + }); - test('test method createEmailToken()', () async { + test('test method updateMfaChallenge()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateMfaChallenge( + challengeId: '', + otp: '', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + test('test method updateMFAChallenge()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateMFAChallenge( + challengeId: '', + otp: '', + ); + expect(response, isA()); + }); + test('test method listMfaFactors()', () async { + final Map data = { + 'totp': true, + 'phone': true, + 'email': true, + 'recoveryCode': true, + }; - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await account.listMfaFactors(); + expect(response, isA()); + }); - final response = await account.createEmailToken( - userId: '', - email: 'email@example.com', - ); - expect(response, isA()); + test('test method listMFAFactors()', () async { + final Map data = { + 'totp': true, + 'phone': true, + 'email': true, + 'recoveryCode': true, + }; - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method createMagicURLToken()', () async { + final response = await account.listMFAFactors(); + expect(response, isA()); + }); - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + test('test method getMfaRecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [], + }; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + final response = await account.getMfaRecoveryCodes(); + expect(response, isA()); + }); + test('test method getMFARecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [], + }; - final response = await account.createMagicURLToken( - userId: '', - email: 'email@example.com', - ); - expect(response, isA()); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await account.getMFARecoveryCodes(); + expect(response, isA()); + }); - test('test method createOAuth2Token()', () async { + test('test method createMfaRecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [], + }; + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - when(client.webAuth( - argThat(isNotNull), - )).thenAnswer((_) async => 'done'); + final response = await account.createMfaRecoveryCodes(); + expect(response, isA()); + }); + test('test method createMFARecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [], + }; - final response = await account.createOAuth2Token( - provider: enums.OAuthProvider.amazon, - ); - expect(response, equals('done')); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await account.createMFARecoveryCodes(); + expect(response, isA()); + }); - test('test method createPhoneToken()', () async { + test('test method updateMfaRecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [], + }; - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + final response = await account.updateMfaRecoveryCodes(); + expect(response, isA()); + }); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + test('test method updateMFARecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [], + }; + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); - final response = await account.createPhoneToken( - userId: '', - phone: '+12065550100', - ); - expect(response, isA()); + final response = await account.updateMFARecoveryCodes(); + expect(response, isA()); + }); - }); + test('test method updateName()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateName( + name: '', + ); + expect(response, isA()); + }); - test('test method createEmailVerification()', () async { + test('test method updatePassword()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updatePassword( + password: 'password', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + test('test method updatePhone()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updatePhone( + phone: '+12065550100', + password: 'password', + ); + expect(response, isA()); + }); + test('test method getPrefs()', () async { + final Map data = {}; - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await account.getPrefs(); + expect(response, isA()); + }); - final response = await account.createEmailVerification( - url: 'https://example.com', - ); - expect(response, isA()); + test('test method updatePrefs()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updatePrefs( + prefs: {}, + ); + expect(response, isA()); + }); - }); + test('test method createRecovery()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createRecovery( + email: 'email@example.com', + url: 'https://example.com', + ); + expect(response, isA()); + }); - test('test method createVerification()', () async { + test('test method updateRecovery()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateRecovery( + userId: '', + secret: '', + password: 'password', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + test('test method listSessions()', () async { + final Map data = { + 'total': 5, + 'sessions': [], + }; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + final response = await account.listSessions(); + expect(response, isA()); + }); + test('test method deleteSessions()', () async { + final data = ''; - final response = await account.createVerification( - url: 'https://example.com', - ); - expect(response, isA()); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await account.deleteSessions(); + }); - test('test method updateEmailVerification()', () async { + test('test method createAnonymousSession()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createAnonymousSession(); + expect(response, isA()); + }); - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + test('test method createEmailPasswordSession()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createEmailPasswordSession( + email: 'email@example.com', + password: 'password', + ); + expect(response, isA()); + }); + test('test method updateMagicURLSession()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateMagicURLSession( + userId: '', + secret: '', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + test('test method createOAuth2Session()', () async { + when(client.webAuth( + argThat(isNotNull), + )).thenAnswer((_) async => 'done'); + final response = await account.createOAuth2Session( + provider: enums.OAuthProvider.amazon, + ); + expect(response, equals('done')); + }); - final response = await account.updateEmailVerification( - userId: '', - secret: '', - ); - expect(response, isA()); + test('test method updatePhoneSession()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updatePhoneSession( + userId: '', + secret: '', + ); + expect(response, isA()); + }); - }); + test('test method createSession()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createSession( + userId: '', + secret: '', + ); + expect(response, isA()); + }); - test('test method updateVerification()', () async { + test('test method getSession()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.getSession( + sessionId: '', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + test('test method updateSession()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateSession( + sessionId: '', + ); + expect(response, isA()); + }); + test('test method deleteSession()', () async { + final data = ''; - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + final response = await account.deleteSession( + sessionId: '', + ); + }); - final response = await account.updateVerification( - userId: '', - secret: '', - ); - expect(response, isA()); + test('test method updateStatus()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateStatus(); + expect(response, isA()); + }); - }); + test('test method createPushTarget()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Apple iPhone 12', + 'userId': '259125845563242502', + 'providerType': 'email', + 'identifier': 'token', + 'expired': true, + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createPushTarget( + targetId: '', + identifier: '', + ); + expect(response, isA()); + }); - test('test method createPhoneVerification()', () async { + test('test method updatePushTarget()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Apple iPhone 12', + 'userId': '259125845563242502', + 'providerType': 'email', + 'identifier': 'token', + 'expired': true, + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updatePushTarget( + targetId: '', + identifier: '', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + test('test method deletePushTarget()', () async { + final data = ''; + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + final response = await account.deletePushTarget( + targetId: '', + ); + }); + test('test method createEmailToken()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createEmailToken( + userId: '', + email: 'email@example.com', + ); + expect(response, isA()); + }); - final response = await account.createPhoneVerification( - ); - expect(response, isA()); + test('test method createMagicURLToken()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createMagicURLToken( + userId: '', + email: 'email@example.com', + ); + expect(response, isA()); + }); - }); + test('test method createOAuth2Token()', () async { + when(client.webAuth( + argThat(isNotNull), + )).thenAnswer((_) async => 'done'); - test('test method updatePhoneVerification()', () async { + final response = await account.createOAuth2Token( + provider: enums.OAuthProvider.amazon, + ); + expect(response, equals('done')); + }); - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + test('test method createPhoneToken()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createPhoneToken( + userId: '', + phone: '+12065550100', + ); + expect(response, isA()); + }); + test('test method createEmailVerification()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createEmailVerification( + url: 'https://example.com', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + test('test method createVerification()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createVerification( + url: 'https://example.com', + ); + expect(response, isA()); + }); + test('test method updateEmailVerification()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateEmailVerification( + userId: '', + secret: '', + ); + expect(response, isA()); + }); - final response = await account.updatePhoneVerification( - userId: '', - secret: '', - ); - expect(response, isA()); + test('test method updateVerification()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateVerification( + userId: '', + secret: '', + ); + expect(response, isA()); + }); - }); + test('test method createPhoneVerification()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createPhoneVerification(); + expect(response, isA()); + }); + test('test method updatePhoneVerification()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updatePhoneVerification( + userId: '', + secret: '', + ); + expect(response, isA()); }); + }); } diff --git a/test/services/avatars_test.dart b/test/services/avatars_test.dart index 4bdb434d..8d2c48fb 100644 --- a/test/services/avatars_test.dart +++ b/test/services/avatars_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,138 +40,123 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Avatars test', () { - late MockClient client; - late Avatars avatars; - - setUp(() { - client = MockClient(); - avatars = Avatars(client); - }); - - test('test method getBrowser()', () async { -final Uint8List data = Uint8List.fromList([]); - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await avatars.getBrowser( - code: enums.Browser.avantBrowser, - ); - expect(response, isA()); - - }); - - test('test method getCreditCard()', () async { -final Uint8List data = Uint8List.fromList([]); - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await avatars.getCreditCard( - code: enums.CreditCard.americanExpress, - ); - expect(response, isA()); - - }); - - test('test method getFavicon()', () async { -final Uint8List data = Uint8List.fromList([]); + group('Avatars test', () { + late MockClient client; + late Avatars avatars; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await avatars.getFavicon( - url: 'https://example.com', - ); - expect(response, isA()); - - }); - - test('test method getFlag()', () async { -final Uint8List data = Uint8List.fromList([]); - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + setUp(() { + client = MockClient(); + avatars = Avatars(client); + }); + test('test method getBrowser()', () async { + final Uint8List data = Uint8List.fromList([]); - final response = await avatars.getFlag( - code: enums.Flag.afghanistan, - ); - expect(response, isA()); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await avatars.getBrowser( + code: enums.Browser.avantBrowser, + ); + expect(response, isA()); + }); - test('test method getImage()', () async { -final Uint8List data = Uint8List.fromList([]); + test('test method getCreditCard()', () async { + final Uint8List data = Uint8List.fromList([]); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await avatars.getCreditCard( + code: enums.CreditCard.americanExpress, + ); + expect(response, isA()); + }); - final response = await avatars.getImage( - url: 'https://example.com', - ); - expect(response, isA()); + test('test method getFavicon()', () async { + final Uint8List data = Uint8List.fromList([]); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method getInitials()', () async { -final Uint8List data = Uint8List.fromList([]); + final response = await avatars.getFavicon( + url: 'https://example.com', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + test('test method getFlag()', () async { + final Uint8List data = Uint8List.fromList([]); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await avatars.getInitials( - ); - expect(response, isA()); + final response = await avatars.getFlag( + code: enums.Flag.afghanistan, + ); + expect(response, isA()); + }); - }); + test('test method getImage()', () async { + final Uint8List data = Uint8List.fromList([]); - test('test method getQR()', () async { -final Uint8List data = Uint8List.fromList([]); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final response = await avatars.getImage( + url: 'https://example.com', + ); + expect(response, isA()); + }); + test('test method getInitials()', () async { + final Uint8List data = Uint8List.fromList([]); - final response = await avatars.getQR( - text: '', - ); - expect(response, isA()); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await avatars.getInitials(); + expect(response, isA()); + }); - test('test method getScreenshot()', () async { -final Uint8List data = Uint8List.fromList([]); + test('test method getQR()', () async { + final Uint8List data = Uint8List.fromList([]); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await avatars.getQR( + text: '', + ); + expect(response, isA()); + }); - final response = await avatars.getScreenshot( - url: 'https://example.com', - ); - expect(response, isA()); + test('test method getScreenshot()', () async { + final Uint8List data = Uint8List.fromList([]); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await avatars.getScreenshot( + url: 'https://example.com', + ); + expect(response, isA()); }); + }); } diff --git a/test/services/databases_test.dart b/test/services/databases_test.dart index a4b0a6cc..a3807093 100644 --- a/test/services/databases_test.dart +++ b/test/services/databases_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,337 +40,297 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Databases test', () { - late MockClient client; - late Databases databases; - - setUp(() { - client = MockClient(); - databases = Databases(client); - }); - - test('test method listTransactions()', () async { - - final Map data = { - 'total': 5, - 'transactions': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.listTransactions( - ); - expect(response, isA()); - - }); - - test('test method createTransaction()', () async { - - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.createTransaction( - ); - expect(response, isA()); - - }); - - test('test method getTransaction()', () async { - - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.getTransaction( - transactionId: '', - ); - expect(response, isA()); - - }); - - test('test method updateTransaction()', () async { - - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.updateTransaction( - transactionId: '', - ); - expect(response, isA()); - - }); - - test('test method deleteTransaction()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.deleteTransaction( - transactionId: '', - ); - }); - - test('test method createOperations()', () async { - - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.createOperations( - transactionId: '', - ); - expect(response, isA()); - - }); - - test('test method listDocuments()', () async { - - final Map data = { - 'total': 5, - 'documents': [],}; - + group('Databases test', () { + late MockClient client; + late Databases databases; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.listDocuments( - databaseId: '', - collectionId: '', - ); - expect(response, isA()); - - }); - - test('test method createDocument()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.createDocument( - databaseId: '', - collectionId: '', - documentId: '', - data: {}, - ); - expect(response, isA()); - - }); - - test('test method getDocument()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.getDocument( - databaseId: '', - collectionId: '', - documentId: '', - ); - expect(response, isA()); - - }); - - test('test method upsertDocument()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.upsertDocument( - databaseId: '', - collectionId: '', - documentId: '', - ); - expect(response, isA()); - - }); - - test('test method updateDocument()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.updateDocument( - databaseId: '', - collectionId: '', - documentId: '', - ); - expect(response, isA()); - - }); + setUp(() { + client = MockClient(); + databases = Databases(client); + }); - test('test method deleteDocument()', () async { + test('test method listTransactions()', () async { + final Map data = { + 'total': 5, + 'transactions': [], + }; - final data = ''; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + final response = await databases.listTransactions(); + expect(response, isA()); + }); + test('test method createTransaction()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.createTransaction(); + expect(response, isA()); + }); - final response = await databases.deleteDocument( - databaseId: '', - collectionId: '', - documentId: '', - ); - }); + test('test method getTransaction()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.getTransaction( + transactionId: '', + ); + expect(response, isA()); + }); - test('test method decrementDocumentAttribute()', () async { + test('test method updateTransaction()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.updateTransaction( + transactionId: '', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; + test('test method deleteTransaction()', () async { + final data = ''; + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + final response = await databases.deleteTransaction( + transactionId: '', + ); + }); + test('test method createOperations()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.createOperations( + transactionId: '', + ); + expect(response, isA()); + }); - final response = await databases.decrementDocumentAttribute( - databaseId: '', - collectionId: '', - documentId: '', - attribute: '', - ); - expect(response, isA()); + test('test method listDocuments()', () async { + final Map data = { + 'total': 5, + 'documents': [], + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.listDocuments( + databaseId: '', + collectionId: '', + ); + expect(response, isA()); + }); - }); + test('test method createDocument()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.createDocument( + databaseId: '', + collectionId: '', + documentId: '', + data: {}, + ); + expect(response, isA()); + }); - test('test method incrementDocumentAttribute()', () async { + test('test method getDocument()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.getDocument( + databaseId: '', + collectionId: '', + documentId: '', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; + test('test method upsertDocument()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.upsertDocument( + databaseId: '', + collectionId: '', + documentId: '', + ); + expect(response, isA()); + }); + test('test method updateDocument()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.updateDocument( + databaseId: '', + collectionId: '', + documentId: '', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + test('test method deleteDocument()', () async { + final data = ''; + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - final response = await databases.incrementDocumentAttribute( - databaseId: '', - collectionId: '', - documentId: '', - attribute: '', - ); - expect(response, isA()); + final response = await databases.deleteDocument( + databaseId: '', + collectionId: '', + documentId: '', + ); + }); - }); + test('test method decrementDocumentAttribute()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.decrementDocumentAttribute( + databaseId: '', + collectionId: '', + documentId: '', + attribute: '', + ); + expect(response, isA()); + }); + test('test method incrementDocumentAttribute()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.incrementDocumentAttribute( + databaseId: '', + collectionId: '', + documentId: '', + attribute: '', + ); + expect(response, isA()); }); + }); } diff --git a/test/services/functions_test.dart b/test/services/functions_test.dart index 9b0d046f..c6e50a50 100644 --- a/test/services/functions_test.dart +++ b/test/services/functions_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,107 +40,100 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Functions test', () { - late MockClient client; - late Functions functions; - - setUp(() { - client = MockClient(); - functions = Functions(client); - }); - - test('test method listExecutions()', () async { - - final Map data = { - 'total': 5, - 'executions': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await functions.listExecutions( - functionId: '', - ); - expect(response, isA()); - - }); - - test('test method createExecution()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'functionId': '5e5ea6g16897e', - 'deploymentId': '5e5ea5c16897e', - 'trigger': 'http', - 'status': 'processing', - 'requestMethod': 'GET', - 'requestPath': '/articles?id=5', - 'requestHeaders': [], - 'responseStatusCode': 200, - 'responseBody': '', - 'responseHeaders': [], - 'logs': '', - 'errors': '', - 'duration': 0.4,}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await functions.createExecution( - functionId: '', - ); - expect(response, isA()); - - }); - - test('test method getExecution()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'functionId': '5e5ea6g16897e', - 'deploymentId': '5e5ea5c16897e', - 'trigger': 'http', - 'status': 'processing', - 'requestMethod': 'GET', - 'requestPath': '/articles?id=5', - 'requestHeaders': [], - 'responseStatusCode': 200, - 'responseBody': '', - 'responseHeaders': [], - 'logs': '', - 'errors': '', - 'duration': 0.4,}; + group('Functions test', () { + late MockClient client; + late Functions functions; + setUp(() { + client = MockClient(); + functions = Functions(client); + }); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + test('test method listExecutions()', () async { + final Map data = { + 'total': 5, + 'executions': [], + }; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await functions.getExecution( - functionId: '', - executionId: '', - ); - expect(response, isA()); + final response = await functions.listExecutions( + functionId: '', + ); + expect(response, isA()); + }); - }); + test('test method createExecution()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'functionId': '5e5ea6g16897e', + 'deploymentId': '5e5ea5c16897e', + 'trigger': 'http', + 'status': 'processing', + 'requestMethod': 'GET', + 'requestPath': '/articles?id=5', + 'requestHeaders': [], + 'responseStatusCode': 200, + 'responseBody': '', + 'responseHeaders': [], + 'logs': '', + 'errors': '', + 'duration': 0.4, + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await functions.createExecution( + functionId: '', + ); + expect(response, isA()); + }); + test('test method getExecution()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'functionId': '5e5ea6g16897e', + 'deploymentId': '5e5ea5c16897e', + 'trigger': 'http', + 'status': 'processing', + 'requestMethod': 'GET', + 'requestPath': '/articles?id=5', + 'requestHeaders': [], + 'responseStatusCode': 200, + 'responseBody': '', + 'responseHeaders': [], + 'logs': '', + 'errors': '', + 'duration': 0.4, + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await functions.getExecution( + functionId: '', + executionId: '', + ); + expect(response, isA()); }); + }); } diff --git a/test/services/graphql_test.dart b/test/services/graphql_test.dart index c548e414..84b7de1c 100644 --- a/test/services/graphql_test.dart +++ b/test/services/graphql_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,47 +40,45 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Graphql test', () { - late MockClient client; - late Graphql graphql; - - setUp(() { - client = MockClient(); - graphql = Graphql(client); - }); - - test('test method query()', () async { - - final data = ''; + group('Graphql test', () { + late MockClient client; + late Graphql graphql; - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await graphql.query( - query: {}, - ); - }); + setUp(() { + client = MockClient(); + graphql = Graphql(client); + }); - test('test method mutation()', () async { + test('test method query()', () async { + final data = ''; - final data = ''; + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + final response = await graphql.query( + query: {}, + ); + }); + test('test method mutation()', () async { + final data = ''; - final response = await graphql.mutation( - query: {}, - ); - }); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + final response = await graphql.mutation( + query: {}, + ); }); + }); } diff --git a/test/services/locale_test.dart b/test/services/locale_test.dart index 42faaf72..f9f6489d 100644 --- a/test/services/locale_test.dart +++ b/test/services/locale_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,168 +40,138 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Locale test', () { - late MockClient client; - late Locale locale; - - setUp(() { - client = MockClient(); - locale = Locale(client); - }); - - test('test method get()', () async { - - final Map data = { - 'ip': '127.0.0.1', - 'countryCode': 'US', - 'country': 'United States', - 'continentCode': 'NA', - 'continent': 'North America', - 'eu': true, - 'currency': 'USD',}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await locale.get( - ); - expect(response, isA()); - - }); - - test('test method listCodes()', () async { - - final Map data = { - 'total': 5, - 'localeCodes': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await locale.listCodes( - ); - expect(response, isA()); - - }); - - test('test method listContinents()', () async { - - final Map data = { - 'total': 5, - 'continents': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await locale.listContinents( - ); - expect(response, isA()); + group('Locale test', () { + late MockClient client; + late Locale locale; - }); - - test('test method listCountries()', () async { - - final Map data = { - 'total': 5, - 'countries': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await locale.listCountries( - ); - expect(response, isA()); - - }); - - test('test method listCountriesEU()', () async { - - final Map data = { - 'total': 5, - 'countries': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await locale.listCountriesEU( - ); - expect(response, isA()); - - }); + setUp(() { + client = MockClient(); + locale = Locale(client); + }); - test('test method listCountriesPhones()', () async { + test('test method get()', () async { + final Map data = { + 'ip': '127.0.0.1', + 'countryCode': 'US', + 'country': 'United States', + 'continentCode': 'NA', + 'continent': 'North America', + 'eu': true, + 'currency': 'USD', + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await locale.get(); + expect(response, isA()); + }); - final Map data = { - 'total': 5, - 'phones': [],}; + test('test method listCodes()', () async { + final Map data = { + 'total': 5, + 'localeCodes': [], + }; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final response = await locale.listCodes(); + expect(response, isA()); + }); + test('test method listContinents()', () async { + final Map data = { + 'total': 5, + 'continents': [], + }; - final response = await locale.listCountriesPhones( - ); - expect(response, isA()); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await locale.listContinents(); + expect(response, isA()); + }); - test('test method listCurrencies()', () async { + test('test method listCountries()', () async { + final Map data = { + 'total': 5, + 'countries': [], + }; - final Map data = { - 'total': 5, - 'currencies': [],}; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await locale.listCountries(); + expect(response, isA()); + }); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + test('test method listCountriesEU()', () async { + final Map data = { + 'total': 5, + 'countries': [], + }; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await locale.listCurrencies( - ); - expect(response, isA()); + final response = await locale.listCountriesEU(); + expect(response, isA()); + }); - }); + test('test method listCountriesPhones()', () async { + final Map data = { + 'total': 5, + 'phones': [], + }; - test('test method listLanguages()', () async { + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final Map data = { - 'total': 5, - 'languages': [],}; + final response = await locale.listCountriesPhones(); + expect(response, isA()); + }); + test('test method listCurrencies()', () async { + final Map data = { + 'total': 5, + 'currencies': [], + }; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await locale.listCurrencies(); + expect(response, isA()); + }); - final response = await locale.listLanguages( - ); - expect(response, isA()); + test('test method listLanguages()', () async { + final Map data = { + 'total': 5, + 'languages': [], + }; - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await locale.listLanguages(); + expect(response, isA()); }); + }); } diff --git a/test/services/messaging_test.dart b/test/services/messaging_test.dart index 5899ace3..0c938eff 100644 --- a/test/services/messaging_test.dart +++ b/test/services/messaging_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,71 +40,68 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Messaging test', () { - late MockClient client; - late Messaging messaging; - - setUp(() { - client = MockClient(); - messaging = Messaging(client); - }); - - test('test method createSubscriber()', () async { - - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'targetId': '259125845563242502', - 'target': { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'Apple iPhone 12', - 'userId': '259125845563242502', - 'providerType': 'email', - 'identifier': 'token', - 'expired': true, - }, - 'userId': '5e5ea5c16897e', - 'userName': 'Aegon Targaryen', - 'topicId': '259125845563242502', - 'providerType': 'email',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + group('Messaging test', () { + late MockClient client; + late Messaging messaging; + setUp(() { + client = MockClient(); + messaging = Messaging(client); + }); - final response = await messaging.createSubscriber( - topicId: '', - subscriberId: '', - targetId: '', - ); - expect(response, isA()); - - }); - - test('test method deleteSubscriber()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + test('test method createSubscriber()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'targetId': '259125845563242502', + 'target': { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Apple iPhone 12', + 'userId': '259125845563242502', + 'providerType': 'email', + 'identifier': 'token', + 'expired': true, + }, + 'userId': '5e5ea5c16897e', + 'userName': 'Aegon Targaryen', + 'topicId': '259125845563242502', + 'providerType': 'email', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await messaging.createSubscriber( + topicId: '', + subscriberId: '', + targetId: '', + ); + expect(response, isA()); + }); + test('test method deleteSubscriber()', () async { + final data = ''; - final response = await messaging.deleteSubscriber( - topicId: '', - subscriberId: '', - ); - }); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + final response = await messaging.deleteSubscriber( + topicId: '', + subscriberId: '', + ); }); + }); } diff --git a/test/services/presences_test.dart b/test/services/presences_test.dart index 7b99675f..7fed0439 100644 --- a/test/services/presences_test.dart +++ b/test/services/presences_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,121 +40,108 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Presences test', () { - late MockClient client; - late Presences presences; - - setUp(() { - client = MockClient(); - presences = Presences(client); - }); - - test('test method list()', () async { - - final Map data = { - 'total': 5, - 'presences': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await presences.list( - ); - expect(response, isA()); - - }); - - test('test method get()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'userId': '674af8f3e12a5f9ac0be', - 'source': 'HTTP',}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await presences.get( - presenceId: '', - ); - expect(response, isA()); - - }); + group('Presences test', () { + late MockClient client; + late Presences presences; - test('test method upsert()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'userId': '674af8f3e12a5f9ac0be', - 'source': 'HTTP',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await presences.upsert( - presenceId: '', - status: '', - ); - expect(response, isA()); - - }); - - test('test method update()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'userId': '674af8f3e12a5f9ac0be', - 'source': 'HTTP',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + setUp(() { + client = MockClient(); + presences = Presences(client); + }); + test('test method list()', () async { + final Map data = { + 'total': 5, + 'presences': [], + }; - final response = await presences.update( - presenceId: '', - ); - expect(response, isA()); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await presences.list(); + expect(response, isA()); + }); - test('test method delete()', () async { + test('test method get()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'userId': '674af8f3e12a5f9ac0be', + 'source': 'HTTP', + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await presences.get( + presenceId: '', + ); + expect(response, isA()); + }); - final data = ''; + test('test method upsert()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'userId': '674af8f3e12a5f9ac0be', + 'source': 'HTTP', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await presences.upsert( + presenceId: '', + status: '', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + test('test method update()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'userId': '674af8f3e12a5f9ac0be', + 'source': 'HTTP', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await presences.update( + presenceId: '', + ); + expect(response, isA()); + }); + test('test method delete()', () async { + final data = ''; - final response = await presences.delete( - presenceId: '', - ); - }); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + final response = await presences.delete( + presenceId: '', + ); }); + }); } diff --git a/test/services/storage_test.dart b/test/services/storage_test.dart index 2390bfdd..55a42f94 100644 --- a/test/services/storage_test.dart +++ b/test/services/storage_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,202 +40,184 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Storage test', () { - late MockClient client; - late Storage storage; - - setUp(() { - client = MockClient(); - storage = Storage(client); - }); - - test('test method listFiles()', () async { - - final Map data = { - 'total': 5, - 'files': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await storage.listFiles( - bucketId: '', - ); - expect(response, isA()); - - }); - - test('test method createFile()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - 'bucketId': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'name': 'Pink.png', - 'signature': '5d529fd02b544198ae075bd57c1762bb', - 'mimeType': 'image/png', - 'sizeOriginal': 17890, - 'sizeActual': 12345, - 'chunksTotal': 17890, - 'chunksUploaded': 17890, - 'encryption': true, - 'compression': 'gzip',}; - - - when(client.chunkedUpload( - path: argThat(isNotNull), - params: argThat(isNotNull), - paramName: argThat(isNotNull), - idParamName: argThat(isNotNull), - headers: argThat(isNotNull), - )).thenAnswer((_) async => Response(data: data)); - - - final response = await storage.createFile( - bucketId: '', - fileId: '', - file: InputFile.fromPath(path: './image.png'), - ); - expect(response, isA()); - - }); - - test('test method getFile()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - 'bucketId': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'name': 'Pink.png', - 'signature': '5d529fd02b544198ae075bd57c1762bb', - 'mimeType': 'image/png', - 'sizeOriginal': 17890, - 'sizeActual': 12345, - 'chunksTotal': 17890, - 'chunksUploaded': 17890, - 'encryption': true, - 'compression': 'gzip',}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await storage.getFile( - bucketId: '', - fileId: '', - ); - expect(response, isA()); - - }); - - test('test method updateFile()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - 'bucketId': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'name': 'Pink.png', - 'signature': '5d529fd02b544198ae075bd57c1762bb', - 'mimeType': 'image/png', - 'sizeOriginal': 17890, - 'sizeActual': 12345, - 'chunksTotal': 17890, - 'chunksUploaded': 17890, - 'encryption': true, - 'compression': 'gzip',}; - + group('Storage test', () { + late MockClient client; + late Storage storage; - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await storage.updateFile( - bucketId: '', - fileId: '', - ); - expect(response, isA()); - - }); - - test('test method deleteFile()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + setUp(() { + client = MockClient(); + storage = Storage(client); + }); + test('test method listFiles()', () async { + final Map data = { + 'total': 5, + 'files': [], + }; - final response = await storage.deleteFile( - bucketId: '', - fileId: '', - ); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method getFileDownload()', () async { -final Uint8List data = Uint8List.fromList([]); + final response = await storage.listFiles( + bucketId: '', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + test('test method createFile()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + 'bucketId': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'name': 'Pink.png', + 'signature': '5d529fd02b544198ae075bd57c1762bb', + 'mimeType': 'image/png', + 'sizeOriginal': 17890, + 'sizeActual': 12345, + 'chunksTotal': 17890, + 'chunksUploaded': 17890, + 'encryption': true, + 'compression': 'gzip', + }; + + when(client.chunkedUpload( + path: argThat(isNotNull), + params: argThat(isNotNull), + paramName: argThat(isNotNull), + idParamName: argThat(isNotNull), + headers: argThat(isNotNull), + )).thenAnswer((_) async => Response(data: data)); + + final response = await storage.createFile( + bucketId: '', + fileId: '', + file: InputFile.fromPath(path: './image.png'), + ); + expect(response, isA()); + }); + test('test method getFile()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + 'bucketId': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'name': 'Pink.png', + 'signature': '5d529fd02b544198ae075bd57c1762bb', + 'mimeType': 'image/png', + 'sizeOriginal': 17890, + 'sizeActual': 12345, + 'chunksTotal': 17890, + 'chunksUploaded': 17890, + 'encryption': true, + 'compression': 'gzip', + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await storage.getFile( + bucketId: '', + fileId: '', + ); + expect(response, isA()); + }); - final response = await storage.getFileDownload( - bucketId: '', - fileId: '', - ); - expect(response, isA()); + test('test method updateFile()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + 'bucketId': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'name': 'Pink.png', + 'signature': '5d529fd02b544198ae075bd57c1762bb', + 'mimeType': 'image/png', + 'sizeOriginal': 17890, + 'sizeActual': 12345, + 'chunksTotal': 17890, + 'chunksUploaded': 17890, + 'encryption': true, + 'compression': 'gzip', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await storage.updateFile( + bucketId: '', + fileId: '', + ); + expect(response, isA()); + }); - }); + test('test method deleteFile()', () async { + final data = ''; - test('test method getFilePreview()', () async { -final Uint8List data = Uint8List.fromList([]); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final response = await storage.deleteFile( + bucketId: '', + fileId: '', + ); + }); + test('test method getFileDownload()', () async { + final Uint8List data = Uint8List.fromList([]); - final response = await storage.getFilePreview( - bucketId: '', - fileId: '', - ); - expect(response, isA()); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await storage.getFileDownload( + bucketId: '', + fileId: '', + ); + expect(response, isA()); + }); - test('test method getFileView()', () async { -final Uint8List data = Uint8List.fromList([]); + test('test method getFilePreview()', () async { + final Uint8List data = Uint8List.fromList([]); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await storage.getFilePreview( + bucketId: '', + fileId: '', + ); + expect(response, isA()); + }); - final response = await storage.getFileView( - bucketId: '', - fileId: '', - ); - expect(response, isA()); + test('test method getFileView()', () async { + final Uint8List data = Uint8List.fromList([]); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await storage.getFileView( + bucketId: '', + fileId: '', + ); + expect(response, isA()); }); + }); } diff --git a/test/services/tables_db_test.dart b/test/services/tables_db_test.dart index 5219d2bf..f318cad2 100644 --- a/test/services/tables_db_test.dart +++ b/test/services/tables_db_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,337 +40,297 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('TablesDB test', () { - late MockClient client; - late TablesDB tablesDB; - - setUp(() { - client = MockClient(); - tablesDB = TablesDB(client); - }); - - test('test method listTransactions()', () async { - - final Map data = { - 'total': 5, - 'transactions': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.listTransactions( - ); - expect(response, isA()); - - }); - - test('test method createTransaction()', () async { - - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.createTransaction( - ); - expect(response, isA()); - - }); - - test('test method getTransaction()', () async { - - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.getTransaction( - transactionId: '', - ); - expect(response, isA()); - - }); - - test('test method updateTransaction()', () async { - - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.updateTransaction( - transactionId: '', - ); - expect(response, isA()); - - }); - - test('test method deleteTransaction()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.deleteTransaction( - transactionId: '', - ); - }); - - test('test method createOperations()', () async { - - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.createOperations( - transactionId: '', - ); - expect(response, isA()); - - }); - - test('test method listRows()', () async { - - final Map data = { - 'total': 5, - 'rows': [],}; - + group('TablesDB test', () { + late MockClient client; + late TablesDB tablesDB; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.listRows( - databaseId: '', - tableId: '', - ); - expect(response, isA()); - - }); - - test('test method createRow()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.createRow( - databaseId: '', - tableId: '', - rowId: '', - data: {}, - ); - expect(response, isA()); - - }); - - test('test method getRow()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.getRow( - databaseId: '', - tableId: '', - rowId: '', - ); - expect(response, isA()); - - }); - - test('test method upsertRow()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.upsertRow( - databaseId: '', - tableId: '', - rowId: '', - ); - expect(response, isA()); - - }); - - test('test method updateRow()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.updateRow( - databaseId: '', - tableId: '', - rowId: '', - ); - expect(response, isA()); - - }); + setUp(() { + client = MockClient(); + tablesDB = TablesDB(client); + }); - test('test method deleteRow()', () async { + test('test method listTransactions()', () async { + final Map data = { + 'total': 5, + 'transactions': [], + }; - final data = ''; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + final response = await tablesDB.listTransactions(); + expect(response, isA()); + }); + test('test method createTransaction()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.createTransaction(); + expect(response, isA()); + }); - final response = await tablesDB.deleteRow( - databaseId: '', - tableId: '', - rowId: '', - ); - }); + test('test method getTransaction()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.getTransaction( + transactionId: '', + ); + expect(response, isA()); + }); - test('test method decrementRowColumn()', () async { + test('test method updateTransaction()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.updateTransaction( + transactionId: '', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; + test('test method deleteTransaction()', () async { + final data = ''; + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + final response = await tablesDB.deleteTransaction( + transactionId: '', + ); + }); + test('test method createOperations()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.createOperations( + transactionId: '', + ); + expect(response, isA()); + }); - final response = await tablesDB.decrementRowColumn( - databaseId: '', - tableId: '', - rowId: '', - column: '', - ); - expect(response, isA()); + test('test method listRows()', () async { + final Map data = { + 'total': 5, + 'rows': [], + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.listRows( + databaseId: '', + tableId: '', + ); + expect(response, isA()); + }); - }); + test('test method createRow()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.createRow( + databaseId: '', + tableId: '', + rowId: '', + data: {}, + ); + expect(response, isA()); + }); - test('test method incrementRowColumn()', () async { + test('test method getRow()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.getRow( + databaseId: '', + tableId: '', + rowId: '', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; + test('test method upsertRow()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.upsertRow( + databaseId: '', + tableId: '', + rowId: '', + ); + expect(response, isA()); + }); + test('test method updateRow()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.updateRow( + databaseId: '', + tableId: '', + rowId: '', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + test('test method deleteRow()', () async { + final data = ''; + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - final response = await tablesDB.incrementRowColumn( - databaseId: '', - tableId: '', - rowId: '', - column: '', - ); - expect(response, isA()); + final response = await tablesDB.deleteRow( + databaseId: '', + tableId: '', + rowId: '', + ); + }); - }); + test('test method decrementRowColumn()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.decrementRowColumn( + databaseId: '', + tableId: '', + rowId: '', + column: '', + ); + expect(response, isA()); + }); + test('test method incrementRowColumn()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.incrementRowColumn( + databaseId: '', + tableId: '', + rowId: '', + column: '', + ); + expect(response, isA()); }); + }); } diff --git a/test/services/teams_test.dart b/test/services/teams_test.dart index ea72a432..83f2667b 100644 --- a/test/services/teams_test.dart +++ b/test/services/teams_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,326 +40,288 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Teams test', () { - late MockClient client; - late Teams teams; - - setUp(() { - client = MockClient(); - teams = Teams(client); - }); - - test('test method list()', () async { - - final Map data = { - 'total': 5, - 'teams': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.list( - ); - expect(response, isA()); - - }); - - test('test method create()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'VIP', - 'total': 7, - 'prefs': {},}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.create( - teamId: '', - name: '', - ); - expect(response, isA()); - - }); - - test('test method get()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'VIP', - 'total': 7, - 'prefs': {},}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.get( - teamId: '', - ); - expect(response, isA()); - - }); - - test('test method updateName()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'VIP', - 'total': 7, - 'prefs': {},}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.updateName( - teamId: '', - name: '', - ); - expect(response, isA()); - - }); - - test('test method delete()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.delete( - teamId: '', - ); - }); - - test('test method listMemberships()', () async { - - final Map data = { - 'total': 5, - 'memberships': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + group('Teams test', () { + late MockClient client; + late Teams teams; + setUp(() { + client = MockClient(); + teams = Teams(client); + }); - final response = await teams.listMemberships( - teamId: '', - ); - expect(response, isA()); - - }); - - test('test method createMembership()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [],}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.createMembership( - teamId: '', - roles: [], - ); - expect(response, isA()); - - }); - - test('test method getMembership()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.getMembership( - teamId: '', - membershipId: '', - ); - expect(response, isA()); - - }); - - test('test method updateMembership()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [],}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.updateMembership( - teamId: '', - membershipId: '', - roles: [], - ); - expect(response, isA()); - - }); - - test('test method deleteMembership()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + test('test method list()', () async { + final Map data = { + 'total': 5, + 'teams': [], + }; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await teams.deleteMembership( - teamId: '', - membershipId: '', - ); - }); + final response = await teams.list(); + expect(response, isA()); + }); - test('test method updateMembershipStatus()', () async { + test('test method create()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'VIP', + 'total': 7, + 'prefs': {}, + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await teams.create( + teamId: '', + name: '', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [],}; + test('test method get()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'VIP', + 'total': 7, + 'prefs': {}, + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await teams.get( + teamId: '', + ); + expect(response, isA()); + }); + test('test method updateName()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'VIP', + 'total': 7, + 'prefs': {}, + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await teams.updateName( + teamId: '', + name: '', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + test('test method delete()', () async { + final data = ''; + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - final response = await teams.updateMembershipStatus( - teamId: '', - membershipId: '', - userId: '', - secret: '', - ); - expect(response, isA()); + final response = await teams.delete( + teamId: '', + ); + }); - }); + test('test method listMemberships()', () async { + final Map data = { + 'total': 5, + 'memberships': [], + }; - test('test method getPrefs()', () async { + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final Map data = {}; + final response = await teams.listMemberships( + teamId: '', + ); + expect(response, isA()); + }); + test('test method createMembership()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'userPhone': '+1 555 555 5555', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'roles': [], + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await teams.createMembership( + teamId: '', + roles: [], + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + test('test method getMembership()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'userPhone': '+1 555 555 5555', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'roles': [], + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await teams.getMembership( + teamId: '', + membershipId: '', + ); + expect(response, isA()); + }); + test('test method updateMembership()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'userPhone': '+1 555 555 5555', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'roles': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await teams.updateMembership( + teamId: '', + membershipId: '', + roles: [], + ); + expect(response, isA()); + }); - final response = await teams.getPrefs( - teamId: '', - ); - expect(response, isA()); + test('test method deleteMembership()', () async { + final data = ''; - }); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - test('test method updatePrefs()', () async { + final response = await teams.deleteMembership( + teamId: '', + membershipId: '', + ); + }); - final Map data = {}; + test('test method updateMembershipStatus()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'userPhone': '+1 555 555 5555', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'roles': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await teams.updateMembershipStatus( + teamId: '', + membershipId: '', + userId: '', + secret: '', + ); + expect(response, isA()); + }); + test('test method getPrefs()', () async { + final Map data = {}; - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await teams.getPrefs( + teamId: '', + ); + expect(response, isA()); + }); - final response = await teams.updatePrefs( - teamId: '', - prefs: {}, - ); - expect(response, isA()); + test('test method updatePrefs()', () async { + final Map data = {}; - }); + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + final response = await teams.updatePrefs( + teamId: '', + prefs: {}, + ); + expect(response, isA()); }); + }); } diff --git a/test/src/models/algo_argon2_test.dart b/test/src/models/algo_argon2_test.dart index 15e85f5a..261daa46 100644 --- a/test/src/models/algo_argon2_test.dart +++ b/test/src/models/algo_argon2_test.dart @@ -14,10 +14,10 @@ void main() { final map = model.toMap(); final result = AlgoArgon2.fromMap(map); - expect(result.type, 'argon2'); - expect(result.memoryCost, 65536); - expect(result.timeCost, 4); - expect(result.threads, 3); - }); + expect(result.type, 'argon2'); + expect(result.memoryCost, 65536); + expect(result.timeCost, 4); + expect(result.threads, 3); + }); }); } diff --git a/test/src/models/algo_bcrypt_test.dart b/test/src/models/algo_bcrypt_test.dart index 87a3ca3c..3da36624 100644 --- a/test/src/models/algo_bcrypt_test.dart +++ b/test/src/models/algo_bcrypt_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = AlgoBcrypt.fromMap(map); - expect(result.type, 'bcrypt'); - }); + expect(result.type, 'bcrypt'); + }); }); } diff --git a/test/src/models/algo_md5_test.dart b/test/src/models/algo_md5_test.dart index 3b842e6c..e58fa5b5 100644 --- a/test/src/models/algo_md5_test.dart +++ b/test/src/models/algo_md5_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = AlgoMd5.fromMap(map); - expect(result.type, 'md5'); - }); + expect(result.type, 'md5'); + }); }); } diff --git a/test/src/models/algo_phpass_test.dart b/test/src/models/algo_phpass_test.dart index 49b1e22c..3bcbb488 100644 --- a/test/src/models/algo_phpass_test.dart +++ b/test/src/models/algo_phpass_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = AlgoPhpass.fromMap(map); - expect(result.type, 'phpass'); - }); + expect(result.type, 'phpass'); + }); }); } diff --git a/test/src/models/algo_scrypt_modified_test.dart b/test/src/models/algo_scrypt_modified_test.dart index dd7fa8c3..b2084927 100644 --- a/test/src/models/algo_scrypt_modified_test.dart +++ b/test/src/models/algo_scrypt_modified_test.dart @@ -8,16 +8,18 @@ void main() { type: 'scryptMod', salt: 'UxLMreBr6tYyjQ==', saltSeparator: 'Bw==', - signerKey: 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ==', + signerKey: + 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ==', ); final map = model.toMap(); final result = AlgoScryptModified.fromMap(map); - expect(result.type, 'scryptMod'); - expect(result.salt, 'UxLMreBr6tYyjQ=='); - expect(result.saltSeparator, 'Bw=='); - expect(result.signerKey, 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ=='); - }); + expect(result.type, 'scryptMod'); + expect(result.salt, 'UxLMreBr6tYyjQ=='); + expect(result.saltSeparator, 'Bw=='); + expect(result.signerKey, + 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ=='); + }); }); } diff --git a/test/src/models/algo_scrypt_test.dart b/test/src/models/algo_scrypt_test.dart index c7d9cdbf..8c131568 100644 --- a/test/src/models/algo_scrypt_test.dart +++ b/test/src/models/algo_scrypt_test.dart @@ -15,11 +15,11 @@ void main() { final map = model.toMap(); final result = AlgoScrypt.fromMap(map); - expect(result.type, 'scrypt'); - expect(result.costCpu, 8); - expect(result.costMemory, 14); - expect(result.costParallel, 1); - expect(result.length, 64); - }); + expect(result.type, 'scrypt'); + expect(result.costCpu, 8); + expect(result.costMemory, 14); + expect(result.costParallel, 1); + expect(result.length, 64); + }); }); } diff --git a/test/src/models/algo_sha_test.dart b/test/src/models/algo_sha_test.dart index ae58b57e..d080569c 100644 --- a/test/src/models/algo_sha_test.dart +++ b/test/src/models/algo_sha_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = AlgoSha.fromMap(map); - expect(result.type, 'sha'); - }); + expect(result.type, 'sha'); + }); }); } diff --git a/test/src/models/continent_list_test.dart b/test/src/models/continent_list_test.dart index 8de695b0..e71dcae1 100644 --- a/test/src/models/continent_list_test.dart +++ b/test/src/models/continent_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = ContinentList.fromMap(map); - expect(result.total, 5); - expect(result.continents, []); - }); + expect(result.total, 5); + expect(result.continents, []); + }); }); } diff --git a/test/src/models/continent_test.dart b/test/src/models/continent_test.dart index d5242a4e..85e559f5 100644 --- a/test/src/models/continent_test.dart +++ b/test/src/models/continent_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = Continent.fromMap(map); - expect(result.name, 'Europe'); - expect(result.code, 'EU'); - }); + expect(result.name, 'Europe'); + expect(result.code, 'EU'); + }); }); } diff --git a/test/src/models/country_list_test.dart b/test/src/models/country_list_test.dart index 869f5db6..6df5c584 100644 --- a/test/src/models/country_list_test.dart +++ b/test/src/models/country_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = CountryList.fromMap(map); - expect(result.total, 5); - expect(result.countries, []); - }); + expect(result.total, 5); + expect(result.countries, []); + }); }); } diff --git a/test/src/models/country_test.dart b/test/src/models/country_test.dart index bc66ab7b..d5404a7f 100644 --- a/test/src/models/country_test.dart +++ b/test/src/models/country_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = Country.fromMap(map); - expect(result.name, 'United States'); - expect(result.code, 'US'); - }); + expect(result.name, 'United States'); + expect(result.code, 'US'); + }); }); } diff --git a/test/src/models/currency_list_test.dart b/test/src/models/currency_list_test.dart index 09da675c..d7410db8 100644 --- a/test/src/models/currency_list_test.dart +++ b/test/src/models/currency_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = CurrencyList.fromMap(map); - expect(result.total, 5); - expect(result.currencies, []); - }); + expect(result.total, 5); + expect(result.currencies, []); + }); }); } diff --git a/test/src/models/currency_test.dart b/test/src/models/currency_test.dart index 29890008..00e046c7 100644 --- a/test/src/models/currency_test.dart +++ b/test/src/models/currency_test.dart @@ -17,13 +17,13 @@ void main() { final map = model.toMap(); final result = Currency.fromMap(map); - expect(result.symbol, '\$'); - expect(result.name, 'US dollar'); - expect(result.symbolNative, '\$'); - expect(result.decimalDigits, 2); - expect(result.rounding, 0); - expect(result.code, 'USD'); - expect(result.namePlural, 'US dollars'); - }); + expect(result.symbol, '\$'); + expect(result.name, 'US dollar'); + expect(result.symbolNative, '\$'); + expect(result.decimalDigits, 2); + expect(result.rounding, 0); + expect(result.code, 'USD'); + expect(result.namePlural, 'US dollars'); + }); }); } diff --git a/test/src/models/document_list_test.dart b/test/src/models/document_list_test.dart index f1a5b3cc..217d37e8 100644 --- a/test/src/models/document_list_test.dart +++ b/test/src/models/document_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = DocumentList.fromMap(map); - expect(result.total, 5); - expect(result.documents, []); - }); + expect(result.total, 5); + expect(result.documents, []); + }); }); } diff --git a/test/src/models/document_test.dart b/test/src/models/document_test.dart index 6c1fbb77..397b5fab 100644 --- a/test/src/models/document_test.dart +++ b/test/src/models/document_test.dart @@ -18,13 +18,13 @@ void main() { final map = model.toMap(); final result = Document.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$sequence, '1'); - expect(result.$collectionId, '5e5ea5c15117e'); - expect(result.$databaseId, '5e5ea5c15117e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$sequence, '1'); + expect(result.$collectionId, '5e5ea5c15117e'); + expect(result.$databaseId, '5e5ea5c15117e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + }); }); } diff --git a/test/src/models/execution_list_test.dart b/test/src/models/execution_list_test.dart index fe74af58..a3305e55 100644 --- a/test/src/models/execution_list_test.dart +++ b/test/src/models/execution_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = ExecutionList.fromMap(map); - expect(result.total, 5); - expect(result.executions, []); - }); + expect(result.total, 5); + expect(result.executions, []); + }); }); } diff --git a/test/src/models/execution_test.dart b/test/src/models/execution_test.dart index 6d9bf33c..80ef508a 100644 --- a/test/src/models/execution_test.dart +++ b/test/src/models/execution_test.dart @@ -28,23 +28,23 @@ void main() { final map = model.toMap(); final result = Execution.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - expect(result.functionId, '5e5ea6g16897e'); - expect(result.deploymentId, '5e5ea5c16897e'); - expect(result.trigger, ExecutionTrigger.http); - expect(result.status, ExecutionStatus.waiting); - expect(result.requestMethod, 'GET'); - expect(result.requestPath, '/articles?id=5'); - expect(result.requestHeaders, []); - expect(result.responseStatusCode, 200); - expect(result.responseBody, ''); - expect(result.responseHeaders, []); - expect(result.logs, ''); - expect(result.errors, ''); - expect(result.duration, 0.4); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + expect(result.functionId, '5e5ea6g16897e'); + expect(result.deploymentId, '5e5ea5c16897e'); + expect(result.trigger, ExecutionTrigger.http); + expect(result.status, ExecutionStatus.waiting); + expect(result.requestMethod, 'GET'); + expect(result.requestPath, '/articles?id=5'); + expect(result.requestHeaders, []); + expect(result.responseStatusCode, 200); + expect(result.responseBody, ''); + expect(result.responseHeaders, []); + expect(result.logs, ''); + expect(result.errors, ''); + expect(result.duration, 0.4); + }); }); } diff --git a/test/src/models/file_list_test.dart b/test/src/models/file_list_test.dart index d8e6c95c..8e02f65e 100644 --- a/test/src/models/file_list_test.dart +++ b/test/src/models/file_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = FileList.fromMap(map); - expect(result.total, 5); - expect(result.files, []); - }); + expect(result.total, 5); + expect(result.files, []); + }); }); } diff --git a/test/src/models/file_test.dart b/test/src/models/file_test.dart index 8a734a08..7f132646 100644 --- a/test/src/models/file_test.dart +++ b/test/src/models/file_test.dart @@ -24,20 +24,20 @@ void main() { final map = model.toMap(); final result = File.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.bucketId, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - expect(result.name, 'Pink.png'); - expect(result.signature, '5d529fd02b544198ae075bd57c1762bb'); - expect(result.mimeType, 'image/png'); - expect(result.sizeOriginal, 17890); - expect(result.sizeActual, 12345); - expect(result.chunksTotal, 17890); - expect(result.chunksUploaded, 17890); - expect(result.encryption, true); - expect(result.compression, 'gzip'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.bucketId, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + expect(result.name, 'Pink.png'); + expect(result.signature, '5d529fd02b544198ae075bd57c1762bb'); + expect(result.mimeType, 'image/png'); + expect(result.sizeOriginal, 17890); + expect(result.sizeActual, 12345); + expect(result.chunksTotal, 17890); + expect(result.chunksUploaded, 17890); + expect(result.encryption, true); + expect(result.compression, 'gzip'); + }); }); } diff --git a/test/src/models/headers_test.dart b/test/src/models/headers_test.dart index 489891d4..9252b469 100644 --- a/test/src/models/headers_test.dart +++ b/test/src/models/headers_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = Headers.fromMap(map); - expect(result.name, 'Content-Type'); - expect(result.value, 'application/json'); - }); + expect(result.name, 'Content-Type'); + expect(result.value, 'application/json'); + }); }); } diff --git a/test/src/models/identity_list_test.dart b/test/src/models/identity_list_test.dart index 65f562a7..8c35afec 100644 --- a/test/src/models/identity_list_test.dart +++ b/test/src/models/identity_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = IdentityList.fromMap(map); - expect(result.total, 5); - expect(result.identities, []); - }); + expect(result.total, 5); + expect(result.identities, []); + }); }); } diff --git a/test/src/models/identity_test.dart b/test/src/models/identity_test.dart index 708c8c60..525af4ea 100644 --- a/test/src/models/identity_test.dart +++ b/test/src/models/identity_test.dart @@ -20,16 +20,16 @@ void main() { final map = model.toMap(); final result = Identity.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5bb8c16897e'); - expect(result.provider, 'email'); - expect(result.providerUid, '5e5bb8c16897e'); - expect(result.providerEmail, 'user@example.com'); - expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); - expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5bb8c16897e'); + expect(result.provider, 'email'); + expect(result.providerUid, '5e5bb8c16897e'); + expect(result.providerEmail, 'user@example.com'); + expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); + expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + }); }); } diff --git a/test/src/models/jwt_test.dart b/test/src/models/jwt_test.dart index e616a956..93376af1 100644 --- a/test/src/models/jwt_test.dart +++ b/test/src/models/jwt_test.dart @@ -5,13 +5,15 @@ void main() { group('Jwt', () { test('model', () { final model = Jwt( - jwt: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', + jwt: + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', ); final map = model.toMap(); final result = Jwt.fromMap(map); - expect(result.jwt, 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'); - }); + expect(result.jwt, + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'); + }); }); } diff --git a/test/src/models/language_list_test.dart b/test/src/models/language_list_test.dart index 94c1e33f..a07c0b5f 100644 --- a/test/src/models/language_list_test.dart +++ b/test/src/models/language_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = LanguageList.fromMap(map); - expect(result.total, 5); - expect(result.languages, []); - }); + expect(result.total, 5); + expect(result.languages, []); + }); }); } diff --git a/test/src/models/language_test.dart b/test/src/models/language_test.dart index d4087d5e..4a6c96c1 100644 --- a/test/src/models/language_test.dart +++ b/test/src/models/language_test.dart @@ -13,9 +13,9 @@ void main() { final map = model.toMap(); final result = Language.fromMap(map); - expect(result.name, 'Italian'); - expect(result.code, 'it'); - expect(result.nativeName, 'Italiano'); - }); + expect(result.name, 'Italian'); + expect(result.code, 'it'); + expect(result.nativeName, 'Italiano'); + }); }); } diff --git a/test/src/models/locale_code_list_test.dart b/test/src/models/locale_code_list_test.dart index b6de5137..65b44ad1 100644 --- a/test/src/models/locale_code_list_test.dart +++ b/test/src/models/locale_code_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = LocaleCodeList.fromMap(map); - expect(result.total, 5); - expect(result.localeCodes, []); - }); + expect(result.total, 5); + expect(result.localeCodes, []); + }); }); } diff --git a/test/src/models/locale_code_test.dart b/test/src/models/locale_code_test.dart index f0fcdbce..88cf157b 100644 --- a/test/src/models/locale_code_test.dart +++ b/test/src/models/locale_code_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = LocaleCode.fromMap(map); - expect(result.code, 'en-us'); - expect(result.name, 'US'); - }); + expect(result.code, 'en-us'); + expect(result.name, 'US'); + }); }); } diff --git a/test/src/models/locale_test.dart b/test/src/models/locale_test.dart index 72102045..49cb1fc9 100644 --- a/test/src/models/locale_test.dart +++ b/test/src/models/locale_test.dart @@ -17,13 +17,13 @@ void main() { final map = model.toMap(); final result = Locale.fromMap(map); - expect(result.ip, '127.0.0.1'); - expect(result.countryCode, 'US'); - expect(result.country, 'United States'); - expect(result.continentCode, 'NA'); - expect(result.continent, 'North America'); - expect(result.eu, true); - expect(result.currency, 'USD'); - }); + expect(result.ip, '127.0.0.1'); + expect(result.countryCode, 'US'); + expect(result.country, 'United States'); + expect(result.continentCode, 'NA'); + expect(result.continent, 'North America'); + expect(result.eu, true); + expect(result.currency, 'USD'); + }); }); } diff --git a/test/src/models/log_list_test.dart b/test/src/models/log_list_test.dart index 84c560c8..b07ca8ee 100644 --- a/test/src/models/log_list_test.dart +++ b/test/src/models/log_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = LogList.fromMap(map); - expect(result.total, 5); - expect(result.logs, []); - }); + expect(result.total, 5); + expect(result.logs, []); + }); }); } diff --git a/test/src/models/log_test.dart b/test/src/models/log_test.dart index 1b463633..c8211d3b 100644 --- a/test/src/models/log_test.dart +++ b/test/src/models/log_test.dart @@ -32,28 +32,28 @@ void main() { final map = model.toMap(); final result = Log.fromMap(map); - expect(result.event, 'account.sessions.create'); - expect(result.userId, '610fc2f985ee0'); - expect(result.userEmail, 'john@appwrite.io'); - expect(result.userName, 'John Doe'); - expect(result.mode, 'admin'); - expect(result.userType, 'user'); - expect(result.ip, '127.0.0.1'); - expect(result.time, '2020-10-15T06:38:00.000+00:00'); - expect(result.osCode, 'Mac'); - expect(result.osName, 'Mac'); - expect(result.osVersion, 'Mac'); - expect(result.clientType, 'browser'); - expect(result.clientCode, 'CM'); - expect(result.clientName, 'Chrome Mobile iOS'); - expect(result.clientVersion, '84.0'); - expect(result.clientEngine, 'WebKit'); - expect(result.clientEngineVersion, '605.1.15'); - expect(result.deviceName, 'smartphone'); - expect(result.deviceBrand, 'Google'); - expect(result.deviceModel, 'Nexus 5'); - expect(result.countryCode, 'US'); - expect(result.countryName, 'United States'); - }); + expect(result.event, 'account.sessions.create'); + expect(result.userId, '610fc2f985ee0'); + expect(result.userEmail, 'john@appwrite.io'); + expect(result.userName, 'John Doe'); + expect(result.mode, 'admin'); + expect(result.userType, 'user'); + expect(result.ip, '127.0.0.1'); + expect(result.time, '2020-10-15T06:38:00.000+00:00'); + expect(result.osCode, 'Mac'); + expect(result.osName, 'Mac'); + expect(result.osVersion, 'Mac'); + expect(result.clientType, 'browser'); + expect(result.clientCode, 'CM'); + expect(result.clientName, 'Chrome Mobile iOS'); + expect(result.clientVersion, '84.0'); + expect(result.clientEngine, 'WebKit'); + expect(result.clientEngineVersion, '605.1.15'); + expect(result.deviceName, 'smartphone'); + expect(result.deviceBrand, 'Google'); + expect(result.deviceModel, 'Nexus 5'); + expect(result.countryCode, 'US'); + expect(result.countryName, 'United States'); + }); }); } diff --git a/test/src/models/membership_list_test.dart b/test/src/models/membership_list_test.dart index bb1f0946..4f30c48e 100644 --- a/test/src/models/membership_list_test.dart +++ b/test/src/models/membership_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = MembershipList.fromMap(map); - expect(result.total, 5); - expect(result.memberships, []); - }); + expect(result.total, 5); + expect(result.memberships, []); + }); }); } diff --git a/test/src/models/membership_test.dart b/test/src/models/membership_test.dart index ab136c24..b2b8bd3d 100644 --- a/test/src/models/membership_test.dart +++ b/test/src/models/membership_test.dart @@ -25,21 +25,21 @@ void main() { final map = model.toMap(); final result = Membership.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5ea5c16897e'); - expect(result.userName, 'John Doe'); - expect(result.userEmail, 'john@appwrite.io'); - expect(result.userPhone, '+1 555 555 5555'); - expect(result.teamId, '5e5ea5c16897e'); - expect(result.teamName, 'VIP'); - expect(result.invited, '2020-10-15T06:38:00.000+00:00'); - expect(result.joined, '2020-10-15T06:38:00.000+00:00'); - expect(result.confirm, true); - expect(result.mfa, true); - expect(result.userAccessedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.roles, []); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5ea5c16897e'); + expect(result.userName, 'John Doe'); + expect(result.userEmail, 'john@appwrite.io'); + expect(result.userPhone, '+1 555 555 5555'); + expect(result.teamId, '5e5ea5c16897e'); + expect(result.teamName, 'VIP'); + expect(result.invited, '2020-10-15T06:38:00.000+00:00'); + expect(result.joined, '2020-10-15T06:38:00.000+00:00'); + expect(result.confirm, true); + expect(result.mfa, true); + expect(result.userAccessedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.roles, []); + }); }); } diff --git a/test/src/models/mfa_challenge_test.dart b/test/src/models/mfa_challenge_test.dart index 9410baa3..5d3febca 100644 --- a/test/src/models/mfa_challenge_test.dart +++ b/test/src/models/mfa_challenge_test.dart @@ -14,10 +14,10 @@ void main() { final map = model.toMap(); final result = MfaChallenge.fromMap(map); - expect(result.$id, 'bb8ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5ea5c168bb8'); - expect(result.expire, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, 'bb8ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5ea5c168bb8'); + expect(result.expire, '2020-10-15T06:38:00.000+00:00'); + }); }); } diff --git a/test/src/models/mfa_factors_test.dart b/test/src/models/mfa_factors_test.dart index ed6467d3..64cc55e4 100644 --- a/test/src/models/mfa_factors_test.dart +++ b/test/src/models/mfa_factors_test.dart @@ -14,10 +14,10 @@ void main() { final map = model.toMap(); final result = MfaFactors.fromMap(map); - expect(result.totp, true); - expect(result.phone, true); - expect(result.email, true); - expect(result.recoveryCode, true); - }); + expect(result.totp, true); + expect(result.phone, true); + expect(result.email, true); + expect(result.recoveryCode, true); + }); }); } diff --git a/test/src/models/mfa_recovery_codes_test.dart b/test/src/models/mfa_recovery_codes_test.dart index fa097a49..500913c8 100644 --- a/test/src/models/mfa_recovery_codes_test.dart +++ b/test/src/models/mfa_recovery_codes_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = MfaRecoveryCodes.fromMap(map); - expect(result.recoveryCodes, []); - }); + expect(result.recoveryCodes, []); + }); }); } diff --git a/test/src/models/mfa_type_test.dart b/test/src/models/mfa_type_test.dart index 3f45d288..81657394 100644 --- a/test/src/models/mfa_type_test.dart +++ b/test/src/models/mfa_type_test.dart @@ -6,14 +6,16 @@ void main() { test('model', () { final model = MfaType( secret: '[SHARED_SECRET]', - uri: 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', + uri: + 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', ); final map = model.toMap(); final result = MfaType.fromMap(map); - expect(result.secret, '[SHARED_SECRET]'); - expect(result.uri, 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite'); - }); + expect(result.secret, '[SHARED_SECRET]'); + expect(result.uri, + 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite'); + }); }); } diff --git a/test/src/models/phone_list_test.dart b/test/src/models/phone_list_test.dart index 6ca46a63..bf22a5c7 100644 --- a/test/src/models/phone_list_test.dart +++ b/test/src/models/phone_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = PhoneList.fromMap(map); - expect(result.total, 5); - expect(result.phones, []); - }); + expect(result.total, 5); + expect(result.phones, []); + }); }); } diff --git a/test/src/models/phone_test.dart b/test/src/models/phone_test.dart index d0e5333b..f70db0e3 100644 --- a/test/src/models/phone_test.dart +++ b/test/src/models/phone_test.dart @@ -13,9 +13,9 @@ void main() { final map = model.toMap(); final result = Phone.fromMap(map); - expect(result.code, '+1'); - expect(result.countryCode, 'US'); - expect(result.countryName, 'United States'); - }); + expect(result.code, '+1'); + expect(result.countryCode, 'US'); + expect(result.countryName, 'United States'); + }); }); } diff --git a/test/src/models/preferences_test.dart b/test/src/models/preferences_test.dart index acde349c..9db30b03 100644 --- a/test/src/models/preferences_test.dart +++ b/test/src/models/preferences_test.dart @@ -10,7 +10,6 @@ void main() { final map = model.toMap(); final result = Preferences.fromMap(map); - }); }); } diff --git a/test/src/models/presence_list_test.dart b/test/src/models/presence_list_test.dart index 57a86348..46f69af6 100644 --- a/test/src/models/presence_list_test.dart +++ b/test/src/models/presence_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = PresenceList.fromMap(map); - expect(result.total, 5); - expect(result.presences, []); - }); + expect(result.total, 5); + expect(result.presences, []); + }); }); } diff --git a/test/src/models/presence_test.dart b/test/src/models/presence_test.dart index edcfe5f5..ef2ebe31 100644 --- a/test/src/models/presence_test.dart +++ b/test/src/models/presence_test.dart @@ -16,12 +16,12 @@ void main() { final map = model.toMap(); final result = Presence.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - expect(result.userId, '674af8f3e12a5f9ac0be'); - expect(result.source, 'HTTP'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + expect(result.userId, '674af8f3e12a5f9ac0be'); + expect(result.source, 'HTTP'); + }); }); } diff --git a/test/src/models/row_list_test.dart b/test/src/models/row_list_test.dart index d4900dd4..12693926 100644 --- a/test/src/models/row_list_test.dart +++ b/test/src/models/row_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = RowList.fromMap(map); - expect(result.total, 5); - expect(result.rows, []); - }); + expect(result.total, 5); + expect(result.rows, []); + }); }); } diff --git a/test/src/models/row_test.dart b/test/src/models/row_test.dart index 4e72a449..564bf303 100644 --- a/test/src/models/row_test.dart +++ b/test/src/models/row_test.dart @@ -18,13 +18,13 @@ void main() { final map = model.toMap(); final result = Row.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$sequence, '1'); - expect(result.$tableId, '5e5ea5c15117e'); - expect(result.$databaseId, '5e5ea5c15117e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$sequence, '1'); + expect(result.$tableId, '5e5ea5c15117e'); + expect(result.$databaseId, '5e5ea5c15117e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + }); }); } diff --git a/test/src/models/session_list_test.dart b/test/src/models/session_list_test.dart index eaab249e..708e0583 100644 --- a/test/src/models/session_list_test.dart +++ b/test/src/models/session_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = SessionList.fromMap(map); - expect(result.total, 5); - expect(result.sessions, []); - }); + expect(result.total, 5); + expect(result.sessions, []); + }); }); } diff --git a/test/src/models/session_test.dart b/test/src/models/session_test.dart index 0177e477..689e6048 100644 --- a/test/src/models/session_test.dart +++ b/test/src/models/session_test.dart @@ -39,35 +39,35 @@ void main() { final map = model.toMap(); final result = Session.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5bb8c16897e'); - expect(result.expire, '2020-10-15T06:38:00.000+00:00'); - expect(result.provider, 'email'); - expect(result.providerUid, 'user@example.com'); - expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); - expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - expect(result.ip, '127.0.0.1'); - expect(result.osCode, 'Mac'); - expect(result.osName, 'Mac'); - expect(result.osVersion, 'Mac'); - expect(result.clientType, 'browser'); - expect(result.clientCode, 'CM'); - expect(result.clientName, 'Chrome Mobile iOS'); - expect(result.clientVersion, '84.0'); - expect(result.clientEngine, 'WebKit'); - expect(result.clientEngineVersion, '605.1.15'); - expect(result.deviceName, 'smartphone'); - expect(result.deviceBrand, 'Google'); - expect(result.deviceModel, 'Nexus 5'); - expect(result.countryCode, 'US'); - expect(result.countryName, 'United States'); - expect(result.current, true); - expect(result.factors, []); - expect(result.secret, '5e5bb8c16897e'); - expect(result.mfaUpdatedAt, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5bb8c16897e'); + expect(result.expire, '2020-10-15T06:38:00.000+00:00'); + expect(result.provider, 'email'); + expect(result.providerUid, 'user@example.com'); + expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); + expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + expect(result.ip, '127.0.0.1'); + expect(result.osCode, 'Mac'); + expect(result.osName, 'Mac'); + expect(result.osVersion, 'Mac'); + expect(result.clientType, 'browser'); + expect(result.clientCode, 'CM'); + expect(result.clientName, 'Chrome Mobile iOS'); + expect(result.clientVersion, '84.0'); + expect(result.clientEngine, 'WebKit'); + expect(result.clientEngineVersion, '605.1.15'); + expect(result.deviceName, 'smartphone'); + expect(result.deviceBrand, 'Google'); + expect(result.deviceModel, 'Nexus 5'); + expect(result.countryCode, 'US'); + expect(result.countryName, 'United States'); + expect(result.current, true); + expect(result.factors, []); + expect(result.secret, '5e5bb8c16897e'); + expect(result.mfaUpdatedAt, '2020-10-15T06:38:00.000+00:00'); + }); }); } diff --git a/test/src/models/subscriber_test.dart b/test/src/models/subscriber_test.dart index 94c6a502..7445514c 100644 --- a/test/src/models/subscriber_test.dart +++ b/test/src/models/subscriber_test.dart @@ -10,15 +10,15 @@ void main() { $updatedAt: '2020-10-15T06:38:00.000+00:00', targetId: '259125845563242502', target: Target( - $id: '259125845563242502', - $createdAt: '2020-10-15T06:38:00.000+00:00', - $updatedAt: '2020-10-15T06:38:00.000+00:00', - name: 'Apple iPhone 12', - userId: '259125845563242502', - providerType: 'email', - identifier: 'token', - expired: true, - ), + $id: '259125845563242502', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Apple iPhone 12', + userId: '259125845563242502', + providerType: 'email', + identifier: 'token', + expired: true, + ), userId: '5e5ea5c16897e', userName: 'Aegon Targaryen', topicId: '259125845563242502', @@ -28,14 +28,14 @@ void main() { final map = model.toMap(); final result = Subscriber.fromMap(map); - expect(result.$id, '259125845563242502'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.targetId, '259125845563242502'); - expect(result.userId, '5e5ea5c16897e'); - expect(result.userName, 'Aegon Targaryen'); - expect(result.topicId, '259125845563242502'); - expect(result.providerType, 'email'); - }); + expect(result.$id, '259125845563242502'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.targetId, '259125845563242502'); + expect(result.userId, '5e5ea5c16897e'); + expect(result.userName, 'Aegon Targaryen'); + expect(result.topicId, '259125845563242502'); + expect(result.providerType, 'email'); + }); }); } diff --git a/test/src/models/target_test.dart b/test/src/models/target_test.dart index a49f3def..49f1e75e 100644 --- a/test/src/models/target_test.dart +++ b/test/src/models/target_test.dart @@ -18,14 +18,14 @@ void main() { final map = model.toMap(); final result = Target.fromMap(map); - expect(result.$id, '259125845563242502'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.name, 'Apple iPhone 12'); - expect(result.userId, '259125845563242502'); - expect(result.providerType, 'email'); - expect(result.identifier, 'token'); - expect(result.expired, true); - }); + expect(result.$id, '259125845563242502'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.name, 'Apple iPhone 12'); + expect(result.userId, '259125845563242502'); + expect(result.providerType, 'email'); + expect(result.identifier, 'token'); + expect(result.expired, true); + }); }); } diff --git a/test/src/models/team_list_test.dart b/test/src/models/team_list_test.dart index a19b667d..fe2f4a85 100644 --- a/test/src/models/team_list_test.dart +++ b/test/src/models/team_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = TeamList.fromMap(map); - expect(result.total, 5); - expect(result.teams, []); - }); + expect(result.total, 5); + expect(result.teams, []); + }); }); } diff --git a/test/src/models/team_test.dart b/test/src/models/team_test.dart index 43b2e45c..f652f2c1 100644 --- a/test/src/models/team_test.dart +++ b/test/src/models/team_test.dart @@ -16,11 +16,11 @@ void main() { final map = model.toMap(); final result = Team.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.name, 'VIP'); - expect(result.total, 7); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.name, 'VIP'); + expect(result.total, 7); + }); }); } diff --git a/test/src/models/token_test.dart b/test/src/models/token_test.dart index 7ee4b268..8f0957c9 100644 --- a/test/src/models/token_test.dart +++ b/test/src/models/token_test.dart @@ -16,12 +16,12 @@ void main() { final map = model.toMap(); final result = Token.fromMap(map); - expect(result.$id, 'bb8ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5ea5c168bb8'); - expect(result.secret, ''); - expect(result.expire, '2020-10-15T06:38:00.000+00:00'); - expect(result.phrase, 'Golden Fox'); - }); + expect(result.$id, 'bb8ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5ea5c168bb8'); + expect(result.secret, ''); + expect(result.expire, '2020-10-15T06:38:00.000+00:00'); + expect(result.phrase, 'Golden Fox'); + }); }); } diff --git a/test/src/models/transaction_list_test.dart b/test/src/models/transaction_list_test.dart index 68023e18..a524ef71 100644 --- a/test/src/models/transaction_list_test.dart +++ b/test/src/models/transaction_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = TransactionList.fromMap(map); - expect(result.total, 5); - expect(result.transactions, []); - }); + expect(result.total, 5); + expect(result.transactions, []); + }); }); } diff --git a/test/src/models/transaction_test.dart b/test/src/models/transaction_test.dart index 723ebac2..0169427f 100644 --- a/test/src/models/transaction_test.dart +++ b/test/src/models/transaction_test.dart @@ -16,12 +16,12 @@ void main() { final map = model.toMap(); final result = Transaction.fromMap(map); - expect(result.$id, '259125845563242502'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.status, 'pending'); - expect(result.operations, 5); - expect(result.expiresAt, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, '259125845563242502'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.status, 'pending'); + expect(result.operations, 5); + expect(result.expiresAt, '2020-10-15T06:38:00.000+00:00'); + }); }); } diff --git a/test/src/models/user_test.dart b/test/src/models/user_test.dart index c058ea26..77c7dd97 100644 --- a/test/src/models/user_test.dart +++ b/test/src/models/user_test.dart @@ -26,21 +26,21 @@ void main() { final map = model.toMap(); final result = User.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.name, 'John Doe'); - expect(result.registration, '2020-10-15T06:38:00.000+00:00'); - expect(result.status, true); - expect(result.labels, []); - expect(result.passwordUpdate, '2020-10-15T06:38:00.000+00:00'); - expect(result.email, 'john@appwrite.io'); - expect(result.phone, '+4930901820'); - expect(result.emailVerification, true); - expect(result.phoneVerification, true); - expect(result.mfa, true); - expect(result.targets, []); - expect(result.accessedAt, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.name, 'John Doe'); + expect(result.registration, '2020-10-15T06:38:00.000+00:00'); + expect(result.status, true); + expect(result.labels, []); + expect(result.passwordUpdate, '2020-10-15T06:38:00.000+00:00'); + expect(result.email, 'john@appwrite.io'); + expect(result.phone, '+4930901820'); + expect(result.emailVerification, true); + expect(result.phoneVerification, true); + expect(result.mfa, true); + expect(result.targets, []); + expect(result.accessedAt, '2020-10-15T06:38:00.000+00:00'); + }); }); } From 2a0edb00aed9b0b3c22b7ae23e3aee51002f3d6b Mon Sep 17 00:00:00 2001 From: root Date: Thu, 25 Jun 2026 04:52:20 +0000 Subject: [PATCH 7/8] chore: update Flutter SDK to 25.2.0 --- CHANGELOG.md | 1 - lib/appwrite.dart | 2 +- lib/channel.dart | 20 +- lib/client_browser.dart | 2 +- lib/client_io.dart | 2 +- lib/operator.dart | 11 +- lib/query.dart | 91 +- lib/realtime_browser.dart | 2 +- lib/realtime_io.dart | 2 +- lib/role.dart | 2 +- lib/services/account.dart | 1560 +++++----- lib/services/avatars.dart | 351 +-- lib/services/databases.dart | 603 ++-- lib/services/functions.dart | 115 +- lib/services/graphql.dart | 50 +- lib/services/locale.dart | 142 +- lib/services/messaging.dart | 70 +- lib/services/presences.dart | 182 +- lib/services/storage.dart | 342 +-- lib/services/tables_db.dart | 547 ++-- lib/services/teams.dart | 421 ++- lib/src/client.dart | 4 +- lib/src/client_base.dart | 7 - lib/src/client_browser.dart | 15 +- lib/src/client_io.dart | 15 +- lib/src/client_mixin.dart | 9 +- lib/src/enums/authentication_factor.dart | 18 +- lib/src/enums/authenticator_type.dart | 12 +- lib/src/enums/browser.dart | 38 +- lib/src/enums/browser_permission.dart | 50 +- lib/src/enums/browser_theme.dart | 14 +- lib/src/enums/credit_card.dart | 44 +- lib/src/enums/execution_method.dart | 24 +- lib/src/enums/execution_status.dart | 20 +- lib/src/enums/execution_trigger.dart | 16 +- 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 | 96 +- lib/src/enums/timezone.dart | 848 +++--- lib/src/exception.dart | 2 +- lib/src/models/algo_argon2.dart | 62 +- lib/src/models/algo_bcrypt.dart | 32 +- lib/src/models/algo_md5.dart | 32 +- lib/src/models/algo_phpass.dart | 32 +- lib/src/models/algo_scrypt.dart | 86 +- lib/src/models/algo_scrypt_modified.dart | 62 +- lib/src/models/algo_sha.dart | 32 +- lib/src/models/continent.dart | 42 +- lib/src/models/continent_list.dart | 43 +- lib/src/models/country.dart | 42 +- lib/src/models/country_list.dart | 43 +- lib/src/models/currency.dart | 110 +- lib/src/models/currency_list.dart | 43 +- lib/src/models/document.dart | 102 +- lib/src/models/document_list.dart | 47 +- lib/src/models/execution.dart | 246 +- lib/src/models/execution_list.dart | 43 +- lib/src/models/file.dart | 194 +- lib/src/models/file_list.dart | 42 +- lib/src/models/headers.dart | 42 +- lib/src/models/identity.dart | 122 +- lib/src/models/identity_list.dart | 43 +- lib/src/models/jwt.dart | 32 +- lib/src/models/language.dart | 52 +- lib/src/models/language_list.dart | 43 +- lib/src/models/locale.dart | 110 +- lib/src/models/locale_code.dart | 42 +- lib/src/models/locale_code_list.dart | 43 +- lib/src/models/log.dart | 290 +- lib/src/models/log_list.dart | 42 +- lib/src/models/membership.dart | 206 +- lib/src/models/membership_list.dart | 43 +- lib/src/models/mfa_challenge.dart | 62 +- lib/src/models/mfa_factors.dart | 62 +- lib/src/models/mfa_recovery_codes.dart | 32 +- lib/src/models/mfa_type.dart | 42 +- lib/src/models/model.dart | 2 +- lib/src/models/phone.dart | 52 +- lib/src/models/phone_list.dart | 42 +- lib/src/models/preferences.dart | 32 +- lib/src/models/presence.dart | 112 +- lib/src/models/presence_list.dart | 43 +- lib/src/models/row.dart | 102 +- lib/src/models/row_list.dart | 46 +- lib/src/models/session.dart | 360 +-- lib/src/models/session_list.dart | 43 +- lib/src/models/subscriber.dart | 112 +- lib/src/models/target.dart | 112 +- lib/src/models/team.dart | 98 +- lib/src/models/team_list.dart | 42 +- lib/src/models/token.dart | 98 +- lib/src/models/transaction.dart | 98 +- lib/src/models/transaction_list.dart | 43 +- lib/src/models/user.dart | 332 +- lib/src/realtime.dart | 6 +- lib/src/realtime_io.dart | 4 +- lib/src/realtime_message.dart | 2 +- lib/src/realtime_mixin.dart | 31 +- lib/src/realtime_response.dart | 10 +- lib/src/realtime_stub.dart | 4 +- test/channel_test.dart | 42 +- test/query_test.dart | 1 + test/services/account_test.dart | 2691 +++++++++-------- test/services/avatars_test.dart | 204 +- test/services/databases_test.dart | 585 ++-- test/services/functions_test.dart | 188 +- test/services/graphql_test.dart | 71 +- test/services/locale_test.dart | 253 +- test/services/messaging_test.dart | 122 +- test/services/presences_test.dart | 202 +- test/services/storage_test.dart | 341 ++- test/services/tables_db_test.dart | 585 ++-- test/services/teams_test.dart | 555 ++-- test/src/models/algo_argon2_test.dart | 10 +- test/src/models/algo_bcrypt_test.dart | 4 +- test/src/models/algo_md5_test.dart | 4 +- test/src/models/algo_phpass_test.dart | 4 +- .../src/models/algo_scrypt_modified_test.dart | 14 +- test/src/models/algo_scrypt_test.dart | 12 +- test/src/models/algo_sha_test.dart | 4 +- test/src/models/continent_list_test.dart | 6 +- test/src/models/continent_test.dart | 6 +- test/src/models/country_list_test.dart | 6 +- test/src/models/country_test.dart | 6 +- test/src/models/currency_list_test.dart | 6 +- test/src/models/currency_test.dart | 16 +- test/src/models/document_list_test.dart | 6 +- test/src/models/document_test.dart | 16 +- test/src/models/execution_list_test.dart | 6 +- test/src/models/execution_test.dart | 36 +- test/src/models/file_list_test.dart | 6 +- test/src/models/file_test.dart | 30 +- test/src/models/headers_test.dart | 6 +- test/src/models/identity_list_test.dart | 6 +- test/src/models/identity_test.dart | 22 +- test/src/models/jwt_test.dart | 8 +- test/src/models/language_list_test.dart | 6 +- test/src/models/language_test.dart | 8 +- test/src/models/locale_code_list_test.dart | 6 +- test/src/models/locale_code_test.dart | 6 +- test/src/models/locale_test.dart | 16 +- test/src/models/log_list_test.dart | 6 +- test/src/models/log_test.dart | 46 +- test/src/models/membership_list_test.dart | 6 +- test/src/models/membership_test.dart | 32 +- test/src/models/mfa_challenge_test.dart | 10 +- test/src/models/mfa_factors_test.dart | 10 +- test/src/models/mfa_recovery_codes_test.dart | 4 +- test/src/models/mfa_type_test.dart | 10 +- test/src/models/phone_list_test.dart | 6 +- test/src/models/phone_test.dart | 8 +- test/src/models/preferences_test.dart | 1 + test/src/models/presence_list_test.dart | 6 +- test/src/models/presence_test.dart | 14 +- test/src/models/row_list_test.dart | 6 +- test/src/models/row_test.dart | 16 +- test/src/models/session_list_test.dart | 6 +- test/src/models/session_test.dart | 60 +- test/src/models/subscriber_test.dart | 36 +- test/src/models/target_test.dart | 18 +- test/src/models/team_list_test.dart | 6 +- test/src/models/team_test.dart | 12 +- test/src/models/token_test.dart | 14 +- test/src/models/transaction_list_test.dart | 6 +- test/src/models/transaction_test.dart | 14 +- test/src/models/user_test.dart | 32 +- 167 files changed, 8661 insertions(+), 8517 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77556eae..e3ee6d03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,6 @@ * Added: Realtime connections now authenticate with the configured JWT. * Added: Forwarded `impersonateUserId` on `avatars` and `storage` file requests. -* Deprecated: `databases` transaction and document methods in favor of `TablesDB`. ## 25.1.0 diff --git a/lib/appwrite.dart b/lib/appwrite.dart index ae51be5e..6615de8a 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.9.x. +/// This SDK is compatible with Appwrite server version 1.9.x. /// For older versions, please check /// [previous releases](https://github.com/appwrite/sdk-for-flutter/releases). library appwrite; diff --git a/lib/channel.dart b/lib/channel.dart index afc68efa..d511f5a4 100644 --- a/lib/channel.dart +++ b/lib/channel.dart @@ -2,33 +2,19 @@ part of appwrite; // Marker classes for type safety class _Root {} - class _Database {} - class _Collection {} - class _Document {} - class _TablesDB {} - class _Table {} - class _Row {} - class _Bucket {} - class _File {} - class _Func {} - class _Execution {} - class _Team {} - class _Membership {} - class _Presence {} - class _Resolved {} // Helper function for normalizing ID @@ -113,15 +99,15 @@ extension DatabaseChannel on Channel<_Database> { /// Only available on Channel<_Collection> extension CollectionChannel on Channel<_Collection> { - Channel<_Document> document([String? id]) => - _next<_Document>('documents', id); + Channel<_Document> document([String? id]) => _next<_Document>('documents', id); } // --- TABLESDB ROUTE --- /// Only available on Channel<_TablesDB> extension TablesDBChannel on Channel<_TablesDB> { - Channel<_Table> table(String id) => _next<_Table>('tables', id); + Channel<_Table> table(String id) => + _next<_Table>('tables', id); } /// Only available on Channel<_Table> 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/operator.dart b/lib/operator.dart index 337dda30..9dd7f4c7 100644 --- a/lib/operator.dart +++ b/lib/operator.dart @@ -31,7 +31,7 @@ class Operator { result['method'] = method; - if (values != null) { + if(values != null) { result['values'] = values is List ? values : [values]; } @@ -147,7 +147,8 @@ class Operator { Operator._('arrayRemove', [value]).toString(); /// Remove duplicate values from an array attribute. - static String arrayUnique() => Operator._('arrayUnique', []).toString(); + static String arrayUnique() => + Operator._('arrayUnique', []).toString(); /// Keep only values that exist in both the current array and the provided array. static String arrayIntersect(List values) => @@ -172,7 +173,8 @@ class Operator { Operator._('stringReplace', [search, replace]).toString(); /// Toggle a boolean attribute. - static String toggle() => Operator._('toggle', []).toString(); + static String toggle() => + Operator._('toggle', []).toString(); /// Add days to a date attribute. static String dateAddDays(int days) => @@ -183,5 +185,6 @@ class Operator { Operator._('dateSubDays', [days]).toString(); /// Set a date attribute to the current date and time. - static String dateSetNow() => Operator._('dateSetNow', []).toString(); + static String dateSetNow() => + Operator._('dateSetNow', []).toString(); } diff --git a/lib/query.dart b/lib/query.dart index 3693dce6..95365bf7 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. @@ -140,46 +140,50 @@ class Query { Query._('notEndsWith', attribute, value).toString(); /// Filter resources where document was created before [value]. - static String createdBefore(String value) => lessThan('\$createdAt', value); + static String createdBefore(String value) => + lessThan('\$createdAt', value); /// Filter resources where document was created after [value]. - static String createdAfter(String value) => greaterThan('\$createdAt', value); + static String createdAfter(String value) => + greaterThan('\$createdAt', value); /// Filter resources where document was created between [start] and [end] (inclusive). static String createdBetween(String start, String end) => between('\$createdAt', start, end); /// Filter resources where document was updated before [value]. - static String updatedBefore(String value) => lessThan('\$updatedAt', value); + static String updatedBefore(String value) => + lessThan('\$updatedAt', value); /// Filter resources where document was updated after [value]. - static String updatedAfter(String value) => greaterThan('\$updatedAt', value); + static String updatedAfter(String value) => + greaterThan('\$updatedAt', value); /// Filter resources where document was updated between [start] and [end] (inclusive). static String updatedBetween(String start, String end) => between('\$updatedAt', start, end); static String or(List queries) => Query._( - 'or', - null, - queries.map((query) => jsonDecode(query)).toList(), - ).toString(); + 'or', + null, + queries.map((query) => jsonDecode(query)).toList(), + ).toString(); static String and(List queries) => Query._( - 'and', - null, - queries.map((query) => jsonDecode(query)).toList(), - ).toString(); + 'and', + null, + queries.map((query) => jsonDecode(query)).toList(), + ).toString(); /// Filter array elements where at least one element matches all the specified queries. /// /// [attribute] The attribute containing the array to filter on. /// [queries] The list of query strings to match against array elements. static String elemMatch(String attribute, List queries) => Query._( - 'elemMatch', - attribute, - queries.map((query) => jsonDecode(query)).toList(), - ).toString(); + 'elemMatch', + attribute, + queries.map((query) => jsonDecode(query)).toList(), + ).toString(); /// Specify which attributes should be returned by the API call. static String select(List attributes) => @@ -194,17 +198,18 @@ class Query { Query._('orderDesc', attribute).toString(); /// Sort results randomly. - static String orderRandom() => Query._('orderRandom').toString(); + static String orderRandom() => + Query._('orderRandom').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) => @@ -214,43 +219,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, 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) => @@ -283,4 +272,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 48b60041..9c021e93 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 { final String apiPath = '/account'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -29,30 +30,29 @@ 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 { final String apiPath = '/account'; - final Map apiParams = { - 'userId': userId, - 'email': email, - 'password': password, - if (name != null) 'name': name, - }; + final Map apiParams = { + 'userId': userId, + + 'email': email, + + 'password': password, + + if (name != null) 'name': name, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 @@ -62,65 +62,66 @@ 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 { final String apiPath = '/account/email'; - final Map apiParams = { - 'email': email, - 'password': password, - }; + final Map apiParams = { + 'email': email, + + 'password': password, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, bool? total}) async { + Future listIdentities({List? queries, bool? total}) async { final String apiPath = '/account/identities'; - final Map apiParams = { - if (queries != null) 'queries': queries, - if (total != null) 'total': total, - }; + final Map apiParams = { + if (queries != null) 'queries': queries, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + if (total != null) 'total': total, - final res = await client.call(HttpMethod.get, - path: apiPath, params: apiParams, headers: apiHeaders); + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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 @@ -131,20 +132,20 @@ class Account extends Service { Future createJWT({int? duration}) async { final String apiPath = '/account/jwts'; - final Map apiParams = { - if (duration != null) 'duration': duration, - }; + final Map apiParams = { + if (duration != null) 'duration': duration, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + }; - final res = await client.call(HttpMethod.post, - path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 @@ -152,224 +153,212 @@ class Account extends Service { Future listLogs({List? queries, bool? total}) async { final String apiPath = '/account/logs'; - final Map apiParams = { - if (queries != null) 'queries': queries, - if (total != null) 'total': total, - }; + final Map apiParams = { + if (queries != null) 'queries': queries, + + if (total != null) 'total': total, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 { final String apiPath = '/account/mfa'; - final Map apiParams = { - 'mfa': mfa, - }; + final Map apiParams = { + 'mfa': mfa, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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); + @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 apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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.MfaType.fromMap(res.data); - 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); + Future createMFAAuthenticator({required enums.AuthenticatorType type}) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + + final Map apiParams = { + }; - final Map apiParams = {}; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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.MfaType.fromMap(res.data); - 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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); + 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 apiParams = { - 'otp': otp, - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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.User.fromMap(res.data); - 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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 { final String apiPath = '/account/mfa/challenges'; - final Map apiParams = { - 'factor': factor.value, - }; + final Map apiParams = { + 'factor': factor.value, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 { final String apiPath = '/account/mfa/challenges'; - final Map apiParams = { - 'factor': factor.value, - }; + final Map apiParams = { + 'factor': factor.value, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + }; - final res = await client.call(HttpMethod.post, - path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 @@ -377,27 +366,26 @@ 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 { final String apiPath = '/account/mfa/challenges'; - final Map apiParams = { - 'challengeId': challengeId, - 'otp': otp, - }; + final Map apiParams = { + 'challengeId': challengeId, + + 'otp': otp, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 @@ -405,83 +393,84 @@ 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 { final String apiPath = '/account/mfa/challenges'; - final Map apiParams = { - 'challengeId': challengeId, - 'otp': otp, - }; + final Map apiParams = { + 'challengeId': challengeId, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + 'otp': otp, - final res = await client.call(HttpMethod.put, - path: apiPath, params: apiParams, headers: apiHeaders); + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 { final String apiPath = '/account/mfa/factors'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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 { final String apiPath = '/account/mfa/factors'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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 @@ -491,17 +480,18 @@ class Account extends Service { Future getMFARecoveryCodes() async { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -509,23 +499,22 @@ 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 { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 @@ -536,41 +525,40 @@ class Account extends Service { Future createMFARecoveryCodes() async { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 @@ -580,62 +568,62 @@ class Account extends Service { Future updateMFARecoveryCodes() async { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 { final String apiPath = '/account/name'; - final Map apiParams = { - 'name': name, - }; + final Map apiParams = { + 'name': name, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 { final String apiPath = '/account/password'; - final Map apiParams = { - 'password': password, - if (oldPassword != null) 'oldPassword': oldPassword, - }; + final Map apiParams = { + 'password': password, + + if (oldPassword != null) 'oldPassword': oldPassword, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 @@ -643,42 +631,43 @@ 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 { final String apiPath = '/account/phone'; - final Map apiParams = { - 'phone': phone, - 'password': password, - }; + final Map apiParams = { + 'phone': phone, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + 'password': password, - final res = await client.call(HttpMethod.patch, - path: apiPath, params: apiParams, headers: apiHeaders); + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 { final String apiPath = '/account/prefs'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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 @@ -687,20 +676,20 @@ class Account extends Service { Future updatePrefs({required Map prefs}) async { final String apiPath = '/account/prefs'; - final Map apiParams = { - 'prefs': prefs, - }; + final Map apiParams = { + 'prefs': prefs, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + }; - final res = await client.call(HttpMethod.patch, - path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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. @@ -711,25 +700,25 @@ 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 { final String apiPath = '/account/recovery'; - final Map apiParams = { - 'email': email, - 'url': url, - }; + final Map apiParams = { + 'email': email, + + 'url': url, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 @@ -737,33 +726,32 @@ 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 { final 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 @@ -771,17 +759,18 @@ class Account extends Service { Future listSessions() async { final String apiPath = '/account/sessions'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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 @@ -789,17 +778,18 @@ class Account extends Service { Future deleteSessions() async { final String apiPath = '/account/sessions'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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 @@ -812,216 +802,213 @@ class Account extends Service { Future createAnonymousSession() async { final String apiPath = '/account/sessions/anonymous'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 { final String apiPath = '/account/sessions/email'; - final Map apiParams = { - 'email': email, - 'password': password, - }; + final Map apiParams = { + 'email': email, + + 'password': password, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + }; - final res = await client.call(HttpMethod.post, - path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 { final String apiPath = '/account/sessions/magic-url'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; + final Map apiParams = { + 'userId': userId, + + 'secret': secret, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 = { - if (success != null) 'success': success, - if (failure != null) 'failure': failure, - if (scopes != null) 'scopes': scopes, - 'project': client.config['project'], - }; - - final List query = []; - - params.forEach((key, value) { - if (value is List) { - for (var item in value) { - query.add( + /// + 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 = { + + if (success != null) 'success': success, + + if (failure != null) 'failure': failure, + + if (scopes != null) '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); + } + } 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 { final String apiPath = '/account/sessions/phone'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; + final Map apiParams = { + 'userId': userId, + + 'secret': secret, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + }; - final res = await client.call(HttpMethod.put, - path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 { final String apiPath = '/account/sessions/token'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; + final Map apiParams = { + 'userId': userId, + + 'secret': secret, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 apiParams = {}; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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, @@ -1030,20 +1017,20 @@ 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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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 @@ -1052,18 +1039,18 @@ class Account extends Service { Future updateStatus() async { final String apiPath = '/account/status'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 @@ -1071,28 +1058,27 @@ 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 { final String apiPath = '/account/targets/push'; - final Map apiParams = { - 'targetId': targetId, - 'identifier': identifier, - if (providerId != null) 'providerId': providerId, - }; + final Map apiParams = { + 'targetId': targetId, + + 'identifier': identifier, + + if (providerId != null) 'providerId': providerId, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 @@ -1100,45 +1086,43 @@ 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); + 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 apiParams = { - 'identifier': identifier, - }; + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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.Target.fromMap(res.data); - 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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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 @@ -1150,31 +1134,32 @@ 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 { final String apiPath = '/account/tokens/email'; - final Map apiParams = { - 'userId': userId, - 'email': email, - if (phrase != null) 'phrase': phrase, - }; + final Map apiParams = { + 'userId': userId, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + 'email': email, - final res = await client.call(HttpMethod.post, - path: apiPath, params: apiParams, headers: apiHeaders); + if (phrase != null) 'phrase': phrase, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 @@ -1186,88 +1171,87 @@ 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 { final String apiPath = '/account/tokens/magic-url'; - final Map apiParams = { - 'userId': userId, - 'email': email, - if (url != null) 'url': url, - if (phrase != null) 'phrase': phrase, - }; + final Map apiParams = { + 'userId': userId, + + 'email': email, + + if (url != null) 'url': url, + + if (phrase != null) 'phrase': phrase, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 = { - if (success != null) 'success': success, - if (failure != null) 'failure': failure, - if (scopes != null) 'scopes': scopes, - 'project': client.config['project'], - }; - - final List query = []; - - params.forEach((key, value) { - if (value is List) { - for (var item in value) { - query.add( + 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 = { + + if (success != null) 'success': success, + + if (failure != null) 'failure': failure, + + if (scopes != null) '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); + } + } 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 @@ -1276,29 +1260,29 @@ 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 { final String apiPath = '/account/tokens/phone'; - final Map apiParams = { - 'userId': userId, - 'phone': phone, - }; + final Map apiParams = { + 'userId': userId, + + 'phone': phone, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + }; - final res = await client.call(HttpMethod.post, - path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 @@ -1310,29 +1294,29 @@ 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 createEmailVerification({required String url}) async { final String apiPath = '/account/verifications/email'; - final Map apiParams = { - 'url': url, - }; + final Map apiParams = { + 'url': url, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 @@ -1344,83 +1328,81 @@ 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. - /// - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.createEmailVerification` instead.') + /// + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.createEmailVerification` instead.') Future createVerification({required String url}) async { final String apiPath = '/account/verifications/email'; - final Map apiParams = { - 'url': url, - }; + final Map apiParams = { + 'url': url, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + }; - final res = await client.call(HttpMethod.post, - path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 updateEmailVerification( - {required String userId, required String secret}) async { + Future updateEmailVerification({required String userId, required String secret}) async { final String apiPath = '/account/verifications/email'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; + final Map apiParams = { + 'userId': userId, + + 'secret': secret, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 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. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.updateEmailVerification` instead.') - Future updateVerification( - {required String userId, required String secret}) async { + @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.updateEmailVerification` instead.') + Future updateVerification({required String userId, required String secret}) async { final String apiPath = '/account/verifications/email'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; + final Map apiParams = { + 'userId': userId, + + 'secret': secret, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 @@ -1434,42 +1416,42 @@ class Account extends Service { Future createPhoneVerification() async { final String apiPath = '/account/verifications/phone'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 { final String apiPath = '/account/verifications/phone'; - final Map apiParams = { - 'userId': userId, - 'secret': secret, - }; + final Map apiParams = { + 'userId': userId, + + 'secret': secret, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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); } } diff --git a/lib/services/avatars.dart b/lib/services/avatars.dart index cdd93e6e..4dca3b16 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,134 +11,139 @@ 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 = { - if (width != null) 'width': width, - if (height != null) 'height': height, - if (quality != null) 'quality': quality, - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + + if (width != null) 'width': width, + + if (height != null) 'height': height, + + if (quality != null) 'quality': quality, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 = { - if (width != null) 'width': width, - if (height != null) 'height': height, - if (quality != null) 'quality': quality, - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + + if (width != null) 'width': width, + + if (height != null) 'height': height, + + if (quality != null) 'quality': quality, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 { final String apiPath = '/avatars/favicon'; - final Map params = { - 'url': url, - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; + 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'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 = { - if (width != null) 'width': width, - if (height != null) 'height': height, - if (quality != null) 'quality': quality, - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + + if (width != null) 'width': width, + + if (height != null) 'height': height, + + if (quality != null) 'quality': quality, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 { final String apiPath = '/avatars/image'; - final Map params = { - 'url': url, - if (width != null) 'width': width, - if (height != null) 'height': height, - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - final res = await client.call(HttpMethod.get, - path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + + 'url': url, + + if (width != null) 'width': width, + + if (height != null) 'height': height, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 @@ -146,117 +151,125 @@ 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 { final String apiPath = '/avatars/initials'; - final Map params = { - if (name != null) 'name': name, - if (width != null) 'width': width, - if (height != null) 'height': height, - if (background != null) 'background': background, - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - final res = await client.call(HttpMethod.get, - path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + + if (name != null) 'name': name, + + if (width != null) 'width': width, + + if (height != null) 'height': height, + + if (background != null) 'background': background, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 { final String apiPath = '/avatars/qr'; - final Map params = { - 'text': text, - if (size != null) 'size': size, - if (margin != null) 'margin': margin, - if (download != null) 'download': download, - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - final res = await client.call(HttpMethod.get, - path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + + 'text': text, + + if (size != null) 'size': size, + + if (margin != null) 'margin': margin, + + if (download != null) 'download': download, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// Use this endpoint to capture a screenshot of any website URL. This endpoint /// uses a headless browser to render the webpage and capture it as an image. - /// + /// /// You can configure the browser viewport size, theme, user agent, /// geolocation, permissions, and more. Capture either just the viewport or the /// full page scroll. - /// + /// /// When width and height are specified, the image is resized accordingly. If /// both dimensions are 0, the API provides an image at original size. If /// dimensions are not specified, the default viewport size is 1280x720px. - Future getScreenshot( - {required String url, - Map? headers, - int? viewportWidth, - int? viewportHeight, - double? scale, - enums.BrowserTheme? theme, - String? userAgent, - bool? fullpage, - String? locale, - enums.Timezone? timezone, - double? latitude, - double? longitude, - double? accuracy, - bool? touch, - List? permissions, - int? sleep, - int? width, - int? height, - int? quality, - enums.ImageFormat? output}) async { + Future getScreenshot({required String url, Map? headers, int? viewportWidth, int? viewportHeight, double? scale, enums.BrowserTheme? theme, String? userAgent, bool? fullpage, String? locale, enums.Timezone? timezone, double? latitude, double? longitude, double? accuracy, bool? touch, List? permissions, int? sleep, int? width, int? height, int? quality, enums.ImageFormat? output}) async { final String apiPath = '/avatars/screenshots'; - final Map params = { - 'url': url, - if (headers != null) 'headers': headers, - if (viewportWidth != null) 'viewportWidth': viewportWidth, - if (viewportHeight != null) 'viewportHeight': viewportHeight, - if (scale != null) 'scale': scale, - if (theme != null) 'theme': theme.value, - if (userAgent != null) 'userAgent': userAgent, - if (fullpage != null) 'fullpage': fullpage, - if (locale != null) 'locale': locale, - if (timezone != null) 'timezone': timezone.value, - if (latitude != null) 'latitude': latitude, - if (longitude != null) 'longitude': longitude, - if (accuracy != null) 'accuracy': accuracy, - if (touch != null) 'touch': touch, - if (permissions != null) - 'permissions': permissions.map((e) => e.value).toList(), - if (sleep != null) 'sleep': sleep, - if (width != null) 'width': width, - if (height != null) 'height': height, - if (quality != null) 'quality': quality, - if (output != null) 'output': output.value, - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - final res = await client.call(HttpMethod.get, - path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + + 'url': url, + + if (headers != null) 'headers': headers, + + if (viewportWidth != null) 'viewportWidth': viewportWidth, + + if (viewportHeight != null) 'viewportHeight': viewportHeight, + + if (scale != null) 'scale': scale, + + if (theme != null) 'theme': theme.value, + + if (userAgent != null) 'userAgent': userAgent, + + if (fullpage != null) 'fullpage': fullpage, + + if (locale != null) 'locale': locale, + + if (timezone != null) 'timezone': timezone.value, + + if (latitude != null) 'latitude': latitude, + + if (longitude != null) 'longitude': longitude, + + if (accuracy != null) 'accuracy': accuracy, + + if (touch != null) 'touch': touch, + + if (permissions != null) 'permissions': permissions.map((e) => e.value).toList(), + + if (sleep != null) 'sleep': sleep, + + if (width != null) 'width': width, + + if (height != null) 'height': height, + + if (quality != null) 'quality': quality, + + if (output != null) 'output': output.value, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } } diff --git a/lib/services/databases.dart b/lib/services/databases.dart index 0ff3fb72..0bfd935a 100644 --- a/lib/services/databases.dart +++ b/lib/services/databases.dart @@ -1,418 +1,339 @@ 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); /// List transactions across all databases. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.listTransactions` instead.') - Future listTransactions( - {List? queries}) async { + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.listTransactions` instead.') + Future listTransactions({List? queries}) async { final String apiPath = '/databases/transactions'; - final Map apiParams = { - if (queries != null) 'queries': queries, - }; + final Map apiParams = { + if (queries != null) 'queries': queries, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + }; - final res = await client.call(HttpMethod.get, - path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.TransactionList.fromMap(res.data); - return models.TransactionList.fromMap(res.data); } /// Create a new transaction. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.createTransaction` instead.') + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.createTransaction` instead.') Future createTransaction({int? ttl}) async { final String apiPath = '/databases/transactions'; - final Map apiParams = { - if (ttl != null) 'ttl': ttl, - }; + final Map apiParams = { + if (ttl != null) 'ttl': ttl, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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.Transaction.fromMap(res.data); - return models.Transaction.fromMap(res.data); } /// Get a transaction by its unique ID. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.getTransaction` instead.') - Future getTransaction( - {required String transactionId}) async { - final String apiPath = '/databases/transactions/{transactionId}' - .replaceAll('{transactionId}', transactionId); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.getTransaction` instead.') + Future getTransaction({required String transactionId}) async { + final String apiPath = '/databases/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + }; - final Map apiParams = {}; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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.Transaction.fromMap(res.data); - return models.Transaction.fromMap(res.data); } /// Update a transaction, to either commit or roll back its operations. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.updateTransaction` instead.') - Future updateTransaction( - {required String transactionId, bool? commit, bool? rollback}) async { - final String apiPath = '/databases/transactions/{transactionId}' - .replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - if (commit != null) 'commit': commit, - if (rollback != null) 'rollback': rollback, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, - path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Transaction.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.updateTransaction` instead.') + Future updateTransaction({required String transactionId, bool? commit, bool? rollback}) async { + final String apiPath = '/databases/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + if (commit != null) 'commit': commit, + + if (rollback != null) 'rollback': rollback, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Transaction.fromMap(res.data); + } /// Delete a transaction by its unique ID. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.deleteTransaction` instead.') + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.deleteTransaction` instead.') Future deleteTransaction({required String transactionId}) async { - final String apiPath = '/databases/transactions/{transactionId}' - .replaceAll('{transactionId}', transactionId); + final String apiPath = '/databases/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + }; - final Map apiParams = {}; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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; } /// Create multiple operations in a single transaction. - @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.createOperations` instead.') - Future createOperations( - {required String transactionId, List? operations}) async { - final String apiPath = '/databases/transactions/{transactionId}/operations' - .replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - if (operations != null) 'operations': operations, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.post, - path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Transaction.fromMap(res.data); + @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.createOperations` instead.') + Future createOperations({required String transactionId, List? operations}) async { + final String apiPath = '/databases/transactions/{transactionId}/operations'.replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + if (operations != null) 'operations': operations, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Transaction.fromMap(res.data); + } /// 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, - String? transactionId, - bool? total, - int? ttl}) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - if (transactionId != null) 'transactionId': transactionId, - if (total != null) 'total': total, - if (ttl != null) 'ttl': ttl, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, String? transactionId, bool? total, int? ttl}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + + if (transactionId != null) 'transactionId': transactionId, + + if (total != null) 'total': total, + + if (ttl != null) 'ttl': ttl, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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, - String? transactionId}) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId); - - final Map apiParams = { - 'documentId': documentId, - 'data': data, - 'permissions': permissions, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, String? transactionId}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); + + final Map apiParams = { + 'documentId': documentId, + + 'data': data, + + 'permissions': permissions, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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, - String? transactionId}) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - if (transactionId != null) 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, String? transactionId}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + + if (transactionId != null) 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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, - Map? data, - List? permissions, - String? transactionId}) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); - - final Map apiParams = { - if (data != null) 'data': data, - 'permissions': permissions, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, Map? data, List? permissions, String? transactionId}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + + final Map apiParams = { + if (data != null) 'data': data, + + 'permissions': permissions, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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, - String? transactionId}) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); - - final Map apiParams = { - if (data != null) 'data': data, - 'permissions': permissions, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, String? transactionId}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + + final Map apiParams = { + if (data != null) 'data': data, + + 'permissions': permissions, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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, - String? transactionId}) async { - final String apiPath = - '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); - - final Map apiParams = { - if (transactionId != null) 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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, String? transactionId}) async { + final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); + + final Map apiParams = { + if (transactionId != null) 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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, - String? transactionId}) 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 = { - if (value != null) 'value': value, - 'min': min, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, String? transactionId}) 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 = { + if (value != null) 'value': value, + + 'min': min, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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, - String? transactionId}) 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 = { - if (value != null) 'value': value, - 'max': max, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, String? transactionId}) 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 = { + if (value != null) 'value': value, + + 'max': max, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); + } } diff --git a/lib/services/functions.dart b/lib/services/functions.dart index ed97921b..0640f80f 100644 --- a/lib/services/functions.dart +++ b/lib/services/functions.dart @@ -1,87 +1,82 @@ 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, bool? total}) async { - final String apiPath = '/functions/{functionId}/executions' - .replaceAll('{functionId}', functionId); + Future listExecutions({required String functionId, List? queries, bool? total}) async { + final String apiPath = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); - final Map apiParams = { - if (queries != null) 'queries': queries, - if (total != null) 'total': total, - }; + final Map apiParams = { + if (queries != null) 'queries': queries, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + if (total != null) 'total': total, - final res = await client.call(HttpMethod.get, - path: apiPath, params: apiParams, headers: apiHeaders); + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.ExecutionList.fromMap(res.data); - 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 = { - if (body != null) 'body': body, - if (xasync != null) 'async': xasync, - if (path != null) 'path': path, - if (method != null) 'method': method.value, - if (headers != null) 'headers': headers, - 'scheduledAt': scheduledAt, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 = { + if (body != null) 'body': body, + + if (xasync != null) 'async': xasync, + + if (path != null) 'path': path, + + if (method != null) 'method': method.value, + + if (headers != null) 'headers': headers, + + 'scheduledAt': scheduledAt, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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); + 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 apiParams = {}; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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.Execution.fromMap(res.data); - return models.Execution.fromMap(res.data); } } diff --git a/lib/services/graphql.dart b/lib/services/graphql.dart index c86f3719..978331fa 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,39 @@ class Graphql extends Service { Future query({required Map query}) async { final String apiPath = '/graphql'; - final Map apiParams = { - 'query': query, - }; + final Map apiParams = { + 'query': query, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'x-sdk-graphql': 'true', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + }; - final res = await client.call(HttpMethod.post, - path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'x-sdk-graphql': 'true', 'content-type': 'application/json', 'accept': 'application/json', + }; + + 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 { final String apiPath = '/graphql/mutation'; - final Map apiParams = { - 'query': query, - }; + final Map apiParams = { + 'query': query, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'x-sdk-graphql': 'true', 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'x-sdk-graphql': 'true', - 'content-type': 'application/json', - 'accept': '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; } } diff --git a/lib/services/locale.dart b/lib/services/locale.dart index 87ea162e..c45a1269 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 { final String apiPath = '/locale'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -33,17 +34,18 @@ class Locale extends Service { Future listCodes() async { final String apiPath = '/locale/codes'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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 @@ -51,17 +53,18 @@ class Locale extends Service { Future listContinents() async { final String apiPath = '/locale/continents'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -69,17 +72,18 @@ class Locale extends Service { Future listCountries() async { final String apiPath = '/locale/countries'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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 @@ -87,17 +91,18 @@ class Locale extends Service { Future listCountriesEU() async { final String apiPath = '/locale/countries/eu'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -105,17 +110,18 @@ class Locale extends Service { Future listCountriesPhones() async { final String apiPath = '/locale/countries/phones'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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 @@ -124,17 +130,18 @@ class Locale extends Service { Future listCurrencies() async { final String apiPath = '/locale/currencies'; - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -142,16 +149,17 @@ class Locale extends Service { Future listLanguages() async { final String apiPath = '/locale/languages'; - final Map apiParams = {}; + final Map apiParams = { + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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); } } diff --git a/lib/services/messaging.dart b/lib/services/messaging.dart index 61ecefee..3dffe41b 100644 --- a/lib/services/messaging.dart +++ b/lib/services/messaging.dart @@ -1,54 +1,48 @@ 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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); + 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 apiParams = {}; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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; } } diff --git a/lib/services/presences.dart b/lib/services/presences.dart index 1c9b651b..088700cb 100644 --- a/lib/services/presences.dart +++ b/lib/services/presences.dart @@ -5,127 +5,123 @@ class Presences extends Service { Presences(super.client); /// List presence logs. Expired entries are filtered out automatically. - /// - Future list( - {List? queries, bool? total, int? ttl}) async { + /// + Future list({List? queries, bool? total, int? ttl}) async { final String apiPath = '/presences'; - final Map apiParams = { - if (queries != null) 'queries': queries, - if (total != null) 'total': total, - if (ttl != null) 'ttl': ttl, - }; + final Map apiParams = { + if (queries != null) 'queries': queries, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + if (total != null) 'total': total, - final res = await client.call(HttpMethod.get, - path: apiPath, params: apiParams, headers: apiHeaders); + if (ttl != null) 'ttl': ttl, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.PresenceList.fromMap(res.data); - return models.PresenceList.fromMap(res.data); } /// Get a presence log by its unique ID. Entries whose `expiresAt` is in the /// past are treated as not found. - /// + /// Future get({required String presenceId}) async { - final String apiPath = - '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); + final String apiPath = '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); - final Map apiParams = {}; + final Map apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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.Presence.fromMap(res.data); - return models.Presence.fromMap(res.data); } /// Create or update a presence log by its user ID. - /// - Future upsert( - {required String presenceId, - required String status, - List? permissions, - String? expiresAt, - Map? metadata}) async { - final String apiPath = - '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); - - final Map apiParams = { - 'status': status, - if (permissions != null) 'permissions': permissions, - if (expiresAt != null) 'expiresAt': expiresAt, - if (metadata != null) 'metadata': metadata, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.put, - path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Presence.fromMap(res.data); + /// + Future upsert({required String presenceId, required String status, List? permissions, String? expiresAt, Map? metadata}) async { + final String apiPath = '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); + + final Map apiParams = { + 'status': status, + + if (permissions != null) 'permissions': permissions, + + if (expiresAt != null) 'expiresAt': expiresAt, + + if (metadata != null) 'metadata': metadata, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Presence.fromMap(res.data); + } /// Update a presence log by its unique ID. Using the patch method you can pass /// only specific fields that will get updated. - /// - Future update( - {required String presenceId, - String? status, - String? expiresAt, - Map? metadata, - List? permissions, - bool? purge}) async { - final String apiPath = - '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); - - final Map apiParams = { - if (status != null) 'status': status, - if (expiresAt != null) 'expiresAt': expiresAt, - if (metadata != null) 'metadata': metadata, - if (permissions != null) 'permissions': permissions, - if (purge != null) 'purge': purge, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, - path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Presence.fromMap(res.data); + /// + Future update({required String presenceId, String? status, String? expiresAt, Map? metadata, List? permissions, bool? purge}) async { + final String apiPath = '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); + + final Map apiParams = { + if (status != null) 'status': status, + + if (expiresAt != null) 'expiresAt': expiresAt, + + if (metadata != null) 'metadata': metadata, + + if (permissions != null) 'permissions': permissions, + + if (purge != null) 'purge': purge, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Presence.fromMap(res.data); + } /// Delete a presence log by its unique ID. - /// + /// Future delete({required String presenceId}) async { - final String apiPath = - '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); + final String apiPath = '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); + + final Map apiParams = { + }; - final Map apiParams = {}; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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; } } diff --git a/lib/services/storage.dart b/lib/services/storage.dart index cdb626de..c9499a99 100644 --- a/lib/services/storage.dart +++ b/lib/services/storage.dart @@ -1,178 +1,166 @@ 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, - bool? total}) async { - final String apiPath = - '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - if (search != null) 'search': search, - if (total != null) 'total': total, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, bool? total}) async { + final String apiPath = '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + + if (search != null) 'search': search, + + if (total != null) 'total': total, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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, - if (permissions != null) 'permissions': permissions, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'multipart/form-data', - 'accept': 'application/json', - }; - - 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, + + if (permissions != null) 'permissions': permissions, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'multipart/form-data', 'accept': 'application/json', + }; + + 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); + 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 apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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.File.fromMap(res.data); - 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 = { - if (name != null) 'name': name, - 'permissions': permissions, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 = { + if (name != null) 'name': name, + + 'permissions': permissions, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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 = { - if (token != null) 'token': token, - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + + if (token != null) 'token': token, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 @@ -180,64 +168,60 @@ 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 = { - if (width != null) 'width': width, - if (height != null) 'height': height, - if (gravity != null) 'gravity': gravity.value, - if (quality != null) 'quality': quality, - if (borderWidth != null) 'borderWidth': borderWidth, - if (borderColor != null) 'borderColor': borderColor, - if (borderRadius != null) 'borderRadius': borderRadius, - if (opacity != null) 'opacity': opacity, - if (rotation != null) 'rotation': rotation, - if (background != null) 'background': background, - if (output != null) 'output': output.value, - if (token != null) 'token': token, - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + + if (width != null) 'width': width, + + if (height != null) 'height': height, + + if (gravity != null) 'gravity': gravity.value, + + if (quality != null) 'quality': quality, + + if (borderWidth != null) 'borderWidth': borderWidth, + + if (borderColor != null) 'borderColor': borderColor, + + if (borderRadius != null) 'borderRadius': borderRadius, + + if (opacity != null) 'opacity': opacity, + + if (rotation != null) 'rotation': rotation, + + if (background != null) 'background': background, + + if (output != null) 'output': output.value, + + if (token != null) 'token': token, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 = { - if (token != null) 'token': token, - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + + if (token != null) 'token': token, + + + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } } diff --git a/lib/services/tables_db.dart b/lib/services/tables_db.dart index 8b6284b3..42572021 100644 --- a/lib/services/tables_db.dart +++ b/lib/services/tables_db.dart @@ -5,382 +5,319 @@ class TablesDB extends Service { TablesDB(super.client); /// List transactions across all databases. - Future listTransactions( - {List? queries}) async { + Future listTransactions({List? queries}) async { final String apiPath = '/tablesdb/transactions'; - final Map apiParams = { - if (queries != null) 'queries': queries, - }; + final Map apiParams = { + if (queries != null) 'queries': queries, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + }; - final res = await client.call(HttpMethod.get, - path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.TransactionList.fromMap(res.data); - return models.TransactionList.fromMap(res.data); } /// Create a new transaction. Future createTransaction({int? ttl}) async { final String apiPath = '/tablesdb/transactions'; - final Map apiParams = { - if (ttl != null) 'ttl': ttl, - }; + final Map apiParams = { + if (ttl != null) 'ttl': ttl, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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.Transaction.fromMap(res.data); - return models.Transaction.fromMap(res.data); } /// Get a transaction by its unique ID. - Future getTransaction( - {required String transactionId}) async { - final String apiPath = '/tablesdb/transactions/{transactionId}' - .replaceAll('{transactionId}', transactionId); + Future getTransaction({required String transactionId}) async { + final String apiPath = '/tablesdb/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + }; - final Map apiParams = {}; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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.Transaction.fromMap(res.data); - return models.Transaction.fromMap(res.data); } /// Update a transaction, to either commit or roll back its operations. - Future updateTransaction( - {required String transactionId, bool? commit, bool? rollback}) async { - final String apiPath = '/tablesdb/transactions/{transactionId}' - .replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - if (commit != null) 'commit': commit, - if (rollback != null) 'rollback': rollback, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, - path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Transaction.fromMap(res.data); + Future updateTransaction({required String transactionId, bool? commit, bool? rollback}) async { + final String apiPath = '/tablesdb/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + if (commit != null) 'commit': commit, + + if (rollback != null) 'rollback': rollback, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Transaction.fromMap(res.data); + } /// Delete a transaction by its unique ID. Future deleteTransaction({required String transactionId}) async { - final String apiPath = '/tablesdb/transactions/{transactionId}' - .replaceAll('{transactionId}', transactionId); + final String apiPath = '/tablesdb/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + }; - final Map apiParams = {}; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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; } /// Create multiple operations in a single transaction. - Future createOperations( - {required String transactionId, List? operations}) async { - final String apiPath = '/tablesdb/transactions/{transactionId}/operations' - .replaceAll('{transactionId}', transactionId); + Future createOperations({required String transactionId, List? operations}) async { + final String apiPath = '/tablesdb/transactions/{transactionId}/operations'.replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + if (operations != null) 'operations': operations, + + }; - final Map apiParams = { - if (operations != null) 'operations': operations, - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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.Transaction.fromMap(res.data); - return models.Transaction.fromMap(res.data); } /// 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, - String? transactionId, - bool? total, - int? ttl}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - if (transactionId != null) 'transactionId': transactionId, - if (total != null) 'total': total, - if (ttl != null) 'ttl': ttl, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, String? transactionId, bool? total, int? ttl}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + + if (transactionId != null) 'transactionId': transactionId, + + if (total != null) 'total': total, + + if (ttl != null) 'ttl': ttl, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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/references/cloud/server-dart/tablesDB#createTable) /// API or directly from your database console. - Future createRow( - {required String databaseId, - required String tableId, - required String rowId, - required Map data, - List? permissions, - String? transactionId}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId); - - final Map apiParams = { - 'rowId': rowId, - 'data': data, - 'permissions': permissions, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, String? transactionId}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); + + final Map apiParams = { + 'rowId': rowId, + + 'data': data, + + 'permissions': permissions, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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, - String? transactionId}) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - if (transactionId != null) 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, String? transactionId}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + + if (transactionId != null) 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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/references/cloud/server-dart/tablesDB#createTable) /// API or directly from your database console. - Future upsertRow( - {required String databaseId, - required String tableId, - required String rowId, - Map? data, - List? permissions, - String? transactionId}) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); - - final Map apiParams = { - if (data != null) 'data': data, - 'permissions': permissions, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, String? transactionId}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); + + final Map apiParams = { + if (data != null) 'data': data, + + 'permissions': permissions, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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, - String? transactionId}) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); - - final Map apiParams = { - if (data != null) 'data': data, - 'permissions': permissions, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, String? transactionId}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); + + final Map apiParams = { + if (data != null) 'data': data, + + 'permissions': permissions, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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, - String? transactionId}) async { - final String apiPath = - '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .replaceAll('{databaseId}', databaseId) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); - - final Map apiParams = { - if (transactionId != null) 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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, String? transactionId}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); + + final Map apiParams = { + if (transactionId != null) 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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, - String? transactionId}) 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 = { - if (value != null) 'value': value, - 'min': min, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, String? transactionId}) 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 = { + if (value != null) 'value': value, + + 'min': min, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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, - String? transactionId}) 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 = { - if (value != null) 'value': value, - 'max': max, - 'transactionId': transactionId, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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, String? transactionId}) 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 = { + if (value != null) 'value': value, + + 'max': max, + + 'transactionId': transactionId, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); + } } diff --git a/lib/services/teams.dart b/lib/services/teams.dart index 1f4022f6..27bc561e 100644 --- a/lib/services/teams.dart +++ b/lib/services/teams.dart @@ -1,97 +1,98 @@ 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); /// Get a list of all the teams in which the current user is a member. You can /// use the parameters to filter your results. - Future list( - {List? queries, String? search, bool? total}) async { + Future list({List? queries, String? search, bool? total}) async { final String apiPath = '/teams'; - final Map apiParams = { - if (queries != null) 'queries': queries, - if (search != null) 'search': search, - if (total != null) 'total': total, - }; + final Map apiParams = { + if (queries != null) 'queries': queries, - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + if (search != null) 'search': search, - final res = await client.call(HttpMethod.get, - path: apiPath, params: apiParams, headers: apiHeaders); + if (total != null) 'total': total, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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 { final String apiPath = '/teams'; - final Map apiParams = { - 'teamId': teamId, - 'name': name, - if (roles != null) 'roles': roles, - }; + final Map apiParams = { + 'teamId': teamId, + + 'name': name, + + if (roles != null) 'roles': roles, + + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 @@ -99,45 +100,44 @@ 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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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, - bool? total}) async { - final String apiPath = - '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - if (search != null) 'search': search, - if (total != null) 'total': total, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, bool? total}) async { + final String apiPath = '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + + if (search != null) 'search': search, + + if (total != null) 'total': total, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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 @@ -146,199 +146,180 @@ 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 = { - if (email != null) 'email': email, - if (userId != null) 'userId': userId, - if (phone != null) 'phone': phone, - 'roles': roles, - if (url != null) 'url': url, - if (name != null) 'name': name, - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 = { + if (email != null) 'email': email, + + if (userId != null) 'userId': userId, + + if (phone != null) 'phone': phone, + + 'roles': roles, + + if (url != null) 'url': url, + + if (name != null) 'name': name, + + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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); + 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 apiParams = { + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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.Membership.fromMap(res.data); - 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': '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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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); + 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 apiParams = { - 'prefs': prefs, - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - 'accept': '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.Preferences.fromMap(res.data); - return models.Preferences.fromMap(res.data); } } diff --git a/lib/src/client.dart b/lib/src/client.dart index cc077e56..65b2f044 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -27,8 +27,7 @@ abstract class Client { factory Client({ String endPoint = 'https://cloud.appwrite.io/v1', bool selfSigned = false, - }) => - createClient(endPoint: endPoint, selfSigned: selfSigned); + }) => createClient(endPoint: endPoint, selfSigned: selfSigned); /// Handle OAuth2 session creation. Future webAuth(Uri url, {String? callbackUrlScheme}); @@ -108,6 +107,7 @@ abstract class Client { /// Send a ping to project as part of onboarding. Future ping(); + /// Send the API request. Future call( HttpMethod method, { diff --git a/lib/src/client_base.dart b/lib/src/client_base.dart index da1a5225..9e964a79 100644 --- a/lib/src/client_base.dart +++ b/lib/src/client_base.dart @@ -6,33 +6,26 @@ 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); - /// The user cookie to authenticate with. Used by SDKs that forward an incoming Cookie header in server-side runtimes. @override ClientBase setCookie(value); - /// Impersonate a user by ID @override ClientBase setImpersonateUserId(value); - /// Impersonate a user by email @override ClientBase setImpersonateUserEmail(value); - /// Impersonate a user by phone @override ClientBase setImpersonateUserPhone(value); diff --git a/lib/src/client_browser.dart b/lib/src/client_browser.dart index 32945efd..2f4c7b48 100644 --- a/lib/src/client_browser.dart +++ b/lib/src/client_browser.dart @@ -62,7 +62,6 @@ class ClientBrowser extends ClientBase with ClientMixin { config['project'] = value; return this; } - /// Your secret JSON Web Token @override ClientBrowser setJWT(value) { @@ -70,14 +69,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) { @@ -85,7 +82,6 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Session', value); return this; } - /// Your secret dev API key @override ClientBrowser setDevKey(value) { @@ -93,7 +89,6 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Dev-Key', value); return this; } - /// The user cookie to authenticate with. Used by SDKs that forward an incoming Cookie header in server-side runtimes. @override ClientBrowser setCookie(value) { @@ -101,7 +96,6 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('Cookie', value); return this; } - /// Impersonate a user by ID @override ClientBrowser setImpersonateUserId(value) { @@ -109,7 +103,6 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Impersonate-User-Id', value); return this; } - /// Impersonate a user by email @override ClientBrowser setImpersonateUserEmail(value) { @@ -117,7 +110,6 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Impersonate-User-Email', value); return this; } - /// Impersonate a user by phone @override ClientBrowser setImpersonateUserPhone(value) { @@ -227,8 +219,7 @@ class ClientBrowser extends ClientBase with ClientMixin { final totalChunks = (size / chunkSize).ceil(); - Future uploadChunk( - int index, int start, int end, String? id) async { + Future uploadChunk(int index, int start, int end, String? id) async { List chunk = []; chunk = file.bytes!.getRange(start, end).toList(); @@ -266,9 +257,7 @@ class ClientBrowser extends ClientBase with ClientMixin { bool isUploadComplete(Response response) { final chunksUploaded = response.data['chunksUploaded']; final chunksTotal = response.data['chunksTotal'] ?? totalChunks; - return chunksUploaded is num && - chunksTotal is num && - chunksUploaded >= chunksTotal; + return chunksUploaded is num && chunksTotal is num && chunksUploaded >= chunksTotal; } final progress = UploadProgress( diff --git a/lib/src/client_io.dart b/lib/src/client_io.dart index 78a368ae..6e6e2ee8 100644 --- a/lib/src/client_io.dart +++ b/lib/src/client_io.dart @@ -88,7 +88,6 @@ class ClientIO extends ClientBase with ClientMixin { config['project'] = value; return this; } - /// Your secret JSON Web Token @override ClientIO setJWT(value) { @@ -96,14 +95,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) { @@ -111,7 +108,6 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Session', value); return this; } - /// Your secret dev API key @override ClientIO setDevKey(value) { @@ -119,7 +115,6 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Dev-Key', value); return this; } - /// The user cookie to authenticate with. Used by SDKs that forward an incoming Cookie header in server-side runtimes. @override ClientIO setCookie(value) { @@ -127,7 +122,6 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('Cookie', value); return this; } - /// Impersonate a user by ID @override ClientIO setImpersonateUserId(value) { @@ -135,7 +129,6 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Impersonate-User-Id', value); return this; } - /// Impersonate a user by email @override ClientIO setImpersonateUserEmail(value) { @@ -143,7 +136,6 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Impersonate-User-Email', value); return this; } - /// Impersonate a user by phone @override ClientIO setImpersonateUserPhone(value) { @@ -402,9 +394,7 @@ class ClientIO extends ClientBase with ClientMixin { bool isUploadComplete(Response response) { final chunksUploaded = response.data['chunksUploaded']; final chunksTotal = response.data['chunksTotal'] ?? totalChunks; - return chunksUploaded is num && - chunksTotal is num && - chunksUploaded >= chunksTotal; + return chunksUploaded is num && chunksTotal is num && chunksUploaded >= chunksTotal; } final progress = UploadProgress( @@ -428,8 +418,7 @@ class ClientIO extends ClientBase with ClientMixin { var nextChunk = 0; Future uploadNext() async { - final raf = - file.bytes == null ? await iofile!.open(mode: FileMode.read) : null; + final raf = file.bytes == null ? await iofile!.open(mode: FileMode.read) : null; try { while (nextChunk < chunks.length) { final chunk = chunks[nextChunk++]; diff --git a/lib/src/client_mixin.dart b/lib/src/client_mixin.dart index 89aad359..40484946 100644 --- a/lib/src/client_mixin.dart +++ b/lib/src/client_mixin.dart @@ -12,6 +12,7 @@ mixin ClientMixin { required Map headers, required Map params, }) { + http.BaseRequest request = http.Request(method.name(), uri); if (headers['content-type'] == 'multipart/form-data') { request = http.MultipartRequest(method.name(), uri); @@ -127,13 +128,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/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/browser_permission.dart b/lib/src/enums/browser_permission.dart index fb4983db..765b3e0c 100644 --- a/lib/src/enums/browser_permission.dart +++ b/lib/src/enums/browser_permission.dart @@ -1,30 +1,32 @@ part of '../../enums.dart'; enum BrowserPermission { - geolocation(value: 'geolocation'), - camera(value: 'camera'), - microphone(value: 'microphone'), - notifications(value: 'notifications'), - midi(value: 'midi'), - push(value: 'push'), - clipboardRead(value: 'clipboard-read'), - clipboardWrite(value: 'clipboard-write'), - paymentHandler(value: 'payment-handler'), - usb(value: 'usb'), - bluetooth(value: 'bluetooth'), - accelerometer(value: 'accelerometer'), - gyroscope(value: 'gyroscope'), - magnetometer(value: 'magnetometer'), - ambientLightSensor(value: 'ambient-light-sensor'), - backgroundSync(value: 'background-sync'), - persistentStorage(value: 'persistent-storage'), - screenWakeLock(value: 'screen-wake-lock'), - webShare(value: 'web-share'), - xrSpatialTracking(value: 'xr-spatial-tracking'); + geolocation(value: 'geolocation'), + camera(value: 'camera'), + microphone(value: 'microphone'), + notifications(value: 'notifications'), + midi(value: 'midi'), + push(value: 'push'), + clipboardRead(value: 'clipboard-read'), + clipboardWrite(value: 'clipboard-write'), + paymentHandler(value: 'payment-handler'), + usb(value: 'usb'), + bluetooth(value: 'bluetooth'), + accelerometer(value: 'accelerometer'), + gyroscope(value: 'gyroscope'), + magnetometer(value: 'magnetometer'), + ambientLightSensor(value: 'ambient-light-sensor'), + backgroundSync(value: 'background-sync'), + persistentStorage(value: 'persistent-storage'), + screenWakeLock(value: 'screen-wake-lock'), + webShare(value: 'web-share'), + xrSpatialTracking(value: 'xr-spatial-tracking'); - const BrowserPermission({required this.value}); + const BrowserPermission({ + 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_theme.dart b/lib/src/enums/browser_theme.dart index 1e059c2c..e81a0f68 100644 --- a/lib/src/enums/browser_theme.dart +++ b/lib/src/enums/browser_theme.dart @@ -1,12 +1,14 @@ part of '../../enums.dart'; enum BrowserTheme { - light(value: 'light'), - dark(value: 'dark'); + light(value: 'light'), + dark(value: 'dark'); - const BrowserTheme({required this.value}); + const BrowserTheme({ + 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/execution_status.dart b/lib/src/enums/execution_status.dart index 7ea9865e..f54859c9 100644 --- a/lib/src/enums/execution_status.dart +++ b/lib/src/enums/execution_status.dart @@ -1,15 +1,17 @@ part of '../../enums.dart'; enum ExecutionStatus { - waiting(value: 'waiting'), - processing(value: 'processing'), - completed(value: 'completed'), - failed(value: 'failed'), - scheduled(value: 'scheduled'); + waiting(value: 'waiting'), + processing(value: 'processing'), + completed(value: 'completed'), + failed(value: 'failed'), + scheduled(value: 'scheduled'); - const ExecutionStatus({required this.value}); + const ExecutionStatus({ + 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_trigger.dart b/lib/src/enums/execution_trigger.dart index fb05eb7d..8a14ae60 100644 --- a/lib/src/enums/execution_trigger.dart +++ b/lib/src/enums/execution_trigger.dart @@ -1,13 +1,15 @@ part of '../../enums.dart'; enum ExecutionTrigger { - http(value: 'http'), - schedule(value: 'schedule'), - event(value: 'event'); + http(value: 'http'), + schedule(value: 'schedule'), + event(value: 'event'); - const ExecutionTrigger({required this.value}); + const ExecutionTrigger({ + 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 b88e0a55..8ed7ecff 100644 --- a/lib/src/enums/o_auth_provider.dart +++ b/lib/src/enums/o_auth_provider.dart @@ -1,53 +1,55 @@ 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'), - fusionauth(value: 'fusionauth'), - github(value: 'github'), - gitlab(value: 'gitlab'), - google(value: 'google'), - keycloak(value: 'keycloak'), - kick(value: 'kick'), - 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'), - x(value: 'x'), - yahoo(value: 'yahoo'), - yammer(value: 'yammer'), - yandex(value: 'yandex'), - zoho(value: 'zoho'), - zoom(value: 'zoom'); + 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'), + fusionauth(value: 'fusionauth'), + github(value: 'github'), + gitlab(value: 'gitlab'), + google(value: 'google'), + keycloak(value: 'keycloak'), + kick(value: 'kick'), + 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'), + x(value: 'x'), + yahoo(value: 'yahoo'), + yammer(value: 'yammer'), + yandex(value: 'yandex'), + zoho(value: 'zoho'), + zoom(value: 'zoom'); - 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/enums/timezone.dart b/lib/src/enums/timezone.dart index d5d8d94a..4a8de1ce 100644 --- a/lib/src/enums/timezone.dart +++ b/lib/src/enums/timezone.dart @@ -1,429 +1,431 @@ part of '../../enums.dart'; enum Timezone { - africaAbidjan(value: 'africa/abidjan'), - africaAccra(value: 'africa/accra'), - africaAddisAbaba(value: 'africa/addis_ababa'), - africaAlgiers(value: 'africa/algiers'), - africaAsmara(value: 'africa/asmara'), - africaBamako(value: 'africa/bamako'), - africaBangui(value: 'africa/bangui'), - africaBanjul(value: 'africa/banjul'), - africaBissau(value: 'africa/bissau'), - africaBlantyre(value: 'africa/blantyre'), - africaBrazzaville(value: 'africa/brazzaville'), - africaBujumbura(value: 'africa/bujumbura'), - africaCairo(value: 'africa/cairo'), - africaCasablanca(value: 'africa/casablanca'), - africaCeuta(value: 'africa/ceuta'), - africaConakry(value: 'africa/conakry'), - africaDakar(value: 'africa/dakar'), - africaDarEsSalaam(value: 'africa/dar_es_salaam'), - africaDjibouti(value: 'africa/djibouti'), - africaDouala(value: 'africa/douala'), - africaElAaiun(value: 'africa/el_aaiun'), - africaFreetown(value: 'africa/freetown'), - africaGaborone(value: 'africa/gaborone'), - africaHarare(value: 'africa/harare'), - africaJohannesburg(value: 'africa/johannesburg'), - africaJuba(value: 'africa/juba'), - africaKampala(value: 'africa/kampala'), - africaKhartoum(value: 'africa/khartoum'), - africaKigali(value: 'africa/kigali'), - africaKinshasa(value: 'africa/kinshasa'), - africaLagos(value: 'africa/lagos'), - africaLibreville(value: 'africa/libreville'), - africaLome(value: 'africa/lome'), - africaLuanda(value: 'africa/luanda'), - africaLubumbashi(value: 'africa/lubumbashi'), - africaLusaka(value: 'africa/lusaka'), - africaMalabo(value: 'africa/malabo'), - africaMaputo(value: 'africa/maputo'), - africaMaseru(value: 'africa/maseru'), - africaMbabane(value: 'africa/mbabane'), - africaMogadishu(value: 'africa/mogadishu'), - africaMonrovia(value: 'africa/monrovia'), - africaNairobi(value: 'africa/nairobi'), - africaNdjamena(value: 'africa/ndjamena'), - africaNiamey(value: 'africa/niamey'), - africaNouakchott(value: 'africa/nouakchott'), - africaOuagadougou(value: 'africa/ouagadougou'), - africaPortoNovo(value: 'africa/porto-novo'), - africaSaoTome(value: 'africa/sao_tome'), - africaTripoli(value: 'africa/tripoli'), - africaTunis(value: 'africa/tunis'), - africaWindhoek(value: 'africa/windhoek'), - americaAdak(value: 'america/adak'), - americaAnchorage(value: 'america/anchorage'), - americaAnguilla(value: 'america/anguilla'), - americaAntigua(value: 'america/antigua'), - americaAraguaina(value: 'america/araguaina'), - americaArgentinaBuenosAires(value: 'america/argentina/buenos_aires'), - americaArgentinaCatamarca(value: 'america/argentina/catamarca'), - americaArgentinaCordoba(value: 'america/argentina/cordoba'), - americaArgentinaJujuy(value: 'america/argentina/jujuy'), - americaArgentinaLaRioja(value: 'america/argentina/la_rioja'), - americaArgentinaMendoza(value: 'america/argentina/mendoza'), - americaArgentinaRioGallegos(value: 'america/argentina/rio_gallegos'), - americaArgentinaSalta(value: 'america/argentina/salta'), - americaArgentinaSanJuan(value: 'america/argentina/san_juan'), - americaArgentinaSanLuis(value: 'america/argentina/san_luis'), - americaArgentinaTucuman(value: 'america/argentina/tucuman'), - americaArgentinaUshuaia(value: 'america/argentina/ushuaia'), - americaAruba(value: 'america/aruba'), - americaAsuncion(value: 'america/asuncion'), - americaAtikokan(value: 'america/atikokan'), - americaBahia(value: 'america/bahia'), - americaBahiaBanderas(value: 'america/bahia_banderas'), - americaBarbados(value: 'america/barbados'), - americaBelem(value: 'america/belem'), - americaBelize(value: 'america/belize'), - americaBlancSablon(value: 'america/blanc-sablon'), - americaBoaVista(value: 'america/boa_vista'), - americaBogota(value: 'america/bogota'), - americaBoise(value: 'america/boise'), - americaCambridgeBay(value: 'america/cambridge_bay'), - americaCampoGrande(value: 'america/campo_grande'), - americaCancun(value: 'america/cancun'), - americaCaracas(value: 'america/caracas'), - americaCayenne(value: 'america/cayenne'), - americaCayman(value: 'america/cayman'), - americaChicago(value: 'america/chicago'), - americaChihuahua(value: 'america/chihuahua'), - americaCiudadJuarez(value: 'america/ciudad_juarez'), - americaCostaRica(value: 'america/costa_rica'), - americaCoyhaique(value: 'america/coyhaique'), - americaCreston(value: 'america/creston'), - americaCuiaba(value: 'america/cuiaba'), - americaCuracao(value: 'america/curacao'), - americaDanmarkshavn(value: 'america/danmarkshavn'), - americaDawson(value: 'america/dawson'), - americaDawsonCreek(value: 'america/dawson_creek'), - americaDenver(value: 'america/denver'), - americaDetroit(value: 'america/detroit'), - americaDominica(value: 'america/dominica'), - americaEdmonton(value: 'america/edmonton'), - americaEirunepe(value: 'america/eirunepe'), - americaElSalvador(value: 'america/el_salvador'), - americaFortNelson(value: 'america/fort_nelson'), - americaFortaleza(value: 'america/fortaleza'), - americaGlaceBay(value: 'america/glace_bay'), - americaGooseBay(value: 'america/goose_bay'), - americaGrandTurk(value: 'america/grand_turk'), - americaGrenada(value: 'america/grenada'), - americaGuadeloupe(value: 'america/guadeloupe'), - americaGuatemala(value: 'america/guatemala'), - americaGuayaquil(value: 'america/guayaquil'), - americaGuyana(value: 'america/guyana'), - americaHalifax(value: 'america/halifax'), - americaHavana(value: 'america/havana'), - americaHermosillo(value: 'america/hermosillo'), - americaIndianaIndianapolis(value: 'america/indiana/indianapolis'), - americaIndianaKnox(value: 'america/indiana/knox'), - americaIndianaMarengo(value: 'america/indiana/marengo'), - americaIndianaPetersburg(value: 'america/indiana/petersburg'), - americaIndianaTellCity(value: 'america/indiana/tell_city'), - americaIndianaVevay(value: 'america/indiana/vevay'), - americaIndianaVincennes(value: 'america/indiana/vincennes'), - americaIndianaWinamac(value: 'america/indiana/winamac'), - americaInuvik(value: 'america/inuvik'), - americaIqaluit(value: 'america/iqaluit'), - americaJamaica(value: 'america/jamaica'), - americaJuneau(value: 'america/juneau'), - americaKentuckyLouisville(value: 'america/kentucky/louisville'), - americaKentuckyMonticello(value: 'america/kentucky/monticello'), - americaKralendijk(value: 'america/kralendijk'), - americaLaPaz(value: 'america/la_paz'), - americaLima(value: 'america/lima'), - americaLosAngeles(value: 'america/los_angeles'), - americaLowerPrinces(value: 'america/lower_princes'), - americaMaceio(value: 'america/maceio'), - americaManagua(value: 'america/managua'), - americaManaus(value: 'america/manaus'), - americaMarigot(value: 'america/marigot'), - americaMartinique(value: 'america/martinique'), - americaMatamoros(value: 'america/matamoros'), - americaMazatlan(value: 'america/mazatlan'), - americaMenominee(value: 'america/menominee'), - americaMerida(value: 'america/merida'), - americaMetlakatla(value: 'america/metlakatla'), - americaMexicoCity(value: 'america/mexico_city'), - americaMiquelon(value: 'america/miquelon'), - americaMoncton(value: 'america/moncton'), - americaMonterrey(value: 'america/monterrey'), - americaMontevideo(value: 'america/montevideo'), - americaMontserrat(value: 'america/montserrat'), - americaNassau(value: 'america/nassau'), - americaNewYork(value: 'america/new_york'), - americaNome(value: 'america/nome'), - americaNoronha(value: 'america/noronha'), - americaNorthDakotaBeulah(value: 'america/north_dakota/beulah'), - americaNorthDakotaCenter(value: 'america/north_dakota/center'), - americaNorthDakotaNewSalem(value: 'america/north_dakota/new_salem'), - americaNuuk(value: 'america/nuuk'), - americaOjinaga(value: 'america/ojinaga'), - americaPanama(value: 'america/panama'), - americaParamaribo(value: 'america/paramaribo'), - americaPhoenix(value: 'america/phoenix'), - americaPortAuPrince(value: 'america/port-au-prince'), - americaPortOfSpain(value: 'america/port_of_spain'), - americaPortoVelho(value: 'america/porto_velho'), - americaPuertoRico(value: 'america/puerto_rico'), - americaPuntaArenas(value: 'america/punta_arenas'), - americaRankinInlet(value: 'america/rankin_inlet'), - americaRecife(value: 'america/recife'), - americaRegina(value: 'america/regina'), - americaResolute(value: 'america/resolute'), - americaRioBranco(value: 'america/rio_branco'), - americaSantarem(value: 'america/santarem'), - americaSantiago(value: 'america/santiago'), - americaSantoDomingo(value: 'america/santo_domingo'), - americaSaoPaulo(value: 'america/sao_paulo'), - americaScoresbysund(value: 'america/scoresbysund'), - americaSitka(value: 'america/sitka'), - americaStBarthelemy(value: 'america/st_barthelemy'), - americaStJohns(value: 'america/st_johns'), - americaStKitts(value: 'america/st_kitts'), - americaStLucia(value: 'america/st_lucia'), - americaStThomas(value: 'america/st_thomas'), - americaStVincent(value: 'america/st_vincent'), - americaSwiftCurrent(value: 'america/swift_current'), - americaTegucigalpa(value: 'america/tegucigalpa'), - americaThule(value: 'america/thule'), - americaTijuana(value: 'america/tijuana'), - americaToronto(value: 'america/toronto'), - americaTortola(value: 'america/tortola'), - americaVancouver(value: 'america/vancouver'), - americaWhitehorse(value: 'america/whitehorse'), - americaWinnipeg(value: 'america/winnipeg'), - americaYakutat(value: 'america/yakutat'), - antarcticaCasey(value: 'antarctica/casey'), - antarcticaDavis(value: 'antarctica/davis'), - antarcticaDumontdurville(value: 'antarctica/dumontdurville'), - antarcticaMacquarie(value: 'antarctica/macquarie'), - antarcticaMawson(value: 'antarctica/mawson'), - antarcticaMcmurdo(value: 'antarctica/mcmurdo'), - antarcticaPalmer(value: 'antarctica/palmer'), - antarcticaRothera(value: 'antarctica/rothera'), - antarcticaSyowa(value: 'antarctica/syowa'), - antarcticaTroll(value: 'antarctica/troll'), - antarcticaVostok(value: 'antarctica/vostok'), - arcticLongyearbyen(value: 'arctic/longyearbyen'), - asiaAden(value: 'asia/aden'), - asiaAlmaty(value: 'asia/almaty'), - asiaAmman(value: 'asia/amman'), - asiaAnadyr(value: 'asia/anadyr'), - asiaAqtau(value: 'asia/aqtau'), - asiaAqtobe(value: 'asia/aqtobe'), - asiaAshgabat(value: 'asia/ashgabat'), - asiaAtyrau(value: 'asia/atyrau'), - asiaBaghdad(value: 'asia/baghdad'), - asiaBahrain(value: 'asia/bahrain'), - asiaBaku(value: 'asia/baku'), - asiaBangkok(value: 'asia/bangkok'), - asiaBarnaul(value: 'asia/barnaul'), - asiaBeirut(value: 'asia/beirut'), - asiaBishkek(value: 'asia/bishkek'), - asiaBrunei(value: 'asia/brunei'), - asiaChita(value: 'asia/chita'), - asiaColombo(value: 'asia/colombo'), - asiaDamascus(value: 'asia/damascus'), - asiaDhaka(value: 'asia/dhaka'), - asiaDili(value: 'asia/dili'), - asiaDubai(value: 'asia/dubai'), - asiaDushanbe(value: 'asia/dushanbe'), - asiaFamagusta(value: 'asia/famagusta'), - asiaGaza(value: 'asia/gaza'), - asiaHebron(value: 'asia/hebron'), - asiaHoChiMinh(value: 'asia/ho_chi_minh'), - asiaHongKong(value: 'asia/hong_kong'), - asiaHovd(value: 'asia/hovd'), - asiaIrkutsk(value: 'asia/irkutsk'), - asiaJakarta(value: 'asia/jakarta'), - asiaJayapura(value: 'asia/jayapura'), - asiaJerusalem(value: 'asia/jerusalem'), - asiaKabul(value: 'asia/kabul'), - asiaKamchatka(value: 'asia/kamchatka'), - asiaKarachi(value: 'asia/karachi'), - asiaKathmandu(value: 'asia/kathmandu'), - asiaKhandyga(value: 'asia/khandyga'), - asiaKolkata(value: 'asia/kolkata'), - asiaKrasnoyarsk(value: 'asia/krasnoyarsk'), - asiaKualaLumpur(value: 'asia/kuala_lumpur'), - asiaKuching(value: 'asia/kuching'), - asiaKuwait(value: 'asia/kuwait'), - asiaMacau(value: 'asia/macau'), - asiaMagadan(value: 'asia/magadan'), - asiaMakassar(value: 'asia/makassar'), - asiaManila(value: 'asia/manila'), - asiaMuscat(value: 'asia/muscat'), - asiaNicosia(value: 'asia/nicosia'), - asiaNovokuznetsk(value: 'asia/novokuznetsk'), - asiaNovosibirsk(value: 'asia/novosibirsk'), - asiaOmsk(value: 'asia/omsk'), - asiaOral(value: 'asia/oral'), - asiaPhnomPenh(value: 'asia/phnom_penh'), - asiaPontianak(value: 'asia/pontianak'), - asiaPyongyang(value: 'asia/pyongyang'), - asiaQatar(value: 'asia/qatar'), - asiaQostanay(value: 'asia/qostanay'), - asiaQyzylorda(value: 'asia/qyzylorda'), - asiaRiyadh(value: 'asia/riyadh'), - asiaSakhalin(value: 'asia/sakhalin'), - asiaSamarkand(value: 'asia/samarkand'), - asiaSeoul(value: 'asia/seoul'), - asiaShanghai(value: 'asia/shanghai'), - asiaSingapore(value: 'asia/singapore'), - asiaSrednekolymsk(value: 'asia/srednekolymsk'), - asiaTaipei(value: 'asia/taipei'), - asiaTashkent(value: 'asia/tashkent'), - asiaTbilisi(value: 'asia/tbilisi'), - asiaTehran(value: 'asia/tehran'), - asiaThimphu(value: 'asia/thimphu'), - asiaTokyo(value: 'asia/tokyo'), - asiaTomsk(value: 'asia/tomsk'), - asiaUlaanbaatar(value: 'asia/ulaanbaatar'), - asiaUrumqi(value: 'asia/urumqi'), - asiaUstNera(value: 'asia/ust-nera'), - asiaVientiane(value: 'asia/vientiane'), - asiaVladivostok(value: 'asia/vladivostok'), - asiaYakutsk(value: 'asia/yakutsk'), - asiaYangon(value: 'asia/yangon'), - asiaYekaterinburg(value: 'asia/yekaterinburg'), - asiaYerevan(value: 'asia/yerevan'), - atlanticAzores(value: 'atlantic/azores'), - atlanticBermuda(value: 'atlantic/bermuda'), - atlanticCanary(value: 'atlantic/canary'), - atlanticCapeVerde(value: 'atlantic/cape_verde'), - atlanticFaroe(value: 'atlantic/faroe'), - atlanticMadeira(value: 'atlantic/madeira'), - atlanticReykjavik(value: 'atlantic/reykjavik'), - atlanticSouthGeorgia(value: 'atlantic/south_georgia'), - atlanticStHelena(value: 'atlantic/st_helena'), - atlanticStanley(value: 'atlantic/stanley'), - australiaAdelaide(value: 'australia/adelaide'), - australiaBrisbane(value: 'australia/brisbane'), - australiaBrokenHill(value: 'australia/broken_hill'), - australiaDarwin(value: 'australia/darwin'), - australiaEucla(value: 'australia/eucla'), - australiaHobart(value: 'australia/hobart'), - australiaLindeman(value: 'australia/lindeman'), - australiaLordHowe(value: 'australia/lord_howe'), - australiaMelbourne(value: 'australia/melbourne'), - australiaPerth(value: 'australia/perth'), - australiaSydney(value: 'australia/sydney'), - europeAmsterdam(value: 'europe/amsterdam'), - europeAndorra(value: 'europe/andorra'), - europeAstrakhan(value: 'europe/astrakhan'), - europeAthens(value: 'europe/athens'), - europeBelgrade(value: 'europe/belgrade'), - europeBerlin(value: 'europe/berlin'), - europeBratislava(value: 'europe/bratislava'), - europeBrussels(value: 'europe/brussels'), - europeBucharest(value: 'europe/bucharest'), - europeBudapest(value: 'europe/budapest'), - europeBusingen(value: 'europe/busingen'), - europeChisinau(value: 'europe/chisinau'), - europeCopenhagen(value: 'europe/copenhagen'), - europeDublin(value: 'europe/dublin'), - europeGibraltar(value: 'europe/gibraltar'), - europeGuernsey(value: 'europe/guernsey'), - europeHelsinki(value: 'europe/helsinki'), - europeIsleOfMan(value: 'europe/isle_of_man'), - europeIstanbul(value: 'europe/istanbul'), - europeJersey(value: 'europe/jersey'), - europeKaliningrad(value: 'europe/kaliningrad'), - europeKirov(value: 'europe/kirov'), - europeKyiv(value: 'europe/kyiv'), - europeLisbon(value: 'europe/lisbon'), - europeLjubljana(value: 'europe/ljubljana'), - europeLondon(value: 'europe/london'), - europeLuxembourg(value: 'europe/luxembourg'), - europeMadrid(value: 'europe/madrid'), - europeMalta(value: 'europe/malta'), - europeMariehamn(value: 'europe/mariehamn'), - europeMinsk(value: 'europe/minsk'), - europeMonaco(value: 'europe/monaco'), - europeMoscow(value: 'europe/moscow'), - europeOslo(value: 'europe/oslo'), - europeParis(value: 'europe/paris'), - europePodgorica(value: 'europe/podgorica'), - europePrague(value: 'europe/prague'), - europeRiga(value: 'europe/riga'), - europeRome(value: 'europe/rome'), - europeSamara(value: 'europe/samara'), - europeSanMarino(value: 'europe/san_marino'), - europeSarajevo(value: 'europe/sarajevo'), - europeSaratov(value: 'europe/saratov'), - europeSimferopol(value: 'europe/simferopol'), - europeSkopje(value: 'europe/skopje'), - europeSofia(value: 'europe/sofia'), - europeStockholm(value: 'europe/stockholm'), - europeTallinn(value: 'europe/tallinn'), - europeTirane(value: 'europe/tirane'), - europeUlyanovsk(value: 'europe/ulyanovsk'), - europeVaduz(value: 'europe/vaduz'), - europeVatican(value: 'europe/vatican'), - europeVienna(value: 'europe/vienna'), - europeVilnius(value: 'europe/vilnius'), - europeVolgograd(value: 'europe/volgograd'), - europeWarsaw(value: 'europe/warsaw'), - europeZagreb(value: 'europe/zagreb'), - europeZurich(value: 'europe/zurich'), - indianAntananarivo(value: 'indian/antananarivo'), - indianChagos(value: 'indian/chagos'), - indianChristmas(value: 'indian/christmas'), - indianCocos(value: 'indian/cocos'), - indianComoro(value: 'indian/comoro'), - indianKerguelen(value: 'indian/kerguelen'), - indianMahe(value: 'indian/mahe'), - indianMaldives(value: 'indian/maldives'), - indianMauritius(value: 'indian/mauritius'), - indianMayotte(value: 'indian/mayotte'), - indianReunion(value: 'indian/reunion'), - pacificApia(value: 'pacific/apia'), - pacificAuckland(value: 'pacific/auckland'), - pacificBougainville(value: 'pacific/bougainville'), - pacificChatham(value: 'pacific/chatham'), - pacificChuuk(value: 'pacific/chuuk'), - pacificEaster(value: 'pacific/easter'), - pacificEfate(value: 'pacific/efate'), - pacificFakaofo(value: 'pacific/fakaofo'), - pacificFiji(value: 'pacific/fiji'), - pacificFunafuti(value: 'pacific/funafuti'), - pacificGalapagos(value: 'pacific/galapagos'), - pacificGambier(value: 'pacific/gambier'), - pacificGuadalcanal(value: 'pacific/guadalcanal'), - pacificGuam(value: 'pacific/guam'), - pacificHonolulu(value: 'pacific/honolulu'), - pacificKanton(value: 'pacific/kanton'), - pacificKiritimati(value: 'pacific/kiritimati'), - pacificKosrae(value: 'pacific/kosrae'), - pacificKwajalein(value: 'pacific/kwajalein'), - pacificMajuro(value: 'pacific/majuro'), - pacificMarquesas(value: 'pacific/marquesas'), - pacificMidway(value: 'pacific/midway'), - pacificNauru(value: 'pacific/nauru'), - pacificNiue(value: 'pacific/niue'), - pacificNorfolk(value: 'pacific/norfolk'), - pacificNoumea(value: 'pacific/noumea'), - pacificPagoPago(value: 'pacific/pago_pago'), - pacificPalau(value: 'pacific/palau'), - pacificPitcairn(value: 'pacific/pitcairn'), - pacificPohnpei(value: 'pacific/pohnpei'), - pacificPortMoresby(value: 'pacific/port_moresby'), - pacificRarotonga(value: 'pacific/rarotonga'), - pacificSaipan(value: 'pacific/saipan'), - pacificTahiti(value: 'pacific/tahiti'), - pacificTarawa(value: 'pacific/tarawa'), - pacificTongatapu(value: 'pacific/tongatapu'), - pacificWake(value: 'pacific/wake'), - pacificWallis(value: 'pacific/wallis'), - utc(value: 'utc'); + africaAbidjan(value: 'africa/abidjan'), + africaAccra(value: 'africa/accra'), + africaAddisAbaba(value: 'africa/addis_ababa'), + africaAlgiers(value: 'africa/algiers'), + africaAsmara(value: 'africa/asmara'), + africaBamako(value: 'africa/bamako'), + africaBangui(value: 'africa/bangui'), + africaBanjul(value: 'africa/banjul'), + africaBissau(value: 'africa/bissau'), + africaBlantyre(value: 'africa/blantyre'), + africaBrazzaville(value: 'africa/brazzaville'), + africaBujumbura(value: 'africa/bujumbura'), + africaCairo(value: 'africa/cairo'), + africaCasablanca(value: 'africa/casablanca'), + africaCeuta(value: 'africa/ceuta'), + africaConakry(value: 'africa/conakry'), + africaDakar(value: 'africa/dakar'), + africaDarEsSalaam(value: 'africa/dar_es_salaam'), + africaDjibouti(value: 'africa/djibouti'), + africaDouala(value: 'africa/douala'), + africaElAaiun(value: 'africa/el_aaiun'), + africaFreetown(value: 'africa/freetown'), + africaGaborone(value: 'africa/gaborone'), + africaHarare(value: 'africa/harare'), + africaJohannesburg(value: 'africa/johannesburg'), + africaJuba(value: 'africa/juba'), + africaKampala(value: 'africa/kampala'), + africaKhartoum(value: 'africa/khartoum'), + africaKigali(value: 'africa/kigali'), + africaKinshasa(value: 'africa/kinshasa'), + africaLagos(value: 'africa/lagos'), + africaLibreville(value: 'africa/libreville'), + africaLome(value: 'africa/lome'), + africaLuanda(value: 'africa/luanda'), + africaLubumbashi(value: 'africa/lubumbashi'), + africaLusaka(value: 'africa/lusaka'), + africaMalabo(value: 'africa/malabo'), + africaMaputo(value: 'africa/maputo'), + africaMaseru(value: 'africa/maseru'), + africaMbabane(value: 'africa/mbabane'), + africaMogadishu(value: 'africa/mogadishu'), + africaMonrovia(value: 'africa/monrovia'), + africaNairobi(value: 'africa/nairobi'), + africaNdjamena(value: 'africa/ndjamena'), + africaNiamey(value: 'africa/niamey'), + africaNouakchott(value: 'africa/nouakchott'), + africaOuagadougou(value: 'africa/ouagadougou'), + africaPortoNovo(value: 'africa/porto-novo'), + africaSaoTome(value: 'africa/sao_tome'), + africaTripoli(value: 'africa/tripoli'), + africaTunis(value: 'africa/tunis'), + africaWindhoek(value: 'africa/windhoek'), + americaAdak(value: 'america/adak'), + americaAnchorage(value: 'america/anchorage'), + americaAnguilla(value: 'america/anguilla'), + americaAntigua(value: 'america/antigua'), + americaAraguaina(value: 'america/araguaina'), + americaArgentinaBuenosAires(value: 'america/argentina/buenos_aires'), + americaArgentinaCatamarca(value: 'america/argentina/catamarca'), + americaArgentinaCordoba(value: 'america/argentina/cordoba'), + americaArgentinaJujuy(value: 'america/argentina/jujuy'), + americaArgentinaLaRioja(value: 'america/argentina/la_rioja'), + americaArgentinaMendoza(value: 'america/argentina/mendoza'), + americaArgentinaRioGallegos(value: 'america/argentina/rio_gallegos'), + americaArgentinaSalta(value: 'america/argentina/salta'), + americaArgentinaSanJuan(value: 'america/argentina/san_juan'), + americaArgentinaSanLuis(value: 'america/argentina/san_luis'), + americaArgentinaTucuman(value: 'america/argentina/tucuman'), + americaArgentinaUshuaia(value: 'america/argentina/ushuaia'), + americaAruba(value: 'america/aruba'), + americaAsuncion(value: 'america/asuncion'), + americaAtikokan(value: 'america/atikokan'), + americaBahia(value: 'america/bahia'), + americaBahiaBanderas(value: 'america/bahia_banderas'), + americaBarbados(value: 'america/barbados'), + americaBelem(value: 'america/belem'), + americaBelize(value: 'america/belize'), + americaBlancSablon(value: 'america/blanc-sablon'), + americaBoaVista(value: 'america/boa_vista'), + americaBogota(value: 'america/bogota'), + americaBoise(value: 'america/boise'), + americaCambridgeBay(value: 'america/cambridge_bay'), + americaCampoGrande(value: 'america/campo_grande'), + americaCancun(value: 'america/cancun'), + americaCaracas(value: 'america/caracas'), + americaCayenne(value: 'america/cayenne'), + americaCayman(value: 'america/cayman'), + americaChicago(value: 'america/chicago'), + americaChihuahua(value: 'america/chihuahua'), + americaCiudadJuarez(value: 'america/ciudad_juarez'), + americaCostaRica(value: 'america/costa_rica'), + americaCoyhaique(value: 'america/coyhaique'), + americaCreston(value: 'america/creston'), + americaCuiaba(value: 'america/cuiaba'), + americaCuracao(value: 'america/curacao'), + americaDanmarkshavn(value: 'america/danmarkshavn'), + americaDawson(value: 'america/dawson'), + americaDawsonCreek(value: 'america/dawson_creek'), + americaDenver(value: 'america/denver'), + americaDetroit(value: 'america/detroit'), + americaDominica(value: 'america/dominica'), + americaEdmonton(value: 'america/edmonton'), + americaEirunepe(value: 'america/eirunepe'), + americaElSalvador(value: 'america/el_salvador'), + americaFortNelson(value: 'america/fort_nelson'), + americaFortaleza(value: 'america/fortaleza'), + americaGlaceBay(value: 'america/glace_bay'), + americaGooseBay(value: 'america/goose_bay'), + americaGrandTurk(value: 'america/grand_turk'), + americaGrenada(value: 'america/grenada'), + americaGuadeloupe(value: 'america/guadeloupe'), + americaGuatemala(value: 'america/guatemala'), + americaGuayaquil(value: 'america/guayaquil'), + americaGuyana(value: 'america/guyana'), + americaHalifax(value: 'america/halifax'), + americaHavana(value: 'america/havana'), + americaHermosillo(value: 'america/hermosillo'), + americaIndianaIndianapolis(value: 'america/indiana/indianapolis'), + americaIndianaKnox(value: 'america/indiana/knox'), + americaIndianaMarengo(value: 'america/indiana/marengo'), + americaIndianaPetersburg(value: 'america/indiana/petersburg'), + americaIndianaTellCity(value: 'america/indiana/tell_city'), + americaIndianaVevay(value: 'america/indiana/vevay'), + americaIndianaVincennes(value: 'america/indiana/vincennes'), + americaIndianaWinamac(value: 'america/indiana/winamac'), + americaInuvik(value: 'america/inuvik'), + americaIqaluit(value: 'america/iqaluit'), + americaJamaica(value: 'america/jamaica'), + americaJuneau(value: 'america/juneau'), + americaKentuckyLouisville(value: 'america/kentucky/louisville'), + americaKentuckyMonticello(value: 'america/kentucky/monticello'), + americaKralendijk(value: 'america/kralendijk'), + americaLaPaz(value: 'america/la_paz'), + americaLima(value: 'america/lima'), + americaLosAngeles(value: 'america/los_angeles'), + americaLowerPrinces(value: 'america/lower_princes'), + americaMaceio(value: 'america/maceio'), + americaManagua(value: 'america/managua'), + americaManaus(value: 'america/manaus'), + americaMarigot(value: 'america/marigot'), + americaMartinique(value: 'america/martinique'), + americaMatamoros(value: 'america/matamoros'), + americaMazatlan(value: 'america/mazatlan'), + americaMenominee(value: 'america/menominee'), + americaMerida(value: 'america/merida'), + americaMetlakatla(value: 'america/metlakatla'), + americaMexicoCity(value: 'america/mexico_city'), + americaMiquelon(value: 'america/miquelon'), + americaMoncton(value: 'america/moncton'), + americaMonterrey(value: 'america/monterrey'), + americaMontevideo(value: 'america/montevideo'), + americaMontserrat(value: 'america/montserrat'), + americaNassau(value: 'america/nassau'), + americaNewYork(value: 'america/new_york'), + americaNome(value: 'america/nome'), + americaNoronha(value: 'america/noronha'), + americaNorthDakotaBeulah(value: 'america/north_dakota/beulah'), + americaNorthDakotaCenter(value: 'america/north_dakota/center'), + americaNorthDakotaNewSalem(value: 'america/north_dakota/new_salem'), + americaNuuk(value: 'america/nuuk'), + americaOjinaga(value: 'america/ojinaga'), + americaPanama(value: 'america/panama'), + americaParamaribo(value: 'america/paramaribo'), + americaPhoenix(value: 'america/phoenix'), + americaPortAuPrince(value: 'america/port-au-prince'), + americaPortOfSpain(value: 'america/port_of_spain'), + americaPortoVelho(value: 'america/porto_velho'), + americaPuertoRico(value: 'america/puerto_rico'), + americaPuntaArenas(value: 'america/punta_arenas'), + americaRankinInlet(value: 'america/rankin_inlet'), + americaRecife(value: 'america/recife'), + americaRegina(value: 'america/regina'), + americaResolute(value: 'america/resolute'), + americaRioBranco(value: 'america/rio_branco'), + americaSantarem(value: 'america/santarem'), + americaSantiago(value: 'america/santiago'), + americaSantoDomingo(value: 'america/santo_domingo'), + americaSaoPaulo(value: 'america/sao_paulo'), + americaScoresbysund(value: 'america/scoresbysund'), + americaSitka(value: 'america/sitka'), + americaStBarthelemy(value: 'america/st_barthelemy'), + americaStJohns(value: 'america/st_johns'), + americaStKitts(value: 'america/st_kitts'), + americaStLucia(value: 'america/st_lucia'), + americaStThomas(value: 'america/st_thomas'), + americaStVincent(value: 'america/st_vincent'), + americaSwiftCurrent(value: 'america/swift_current'), + americaTegucigalpa(value: 'america/tegucigalpa'), + americaThule(value: 'america/thule'), + americaTijuana(value: 'america/tijuana'), + americaToronto(value: 'america/toronto'), + americaTortola(value: 'america/tortola'), + americaVancouver(value: 'america/vancouver'), + americaWhitehorse(value: 'america/whitehorse'), + americaWinnipeg(value: 'america/winnipeg'), + americaYakutat(value: 'america/yakutat'), + antarcticaCasey(value: 'antarctica/casey'), + antarcticaDavis(value: 'antarctica/davis'), + antarcticaDumontdurville(value: 'antarctica/dumontdurville'), + antarcticaMacquarie(value: 'antarctica/macquarie'), + antarcticaMawson(value: 'antarctica/mawson'), + antarcticaMcmurdo(value: 'antarctica/mcmurdo'), + antarcticaPalmer(value: 'antarctica/palmer'), + antarcticaRothera(value: 'antarctica/rothera'), + antarcticaSyowa(value: 'antarctica/syowa'), + antarcticaTroll(value: 'antarctica/troll'), + antarcticaVostok(value: 'antarctica/vostok'), + arcticLongyearbyen(value: 'arctic/longyearbyen'), + asiaAden(value: 'asia/aden'), + asiaAlmaty(value: 'asia/almaty'), + asiaAmman(value: 'asia/amman'), + asiaAnadyr(value: 'asia/anadyr'), + asiaAqtau(value: 'asia/aqtau'), + asiaAqtobe(value: 'asia/aqtobe'), + asiaAshgabat(value: 'asia/ashgabat'), + asiaAtyrau(value: 'asia/atyrau'), + asiaBaghdad(value: 'asia/baghdad'), + asiaBahrain(value: 'asia/bahrain'), + asiaBaku(value: 'asia/baku'), + asiaBangkok(value: 'asia/bangkok'), + asiaBarnaul(value: 'asia/barnaul'), + asiaBeirut(value: 'asia/beirut'), + asiaBishkek(value: 'asia/bishkek'), + asiaBrunei(value: 'asia/brunei'), + asiaChita(value: 'asia/chita'), + asiaColombo(value: 'asia/colombo'), + asiaDamascus(value: 'asia/damascus'), + asiaDhaka(value: 'asia/dhaka'), + asiaDili(value: 'asia/dili'), + asiaDubai(value: 'asia/dubai'), + asiaDushanbe(value: 'asia/dushanbe'), + asiaFamagusta(value: 'asia/famagusta'), + asiaGaza(value: 'asia/gaza'), + asiaHebron(value: 'asia/hebron'), + asiaHoChiMinh(value: 'asia/ho_chi_minh'), + asiaHongKong(value: 'asia/hong_kong'), + asiaHovd(value: 'asia/hovd'), + asiaIrkutsk(value: 'asia/irkutsk'), + asiaJakarta(value: 'asia/jakarta'), + asiaJayapura(value: 'asia/jayapura'), + asiaJerusalem(value: 'asia/jerusalem'), + asiaKabul(value: 'asia/kabul'), + asiaKamchatka(value: 'asia/kamchatka'), + asiaKarachi(value: 'asia/karachi'), + asiaKathmandu(value: 'asia/kathmandu'), + asiaKhandyga(value: 'asia/khandyga'), + asiaKolkata(value: 'asia/kolkata'), + asiaKrasnoyarsk(value: 'asia/krasnoyarsk'), + asiaKualaLumpur(value: 'asia/kuala_lumpur'), + asiaKuching(value: 'asia/kuching'), + asiaKuwait(value: 'asia/kuwait'), + asiaMacau(value: 'asia/macau'), + asiaMagadan(value: 'asia/magadan'), + asiaMakassar(value: 'asia/makassar'), + asiaManila(value: 'asia/manila'), + asiaMuscat(value: 'asia/muscat'), + asiaNicosia(value: 'asia/nicosia'), + asiaNovokuznetsk(value: 'asia/novokuznetsk'), + asiaNovosibirsk(value: 'asia/novosibirsk'), + asiaOmsk(value: 'asia/omsk'), + asiaOral(value: 'asia/oral'), + asiaPhnomPenh(value: 'asia/phnom_penh'), + asiaPontianak(value: 'asia/pontianak'), + asiaPyongyang(value: 'asia/pyongyang'), + asiaQatar(value: 'asia/qatar'), + asiaQostanay(value: 'asia/qostanay'), + asiaQyzylorda(value: 'asia/qyzylorda'), + asiaRiyadh(value: 'asia/riyadh'), + asiaSakhalin(value: 'asia/sakhalin'), + asiaSamarkand(value: 'asia/samarkand'), + asiaSeoul(value: 'asia/seoul'), + asiaShanghai(value: 'asia/shanghai'), + asiaSingapore(value: 'asia/singapore'), + asiaSrednekolymsk(value: 'asia/srednekolymsk'), + asiaTaipei(value: 'asia/taipei'), + asiaTashkent(value: 'asia/tashkent'), + asiaTbilisi(value: 'asia/tbilisi'), + asiaTehran(value: 'asia/tehran'), + asiaThimphu(value: 'asia/thimphu'), + asiaTokyo(value: 'asia/tokyo'), + asiaTomsk(value: 'asia/tomsk'), + asiaUlaanbaatar(value: 'asia/ulaanbaatar'), + asiaUrumqi(value: 'asia/urumqi'), + asiaUstNera(value: 'asia/ust-nera'), + asiaVientiane(value: 'asia/vientiane'), + asiaVladivostok(value: 'asia/vladivostok'), + asiaYakutsk(value: 'asia/yakutsk'), + asiaYangon(value: 'asia/yangon'), + asiaYekaterinburg(value: 'asia/yekaterinburg'), + asiaYerevan(value: 'asia/yerevan'), + atlanticAzores(value: 'atlantic/azores'), + atlanticBermuda(value: 'atlantic/bermuda'), + atlanticCanary(value: 'atlantic/canary'), + atlanticCapeVerde(value: 'atlantic/cape_verde'), + atlanticFaroe(value: 'atlantic/faroe'), + atlanticMadeira(value: 'atlantic/madeira'), + atlanticReykjavik(value: 'atlantic/reykjavik'), + atlanticSouthGeorgia(value: 'atlantic/south_georgia'), + atlanticStHelena(value: 'atlantic/st_helena'), + atlanticStanley(value: 'atlantic/stanley'), + australiaAdelaide(value: 'australia/adelaide'), + australiaBrisbane(value: 'australia/brisbane'), + australiaBrokenHill(value: 'australia/broken_hill'), + australiaDarwin(value: 'australia/darwin'), + australiaEucla(value: 'australia/eucla'), + australiaHobart(value: 'australia/hobart'), + australiaLindeman(value: 'australia/lindeman'), + australiaLordHowe(value: 'australia/lord_howe'), + australiaMelbourne(value: 'australia/melbourne'), + australiaPerth(value: 'australia/perth'), + australiaSydney(value: 'australia/sydney'), + europeAmsterdam(value: 'europe/amsterdam'), + europeAndorra(value: 'europe/andorra'), + europeAstrakhan(value: 'europe/astrakhan'), + europeAthens(value: 'europe/athens'), + europeBelgrade(value: 'europe/belgrade'), + europeBerlin(value: 'europe/berlin'), + europeBratislava(value: 'europe/bratislava'), + europeBrussels(value: 'europe/brussels'), + europeBucharest(value: 'europe/bucharest'), + europeBudapest(value: 'europe/budapest'), + europeBusingen(value: 'europe/busingen'), + europeChisinau(value: 'europe/chisinau'), + europeCopenhagen(value: 'europe/copenhagen'), + europeDublin(value: 'europe/dublin'), + europeGibraltar(value: 'europe/gibraltar'), + europeGuernsey(value: 'europe/guernsey'), + europeHelsinki(value: 'europe/helsinki'), + europeIsleOfMan(value: 'europe/isle_of_man'), + europeIstanbul(value: 'europe/istanbul'), + europeJersey(value: 'europe/jersey'), + europeKaliningrad(value: 'europe/kaliningrad'), + europeKirov(value: 'europe/kirov'), + europeKyiv(value: 'europe/kyiv'), + europeLisbon(value: 'europe/lisbon'), + europeLjubljana(value: 'europe/ljubljana'), + europeLondon(value: 'europe/london'), + europeLuxembourg(value: 'europe/luxembourg'), + europeMadrid(value: 'europe/madrid'), + europeMalta(value: 'europe/malta'), + europeMariehamn(value: 'europe/mariehamn'), + europeMinsk(value: 'europe/minsk'), + europeMonaco(value: 'europe/monaco'), + europeMoscow(value: 'europe/moscow'), + europeOslo(value: 'europe/oslo'), + europeParis(value: 'europe/paris'), + europePodgorica(value: 'europe/podgorica'), + europePrague(value: 'europe/prague'), + europeRiga(value: 'europe/riga'), + europeRome(value: 'europe/rome'), + europeSamara(value: 'europe/samara'), + europeSanMarino(value: 'europe/san_marino'), + europeSarajevo(value: 'europe/sarajevo'), + europeSaratov(value: 'europe/saratov'), + europeSimferopol(value: 'europe/simferopol'), + europeSkopje(value: 'europe/skopje'), + europeSofia(value: 'europe/sofia'), + europeStockholm(value: 'europe/stockholm'), + europeTallinn(value: 'europe/tallinn'), + europeTirane(value: 'europe/tirane'), + europeUlyanovsk(value: 'europe/ulyanovsk'), + europeVaduz(value: 'europe/vaduz'), + europeVatican(value: 'europe/vatican'), + europeVienna(value: 'europe/vienna'), + europeVilnius(value: 'europe/vilnius'), + europeVolgograd(value: 'europe/volgograd'), + europeWarsaw(value: 'europe/warsaw'), + europeZagreb(value: 'europe/zagreb'), + europeZurich(value: 'europe/zurich'), + indianAntananarivo(value: 'indian/antananarivo'), + indianChagos(value: 'indian/chagos'), + indianChristmas(value: 'indian/christmas'), + indianCocos(value: 'indian/cocos'), + indianComoro(value: 'indian/comoro'), + indianKerguelen(value: 'indian/kerguelen'), + indianMahe(value: 'indian/mahe'), + indianMaldives(value: 'indian/maldives'), + indianMauritius(value: 'indian/mauritius'), + indianMayotte(value: 'indian/mayotte'), + indianReunion(value: 'indian/reunion'), + pacificApia(value: 'pacific/apia'), + pacificAuckland(value: 'pacific/auckland'), + pacificBougainville(value: 'pacific/bougainville'), + pacificChatham(value: 'pacific/chatham'), + pacificChuuk(value: 'pacific/chuuk'), + pacificEaster(value: 'pacific/easter'), + pacificEfate(value: 'pacific/efate'), + pacificFakaofo(value: 'pacific/fakaofo'), + pacificFiji(value: 'pacific/fiji'), + pacificFunafuti(value: 'pacific/funafuti'), + pacificGalapagos(value: 'pacific/galapagos'), + pacificGambier(value: 'pacific/gambier'), + pacificGuadalcanal(value: 'pacific/guadalcanal'), + pacificGuam(value: 'pacific/guam'), + pacificHonolulu(value: 'pacific/honolulu'), + pacificKanton(value: 'pacific/kanton'), + pacificKiritimati(value: 'pacific/kiritimati'), + pacificKosrae(value: 'pacific/kosrae'), + pacificKwajalein(value: 'pacific/kwajalein'), + pacificMajuro(value: 'pacific/majuro'), + pacificMarquesas(value: 'pacific/marquesas'), + pacificMidway(value: 'pacific/midway'), + pacificNauru(value: 'pacific/nauru'), + pacificNiue(value: 'pacific/niue'), + pacificNorfolk(value: 'pacific/norfolk'), + pacificNoumea(value: 'pacific/noumea'), + pacificPagoPago(value: 'pacific/pago_pago'), + pacificPalau(value: 'pacific/palau'), + pacificPitcairn(value: 'pacific/pitcairn'), + pacificPohnpei(value: 'pacific/pohnpei'), + pacificPortMoresby(value: 'pacific/port_moresby'), + pacificRarotonga(value: 'pacific/rarotonga'), + pacificSaipan(value: 'pacific/saipan'), + pacificTahiti(value: 'pacific/tahiti'), + pacificTarawa(value: 'pacific/tarawa'), + pacificTongatapu(value: 'pacific/tongatapu'), + pacificWake(value: 'pacific/wake'), + pacificWallis(value: 'pacific/wallis'), + utc(value: 'utc'); - const Timezone({required this.value}); + const Timezone({ + 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 344a8770..f80fa854 100644 --- a/lib/src/models/algo_argon2.dart +++ b/lib/src/models/algo_argon2.dart @@ -2,41 +2,41 @@ 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'], + ); + } - @override - Map toMap() { - return { - "type": type, - "memoryCost": memoryCost, - "timeCost": timeCost, - "threads": threads, - }; - } + @override + 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 9909265e..c51da4bb 100644 --- a/lib/src/models/algo_bcrypt.dart +++ b/lib/src/models/algo_bcrypt.dart @@ -2,23 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return { - "type": type, - }; - } + @override + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_md5.dart b/lib/src/models/algo_md5.dart index 746fbd52..43523ab1 100644 --- a/lib/src/models/algo_md5.dart +++ b/lib/src/models/algo_md5.dart @@ -2,23 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return { - "type": type, - }; - } + @override + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_phpass.dart b/lib/src/models/algo_phpass.dart index cab45e49..8562c4e3 100644 --- a/lib/src/models/algo_phpass.dart +++ b/lib/src/models/algo_phpass.dart @@ -2,23 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return { - "type": type, - }; - } + @override + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_scrypt.dart b/lib/src/models/algo_scrypt.dart index a1648843..8e844839 100644 --- a/lib/src/models/algo_scrypt.dart +++ b/lib/src/models/algo_scrypt.dart @@ -2,47 +2,47 @@ 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'], - ); - } - - @override - 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'], + ); + } + + @override + 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 33ef4a6f..5202db05 100644 --- a/lib/src/models/algo_scrypt_modified.dart +++ b/lib/src/models/algo_scrypt_modified.dart @@ -2,41 +2,41 @@ 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(), + ); + } - @override - Map toMap() { - return { - "type": type, - "salt": salt, - "saltSeparator": saltSeparator, - "signerKey": signerKey, - }; - } + @override + 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 4984df75..3d08af9f 100644 --- a/lib/src/models/algo_sha.dart +++ b/lib/src/models/algo_sha.dart @@ -2,23 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return { - "type": type, - }; - } + @override + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/continent.dart b/lib/src/models/continent.dart index ec3c41be..930900bf 100644 --- a/lib/src/models/continent.dart +++ b/lib/src/models/continent.dart @@ -2,29 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return { - "name": name, - "code": code, - }; - } + @override + Map toMap() { + return { + "name": name, + "code": code, + }; + } } diff --git a/lib/src/models/continent_list.dart b/lib/src/models/continent_list.dart index df28f04b..753bcacc 100644 --- a/lib/src/models/continent_list.dart +++ b/lib/src/models/continent_list.dart @@ -2,30 +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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "continents": continents.map((p) => p.toMap()).toList(), - }; - } + @override + 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 3bcbb76d..c4838ba3 100644 --- a/lib/src/models/country.dart +++ b/lib/src/models/country.dart @@ -2,29 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return { - "name": name, - "code": code, - }; - } + @override + Map toMap() { + return { + "name": name, + "code": code, + }; + } } diff --git a/lib/src/models/country_list.dart b/lib/src/models/country_list.dart index 79cb1256..f363a54b 100644 --- a/lib/src/models/country_list.dart +++ b/lib/src/models/country_list.dart @@ -2,30 +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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "countries": countries.map((p) => p.toMap()).toList(), - }; - } + @override + 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 f2b18093..b6bb455f 100644 --- a/lib/src/models/currency.dart +++ b/lib/src/models/currency.dart @@ -2,59 +2,59 @@ 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(), - ); - } - - @override - 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(), + ); + } + + @override + 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 6c39ae2e..eb2bad19 100644 --- a/lib/src/models/currency_list.dart +++ b/lib/src/models/currency_list.dart @@ -2,30 +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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "currencies": currencies.map((p) => p.toMap()).toList(), - }; - } + @override + 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 be08d599..0d1fdeb0 100644 --- a/lib/src/models/document.dart +++ b/lib/src/models/document.dart @@ -2,66 +2,66 @@ part of '../../models.dart'; /// Document class Document implements Model { - /// Document ID. - final String $id; + /// Document ID. + final String $id; - /// Document sequence ID. - final String $sequence; + /// Document sequence ID. + final String $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'].toString(), - $collectionId: map['\$collectionId'].toString(), - $databaseId: map['\$databaseId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - data: map["data"] ?? map, - ); - } + factory Document.fromMap(Map map) { + return Document( + $id: map['\$id'].toString(), + $sequence: map['\$sequence'].toString(), + $collectionId: map['\$collectionId'].toString(), + $databaseId: map['\$databaseId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + data: map["data"] ?? map, + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$sequence": $sequence, - "\$collectionId": $collectionId, - "\$databaseId": $databaseId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "data": data, - }; - } + @override + 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 76a07309..0e30844a 100644 --- a/lib/src/models/document_list.dart +++ b/lib/src/models/document_list.dart @@ -2,33 +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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "documents": documents.map((p) => p.toMap()).toList(), - }; - } + @override + 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 3629e1d6..3e767ca3 100644 --- a/lib/src/models/execution.dart +++ b/lib/src/models/execution.dart @@ -2,129 +2,125 @@ 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 enums.ExecutionTrigger trigger; - - /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, `failed`, or `scheduled`. - final enums.ExecutionStatus status; - - /// HTTP request method type. - final String requestMethod; - - /// HTTP request path and query. - final String requestPath; - - /// HTTP request 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: enums.ExecutionTrigger.values - .firstWhere((e) => e.value == map['trigger']), - status: enums.ExecutionStatus.values - .firstWhere((e) => e.value == map['status']), - 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(), - ); - } - - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "functionId": functionId, - "deploymentId": deploymentId, - "trigger": trigger.value, - "status": status.value, - "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 enums.ExecutionTrigger trigger; + + /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, `failed`, or `scheduled`. + final enums.ExecutionStatus status; + + /// HTTP request method type. + final String requestMethod; + + /// HTTP request path and query. + final String requestPath; + + /// HTTP request 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: enums.ExecutionTrigger.values.firstWhere((e) => e.value == map['trigger']), + status: enums.ExecutionStatus.values.firstWhere((e) => e.value == map['status']), + 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(), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "functionId": functionId, + "deploymentId": deploymentId, + "trigger": trigger.value, + "status": status.value, + "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 63c2ad7e..45b60682 100644 --- a/lib/src/models/execution_list.dart +++ b/lib/src/models/execution_list.dart @@ -2,30 +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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "executions": executions.map((p) => p.toMap()).toList(), - }; - } + @override + 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 01cdcb3a..9e5f9eb1 100644 --- a/lib/src/models/file.dart +++ b/lib/src/models/file.dart @@ -2,101 +2,101 @@ part of '../../models.dart'; /// File class File implements Model { - /// File ID. - final String $id; - - /// Bucket ID. - final String bucketId; - - /// File creation date in ISO 8601 format. - final String $createdAt; - - /// 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 name. - final String name; - - /// File MD5 signature. - final String signature; - - /// File mime type. - final String mimeType; - - /// File original size in bytes. - final int sizeOriginal; - - /// File actual stored size in bytes after compression and/or encryption. - final int sizeActual; - - /// Total number of chunks available - final int chunksTotal; - - /// Total number of chunks uploaded - final int chunksUploaded; - - /// Whether file contents are encrypted at rest. - final bool encryption; - - /// Compression algorithm used for the file. Will be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd). - final String compression; - - 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.sizeActual, - required this.chunksTotal, - required this.chunksUploaded, - required this.encryption, - required this.compression, - }); - - 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'], - sizeActual: map['sizeActual'], - chunksTotal: map['chunksTotal'], - chunksUploaded: map['chunksUploaded'], - encryption: map['encryption'], - compression: map['compression'].toString(), - ); - } - - @override - Map toMap() { - return { - "\$id": $id, - "bucketId": bucketId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "name": name, - "signature": signature, - "mimeType": mimeType, - "sizeOriginal": sizeOriginal, - "sizeActual": sizeActual, - "chunksTotal": chunksTotal, - "chunksUploaded": chunksUploaded, - "encryption": encryption, - "compression": compression, - }; - } + /// File ID. + final String $id; + + /// Bucket ID. + final String bucketId; + + /// File creation date in ISO 8601 format. + final String $createdAt; + + /// 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 name. + final String name; + + /// File MD5 signature. + final String signature; + + /// File mime type. + final String mimeType; + + /// File original size in bytes. + final int sizeOriginal; + + /// File actual stored size in bytes after compression and/or encryption. + final int sizeActual; + + /// Total number of chunks available + final int chunksTotal; + + /// Total number of chunks uploaded + final int chunksUploaded; + + /// Whether file contents are encrypted at rest. + final bool encryption; + + /// Compression algorithm used for the file. Will be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd). + final String compression; + + 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.sizeActual, + required this.chunksTotal, + required this.chunksUploaded, + required this.encryption, + required this.compression, + }); + + 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'], + sizeActual: map['sizeActual'], + chunksTotal: map['chunksTotal'], + chunksUploaded: map['chunksUploaded'], + encryption: map['encryption'], + compression: map['compression'].toString(), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "bucketId": bucketId, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "name": name, + "signature": signature, + "mimeType": mimeType, + "sizeOriginal": sizeOriginal, + "sizeActual": sizeActual, + "chunksTotal": chunksTotal, + "chunksUploaded": chunksUploaded, + "encryption": encryption, + "compression": compression, + }; + } } diff --git a/lib/src/models/file_list.dart b/lib/src/models/file_list.dart index 1157554a..84c54b2e 100644 --- a/lib/src/models/file_list.dart +++ b/lib/src/models/file_list.dart @@ -2,29 +2,29 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "files": files.map((p) => p.toMap()).toList(), - }; - } + @override + 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 fa054420..bbccf88a 100644 --- a/lib/src/models/headers.dart +++ b/lib/src/models/headers.dart @@ -2,29 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return { - "name": name, - "value": value, - }; - } + @override + Map toMap() { + return { + "name": name, + "value": value, + }; + } } diff --git a/lib/src/models/identity.dart b/lib/src/models/identity.dart index cc659043..7e90020c 100644 --- a/lib/src/models/identity.dart +++ b/lib/src/models/identity.dart @@ -2,77 +2,77 @@ 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(), + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "userId": userId, - "provider": provider, - "providerUid": providerUid, - "providerEmail": providerEmail, - "providerAccessToken": providerAccessToken, - "providerAccessTokenExpiry": providerAccessTokenExpiry, - "providerRefreshToken": providerRefreshToken, - }; - } + @override + 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 a5d39ea0..d9cc09a2 100644 --- a/lib/src/models/identity_list.dart +++ b/lib/src/models/identity_list.dart @@ -2,30 +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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "identities": identities.map((p) => p.toMap()).toList(), - }; - } + @override + 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 cda66c70..2000acb6 100644 --- a/lib/src/models/jwt.dart +++ b/lib/src/models/jwt.dart @@ -2,23 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return { - "jwt": jwt, - }; - } + @override + Map toMap() { + return { + "jwt": jwt, + }; + } } diff --git a/lib/src/models/language.dart b/lib/src/models/language.dart index 87dc3606..1422d065 100644 --- a/lib/src/models/language.dart +++ b/lib/src/models/language.dart @@ -2,35 +2,35 @@ 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(), + ); + } - @override - Map toMap() { - return { - "name": name, - "code": code, - "nativeName": nativeName, - }; - } + @override + 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 6198d61e..5d78a367 100644 --- a/lib/src/models/language_list.dart +++ b/lib/src/models/language_list.dart @@ -2,30 +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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "languages": languages.map((p) => p.toMap()).toList(), - }; - } + @override + 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 54dd0c29..3292a896 100644 --- a/lib/src/models/locale.dart +++ b/lib/src/models/locale.dart @@ -2,59 +2,59 @@ 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(), - ); - } - - @override - 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(), + ); + } + + @override + 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 21405aff..49ef3b0b 100644 --- a/lib/src/models/locale_code.dart +++ b/lib/src/models/locale_code.dart @@ -2,29 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return { - "code": code, - "name": name, - }; - } + @override + 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 202355a4..a3a26b61 100644 --- a/lib/src/models/locale_code_list.dart +++ b/lib/src/models/locale_code_list.dart @@ -2,30 +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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "localeCodes": localeCodes.map((p) => p.toMap()).toList(), - }; - } + @override + 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 572cce50..406fcbcf 100644 --- a/lib/src/models/log.dart +++ b/lib/src/models/log.dart @@ -2,149 +2,149 @@ part of '../../models.dart'; /// Log class Log implements Model { - /// Event name. - final String event; - - /// User ID of the actor recorded for this log. During impersonation, this is the original impersonator, not the impersonated target user. - final String userId; - - /// User email of the actor recorded for this log. During impersonation, this is the original impersonator. - final String userEmail; - - /// User name of the actor recorded for this log. During impersonation, this is the original impersonator. - final String userName; - - /// API mode when event triggered. - final String mode; - - /// User type who triggered the audit log. Possible values: user, admin, guest, keyProject, keyAccount, keyOrganization. - final String userType; - - /// 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.userType, - 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(), - userType: map['userType'].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(), - ); - } - - @override - Map toMap() { - return { - "event": event, - "userId": userId, - "userEmail": userEmail, - "userName": userName, - "mode": mode, - "userType": userType, - "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 of the actor recorded for this log. During impersonation, this is the original impersonator, not the impersonated target user. + final String userId; + + /// User email of the actor recorded for this log. During impersonation, this is the original impersonator. + final String userEmail; + + /// User name of the actor recorded for this log. During impersonation, this is the original impersonator. + final String userName; + + /// API mode when event triggered. + final String mode; + + /// User type who triggered the audit log. Possible values: user, admin, guest, keyProject, keyAccount, keyOrganization. + final String userType; + + /// 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.userType, + 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(), + userType: map['userType'].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(), + ); + } + + @override + Map toMap() { + return { + "event": event, + "userId": userId, + "userEmail": userEmail, + "userName": userName, + "mode": mode, + "userType": userType, + "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 3494b111..ebf593c2 100644 --- a/lib/src/models/log_list.dart +++ b/lib/src/models/log_list.dart @@ -2,29 +2,29 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "logs": logs.map((p) => p.toMap()).toList(), - }; - } + @override + 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 4d8a2f9b..4baffb71 100644 --- a/lib/src/models/membership.dart +++ b/lib/src/models/membership.dart @@ -2,107 +2,107 @@ 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; - - /// User phone number. Hide this attribute by toggling membership privacy in the Console. - final String userPhone; - - /// 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; - - /// Most recent access date in ISO 8601 format. Show this attribute by toggling membership privacy in the Console. - final String userAccessedAt; - - /// 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.userPhone, - required this.teamId, - required this.teamName, - required this.invited, - required this.joined, - required this.confirm, - required this.mfa, - required this.userAccessedAt, - 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(), - userPhone: map['userPhone'].toString(), - teamId: map['teamId'].toString(), - teamName: map['teamName'].toString(), - invited: map['invited'].toString(), - joined: map['joined'].toString(), - confirm: map['confirm'], - mfa: map['mfa'], - userAccessedAt: map['userAccessedAt'].toString(), - roles: List.from(map['roles'] ?? []), - ); - } - - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "userId": userId, - "userName": userName, - "userEmail": userEmail, - "userPhone": userPhone, - "teamId": teamId, - "teamName": teamName, - "invited": invited, - "joined": joined, - "confirm": confirm, - "mfa": mfa, - "userAccessedAt": userAccessedAt, - "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; + + /// User phone number. Hide this attribute by toggling membership privacy in the Console. + final String userPhone; + + /// 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; + + /// Most recent access date in ISO 8601 format. Show this attribute by toggling membership privacy in the Console. + final String userAccessedAt; + + /// 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.userPhone, + required this.teamId, + required this.teamName, + required this.invited, + required this.joined, + required this.confirm, + required this.mfa, + required this.userAccessedAt, + 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(), + userPhone: map['userPhone'].toString(), + teamId: map['teamId'].toString(), + teamName: map['teamName'].toString(), + invited: map['invited'].toString(), + joined: map['joined'].toString(), + confirm: map['confirm'], + mfa: map['mfa'], + userAccessedAt: map['userAccessedAt'].toString(), + roles: List.from(map['roles'] ?? []), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "userId": userId, + "userName": userName, + "userEmail": userEmail, + "userPhone": userPhone, + "teamId": teamId, + "teamName": teamName, + "invited": invited, + "joined": joined, + "confirm": confirm, + "mfa": mfa, + "userAccessedAt": userAccessedAt, + "roles": roles, + }; + } } diff --git a/lib/src/models/membership_list.dart b/lib/src/models/membership_list.dart index cc664c9f..a0641a28 100644 --- a/lib/src/models/membership_list.dart +++ b/lib/src/models/membership_list.dart @@ -2,30 +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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "memberships": memberships.map((p) => p.toMap()).toList(), - }; - } + @override + 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 fa385541..3d2e2335 100644 --- a/lib/src/models/mfa_challenge.dart +++ b/lib/src/models/mfa_challenge.dart @@ -2,41 +2,41 @@ 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(), + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "userId": userId, - "expire": expire, - }; - } + @override + 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 2777de7f..a7e5fefc 100644 --- a/lib/src/models/mfa_factors.dart +++ b/lib/src/models/mfa_factors.dart @@ -2,41 +2,41 @@ 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'], + ); + } - @override - Map toMap() { - return { - "totp": totp, - "phone": phone, - "email": email, - "recoveryCode": recoveryCode, - }; - } + @override + 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 864a5db8..33036476 100644 --- a/lib/src/models/mfa_recovery_codes.dart +++ b/lib/src/models/mfa_recovery_codes.dart @@ -2,23 +2,23 @@ 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'] ?? []), + ); + } - @override - Map toMap() { - return { - "recoveryCodes": recoveryCodes, - }; - } + @override + Map toMap() { + return { + "recoveryCodes": recoveryCodes, + }; + } } diff --git a/lib/src/models/mfa_type.dart b/lib/src/models/mfa_type.dart index fe5327fc..05cab363 100644 --- a/lib/src/models/mfa_type.dart +++ b/lib/src/models/mfa_type.dart @@ -2,29 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return { - "secret": secret, - "uri": uri, - }; - } + @override + 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 60e2abd9..7ac578e2 100644 --- a/lib/src/models/phone.dart +++ b/lib/src/models/phone.dart @@ -2,35 +2,35 @@ 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(), + ); + } - @override - Map toMap() { - return { - "code": code, - "countryCode": countryCode, - "countryName": countryName, - }; - } + @override + 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 1a197fc7..9791d590 100644 --- a/lib/src/models/phone_list.dart +++ b/lib/src/models/phone_list.dart @@ -2,29 +2,29 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "phones": phones.map((p) => p.toMap()).toList(), - }; - } + @override + 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 3ca04118..b107afe5 100644 --- a/lib/src/models/preferences.dart +++ b/lib/src/models/preferences.dart @@ -2,24 +2,24 @@ 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["data"] ?? map, - ); - } + factory Preferences.fromMap(Map map) { + return Preferences( + data: map["data"] ?? map, + ); + } - @override - Map toMap() { - return { - "data": data, - }; - } + @override + 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/presence.dart b/lib/src/models/presence.dart index d31911de..133fe66d 100644 --- a/lib/src/models/presence.dart +++ b/lib/src/models/presence.dart @@ -2,71 +2,71 @@ part of '../../models.dart'; /// Presence class Presence implements Model { - /// Presence ID. - final String $id; + /// Presence ID. + final String $id; - /// Presence creation date in ISO 8601 format. - final String $createdAt; + /// Presence creation date in ISO 8601 format. + final String $createdAt; - /// Presence update date in ISO 8601 format. - final String $updatedAt; + /// Presence update date in ISO 8601 format. + final String $updatedAt; - /// Presence permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; + /// Presence permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Presence status. - final String? status; + /// Presence status. + final String? status; - /// Presence source. - final String source; + /// Presence source. + final String source; - /// Presence expiry date in ISO 8601 format. - final String? expiresAt; + /// Presence expiry date in ISO 8601 format. + final String? expiresAt; - /// Presence metadata. - final Map? metadata; + /// Presence metadata. + final Map? metadata; - Presence({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.userId, - this.status, - required this.source, - this.expiresAt, - this.metadata, - }); + Presence({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.userId, + this.status, + required this.source, + this.expiresAt, + this.metadata, + }); - factory Presence.fromMap(Map map) { - return Presence( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - userId: map['userId'].toString(), - status: map['status']?.toString(), - source: map['source'].toString(), - expiresAt: map['expiresAt']?.toString(), - metadata: map['metadata'], - ); - } + factory Presence.fromMap(Map map) { + return Presence( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + userId: map['userId'].toString(), + status: map['status']?.toString(), + source: map['source'].toString(), + expiresAt: map['expiresAt']?.toString(), + metadata: map['metadata'], + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "userId": userId, - "status": status, - "source": source, - "expiresAt": expiresAt, - "metadata": metadata, - }; - } + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "userId": userId, + "status": status, + "source": source, + "expiresAt": expiresAt, + "metadata": metadata, + }; + } } diff --git a/lib/src/models/presence_list.dart b/lib/src/models/presence_list.dart index 3d010b1c..aebbe880 100644 --- a/lib/src/models/presence_list.dart +++ b/lib/src/models/presence_list.dart @@ -2,30 +2,29 @@ part of '../../models.dart'; /// Presences List class PresenceList implements Model { - /// Total number of presences that matched your query. - final int total; + /// Total number of presences that matched your query. + final int total; - /// List of presences. - final List presences; + /// List of presences. + final List presences; - PresenceList({ - required this.total, - required this.presences, - }); + PresenceList({ + required this.total, + required this.presences, + }); - factory PresenceList.fromMap(Map map) { - return PresenceList( - total: map['total'], - presences: - List.from(map['presences'].map((p) => Presence.fromMap(p))), - ); - } + factory PresenceList.fromMap(Map map) { + return PresenceList( + total: map['total'], + presences: List.from(map['presences'].map((p) => Presence.fromMap(p))), + ); + } - @override - Map toMap() { - return { - "total": total, - "presences": presences.map((p) => p.toMap()).toList(), - }; - } + @override + Map toMap() { + return { + "total": total, + "presences": presences.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/row.dart b/lib/src/models/row.dart index a825eab0..c5f233b4 100644 --- a/lib/src/models/row.dart +++ b/lib/src/models/row.dart @@ -2,66 +2,66 @@ part of '../../models.dart'; /// Row class Row implements Model { - /// Row ID. - final String $id; + /// Row ID. + final String $id; - /// Row sequence ID. - final String $sequence; + /// Row sequence ID. + final String $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'].toString(), - $tableId: map['\$tableId'].toString(), - $databaseId: map['\$databaseId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - data: map["data"] ?? map, - ); - } + factory Row.fromMap(Map map) { + return Row( + $id: map['\$id'].toString(), + $sequence: map['\$sequence'].toString(), + $tableId: map['\$tableId'].toString(), + $databaseId: map['\$databaseId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + data: map["data"] ?? map, + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$sequence": $sequence, - "\$tableId": $tableId, - "\$databaseId": $databaseId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "data": data, - }; - } + @override + 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 5023c633..90efa95f 100644 --- a/lib/src/models/row_list.dart +++ b/lib/src/models/row_list.dart @@ -2,32 +2,32 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "rows": rows.map((p) => p.toMap()).toList(), - }; - } + @override + 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 92e4034e..c37de95a 100644 --- a/lib/src/models/session.dart +++ b/lib/src/models/session.dart @@ -2,191 +2,191 @@ 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(), - ); - } - - @override - 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(), + ); + } + + @override + 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 4ea12394..d823d0e6 100644 --- a/lib/src/models/session_list.dart +++ b/lib/src/models/session_list.dart @@ -2,30 +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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "sessions": sessions.map((p) => p.toMap()).toList(), - }; - } + @override + 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 450aafd1..850ab8d2 100644 --- a/lib/src/models/subscriber.dart +++ b/lib/src/models/subscriber.dart @@ -2,71 +2,71 @@ 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(), + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "targetId": targetId, - "target": target.toMap(), - "userId": userId, - "userName": userName, - "topicId": topicId, - "providerType": providerType, - }; - } + @override + 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 c2e8c4dc..742e7590 100644 --- a/lib/src/models/target.dart +++ b/lib/src/models/target.dart @@ -2,71 +2,71 @@ 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'], + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "userId": userId, - "providerId": providerId, - "providerType": providerType, - "identifier": identifier, - "expired": expired, - }; - } + @override + 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 91b888b9..21e65e95 100644 --- a/lib/src/models/team.dart +++ b/lib/src/models/team.dart @@ -2,53 +2,53 @@ 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']), - ); - } - - @override - 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']), + ); + } + + @override + 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 e8f1c621..ffca5e98 100644 --- a/lib/src/models/team_list.dart +++ b/lib/src/models/team_list.dart @@ -2,29 +2,29 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "teams": teams.map((p) => p.toMap()).toList(), - }; - } + @override + 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 b5ea87c8..b05320da 100644 --- a/lib/src/models/token.dart +++ b/lib/src/models/token.dart @@ -2,53 +2,53 @@ 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(), - ); - } - - @override - 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(), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "userId": userId, + "secret": secret, + "expire": expire, + "phrase": phrase, + }; + } } diff --git a/lib/src/models/transaction.dart b/lib/src/models/transaction.dart index b0606dd8..e3f3e43d 100644 --- a/lib/src/models/transaction.dart +++ b/lib/src/models/transaction.dart @@ -2,53 +2,53 @@ part of '../../models.dart'; /// Transaction class Transaction implements Model { - /// Transaction ID. - final String $id; - - /// Transaction creation time in ISO 8601 format. - final String $createdAt; - - /// Transaction update date in ISO 8601 format. - final String $updatedAt; - - /// Current status of the transaction. One of: pending, committing, committed, rolled_back, failed. - final String status; - - /// Number of operations in the transaction. - final int operations; - - /// Expiration time in ISO 8601 format. - final String expiresAt; - - Transaction({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.status, - required this.operations, - required this.expiresAt, - }); - - factory Transaction.fromMap(Map map) { - return Transaction( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - status: map['status'].toString(), - operations: map['operations'], - expiresAt: map['expiresAt'].toString(), - ); - } - - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "status": status, - "operations": operations, - "expiresAt": expiresAt, - }; - } + /// Transaction ID. + final String $id; + + /// Transaction creation time in ISO 8601 format. + final String $createdAt; + + /// Transaction update date in ISO 8601 format. + final String $updatedAt; + + /// Current status of the transaction. One of: pending, committing, committed, rolled_back, failed. + final String status; + + /// Number of operations in the transaction. + final int operations; + + /// Expiration time in ISO 8601 format. + final String expiresAt; + + Transaction({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.status, + required this.operations, + required this.expiresAt, + }); + + factory Transaction.fromMap(Map map) { + return Transaction( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + status: map['status'].toString(), + operations: map['operations'], + expiresAt: map['expiresAt'].toString(), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "status": status, + "operations": operations, + "expiresAt": expiresAt, + }; + } } diff --git a/lib/src/models/transaction_list.dart b/lib/src/models/transaction_list.dart index 7f321175..19ea651d 100644 --- a/lib/src/models/transaction_list.dart +++ b/lib/src/models/transaction_list.dart @@ -2,30 +2,29 @@ part of '../../models.dart'; /// Transaction List class TransactionList implements Model { - /// Total number of transactions that matched your query. - final int total; + /// Total number of transactions that matched your query. + final int total; - /// List of transactions. - final List transactions; + /// List of transactions. + final List transactions; - TransactionList({ - required this.total, - required this.transactions, - }); + TransactionList({ + required this.total, + required this.transactions, + }); - factory TransactionList.fromMap(Map map) { - return TransactionList( - total: map['total'], - transactions: List.from( - map['transactions'].map((p) => Transaction.fromMap(p))), - ); - } + factory TransactionList.fromMap(Map map) { + return TransactionList( + total: map['total'], + transactions: List.from(map['transactions'].map((p) => Transaction.fromMap(p))), + ); + } - @override - Map toMap() { - return { - "total": total, - "transactions": transactions.map((p) => p.toMap()).toList(), - }; - } + @override + Map toMap() { + return { + "total": total, + "transactions": transactions.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/user.dart b/lib/src/models/user.dart index 5a6cad30..e3b9536b 100644 --- a/lib/src/models/user.dart +++ b/lib/src/models/user.dart @@ -2,173 +2,173 @@ part of '../../models.dart'; /// User class User implements Model { - /// User ID. - final String $id; + /// User ID. + final String $id; - /// User creation date in ISO 8601 format. - final String $createdAt; + /// User creation date in ISO 8601 format. + final String $createdAt; - /// User update date in ISO 8601 format. - final String $updatedAt; + /// 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; - - /// Canonical form of the user email address. - final String? emailCanonical; - - /// Whether the user email is from a free email provider. - final bool? emailIsFree; - - /// Whether the user email is from a disposable email provider. - final bool? emailIsDisposable; - - /// Whether the user email is from a corporate domain. - final bool? emailIsCorporate; - - /// Whether the user email is in its canonical form. - final bool? emailIsCanonical; - - /// 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; - - /// Whether the user can impersonate other users. - final bool? impersonator; - - /// ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data. - final String? impersonatorUserId; - - 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, - this.emailCanonical, - this.emailIsFree, - this.emailIsDisposable, - this.emailIsCorporate, - this.emailIsCanonical, - required this.phoneVerification, - required this.mfa, - required this.prefs, - required this.targets, - required this.accessedAt, - this.impersonator, - this.impersonatorUserId, - }); - - 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'], - emailCanonical: map['emailCanonical']?.toString(), - emailIsFree: map['emailIsFree'], - emailIsDisposable: map['emailIsDisposable'], - emailIsCorporate: map['emailIsCorporate'], - emailIsCanonical: map['emailIsCanonical'], - 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(), - impersonator: map['impersonator'], - impersonatorUserId: map['impersonatorUserId']?.toString(), - ); - } - - @override - 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, - "emailCanonical": emailCanonical, - "emailIsFree": emailIsFree, - "emailIsDisposable": emailIsDisposable, - "emailIsCorporate": emailIsCorporate, - "emailIsCanonical": emailIsCanonical, - "phoneVerification": phoneVerification, - "mfa": mfa, - "prefs": prefs.toMap(), - "targets": targets.map((p) => p.toMap()).toList(), - "accessedAt": accessedAt, - "impersonator": impersonator, - "impersonatorUserId": impersonatorUserId, - }; - } + /// 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; + + /// Canonical form of the user email address. + final String? emailCanonical; + + /// Whether the user email is from a free email provider. + final bool? emailIsFree; + + /// Whether the user email is from a disposable email provider. + final bool? emailIsDisposable; + + /// Whether the user email is from a corporate domain. + final bool? emailIsCorporate; + + /// Whether the user email is in its canonical form. + final bool? emailIsCanonical; + + /// 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; + + /// Whether the user can impersonate other users. + final bool? impersonator; + + /// ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data. + final String? impersonatorUserId; + + 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, + this.emailCanonical, + this.emailIsFree, + this.emailIsDisposable, + this.emailIsCorporate, + this.emailIsCanonical, + required this.phoneVerification, + required this.mfa, + required this.prefs, + required this.targets, + required this.accessedAt, + this.impersonator, + this.impersonatorUserId, + }); + + 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'], + emailCanonical: map['emailCanonical']?.toString(), + emailIsFree: map['emailIsFree'], + emailIsDisposable: map['emailIsDisposable'], + emailIsCorporate: map['emailIsCorporate'], + emailIsCanonical: map['emailIsCanonical'], + 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(), + impersonator: map['impersonator'], + impersonatorUserId: map['impersonatorUserId']?.toString(), + ); + } + + @override + 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, + "emailCanonical": emailCanonical, + "emailIsFree": emailIsFree, + "emailIsDisposable": emailIsDisposable, + "emailIsCorporate": emailIsCorporate, + "emailIsCanonical": emailIsCanonical, + "phoneVerification": phoneVerification, + "mfa": mfa, + "prefs": prefs.toMap(), + "targets": targets.map((p) => p.toMap()).toList(), + "accessedAt": accessedAt, + "impersonator": impersonator, + "impersonatorUserId": impersonatorUserId, + }; + } } diff --git a/lib/src/realtime.dart b/lib/src/realtime.dart index 28e4c43d..7a5e6303 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(); /// ``` - /// + /// /// You can also use Channel builders: /// ```dart /// final subscription = realtime.subscribe([ diff --git a/lib/src/realtime_io.dart b/lib/src/realtime_io.dart index 0ed367a6..83f01b4c 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) { 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 72edf5ee..6cebb5b1 100644 --- a/lib/src/realtime_mixin.dart +++ b/lib/src/realtime_mixin.dart @@ -58,7 +58,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" + })); } }); } @@ -138,11 +140,9 @@ mixin RealtimeMixin { case 'event': final messageData = data.data as Map; final message = RealtimeMessage.fromMap(messageData); - final subscriptions = - (messageData['subscriptions'] as List?) - ?.map((x) => x.toString()) - .toList() ?? - []; + final subscriptions = (messageData['subscriptions'] as List?) + ?.map((x) => x.toString()) + .toList() ?? []; if (subscriptions.isEmpty) { break; @@ -209,15 +209,13 @@ mixin RealtimeMixin { "Please set endPointRealtime to connect to realtime server"); } var uri = Uri.parse(client.endPointRealtime!); - - var queryParams = - "project=${Uri.encodeComponent(client.config['project']!)}"; + + var queryParams = "project=${Uri.encodeComponent(client.config['project']!)}"; final portPart = (uri.hasPort && uri.port != 80 && uri.port != 443) ? ':${uri.port}' : ''; - return Uri.parse( - "${uri.scheme}://${uri.host}$portPart${uri.path}/realtime?$queryParams"); + return Uri.parse("${uri.scheme}://${uri.host}$portPart${uri.path}/realtime?$queryParams"); } void _sendUnsubscribeMessage(List subscriptionIds) { @@ -312,11 +310,9 @@ mixin RealtimeMixin { return channel is String ? channel : channel.toString(); } - RealtimeSubscription subscribeTo(List channels, - [List queries = const []]) { + RealtimeSubscription subscribeTo(List channels, [List queries = const []]) { StreamController controller = StreamController.broadcast(); - final channelStrings = - channels.map((ch) => _channelToString(ch)).toList().cast(); + final channelStrings = channels.map((ch) => _channelToString(ch)).toList().cast(); final queryStrings = List.from(queries); final subscriptionId = _generateUniqueSubscriptionId(); @@ -333,7 +329,8 @@ mixin RealtimeMixin { _sendUnsubscribeMessage([subscriptionId]); } - Future update({List? channels, List? queries}) async { + Future update( + {List? channels, List? queries}) async { final current = _subscriptions[subscriptionId]; if (current == null) { return; @@ -420,4 +417,4 @@ mixin RealtimeMixin { // until the application-level handshake completes. _flushPendingPresence(); } -} +} \ No newline at end of file diff --git a/lib/src/realtime_response.dart b/lib/src/realtime_response.dart index b0356111..56e7669a 100644 --- a/lib/src/realtime_response.dart +++ b/lib/src/realtime_response.dart @@ -8,6 +8,7 @@ class RealtimeResponse { required this.type, required this.data, }); + RealtimeResponse copyWith({ String? type, @@ -35,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)'; @@ -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 diff --git a/lib/src/realtime_stub.dart b/lib/src/realtime_stub.dart index 3aab4e03..ce0b7e95 100644 --- a/lib/src/realtime_stub.dart +++ b/lib/src/realtime_stub.dart @@ -3,5 +3,5 @@ import 'client.dart'; /// Implemented in `realtime_browser.dart` and `realtime_io.dart`. RealtimeBase createRealtime(Client client) => throw UnsupportedError( - 'Cannot create a client without dart:html or dart:io.', - ); + 'Cannot create a client without dart:html or dart:io.', +); diff --git a/test/channel_test.dart b/test/channel_test.dart index 9e0e11d3..62031aec 100644 --- a/test/channel_test.dart +++ b/test/channel_test.dart @@ -13,22 +13,12 @@ void main() { }); test('returns database channel with action', () { - expect( - Channel.database('db1') - .collection('col1') - .document('doc1') - .create() - .toString(), + expect(Channel.database('db1').collection('col1').document('doc1').create().toString(), 'databases.db1.collections.col1.documents.doc1.create'); }); test('returns database channel with upsert action', () { - expect( - Channel.database('db1') - .collection('col1') - .document('doc1') - .upsert() - .toString(), + expect(Channel.database('db1').collection('col1').document('doc1').upsert().toString(), 'databases.db1.collections.col1.documents.doc1.upsert'); }); }); @@ -44,12 +34,7 @@ void main() { }); test('returns tablesdb channel with action', () { - expect( - Channel.tablesdb('db1') - .table('table1') - .row('row1') - .update() - .toString(), + expect(Channel.tablesdb('db1').table('table1').row('row1').update().toString(), 'tablesdb.db1.tables.table1.rows.row1.update'); }); }); @@ -62,16 +47,16 @@ void main() { group('bucket()', () { test('throws when bucket id is missing', () { - expect(() => Channel.bucket(''), throwsArgumentError); + expect(() => Channel.bucket(''), throwsArgumentError); }); test('returns buckets channel with specific IDs', () { - expect( - Channel.bucket('bucket1').file().toString(), 'buckets.bucket1.files'); + expect(Channel.bucket('bucket1').file().toString(), + 'buckets.bucket1.files'); }); test('returns buckets channel with action', () { - expect(Channel.bucket('bucket1').file('file1').delete().toString(), + expect(Channel.bucket('bucket1').file('file1').delete().toString(), 'buckets.bucket1.files.file1.delete'); }); }); @@ -98,30 +83,29 @@ void main() { group('teams()', () { test('throws when team id is missing', () { - expect(() => Channel.team(''), throwsArgumentError); + expect(() => Channel.team(''), throwsArgumentError); }); test('returns teams channel with specific team ID', () { - expect(Channel.team('team1').toString(), 'teams.team1'); + expect(Channel.team('team1').toString(), 'teams.team1'); }); test('returns teams channel with action', () { - expect(Channel.team('team1').create().toString(), 'teams.team1.create'); + expect(Channel.team('team1').create().toString(), 'teams.team1.create'); }); }); group('memberships()', () { test('throws when membership id is missing', () { - expect(() => Channel.membership(''), throwsArgumentError); + expect(() => Channel.membership(''), throwsArgumentError); }); test('returns memberships channel with specific membership ID', () { - expect(Channel.membership('membership1').toString(), - 'memberships.membership1'); + expect(Channel.membership('membership1').toString(), 'memberships.membership1'); }); test('returns memberships channel with action', () { - expect(Channel.membership('membership1').update().toString(), + expect(Channel.membership('membership1').update().toString(), 'memberships.membership1.update'); }); }); diff --git a/test/query_test.dart b/test/query_test.dart index db7b9214..25388fad 100644 --- a/test/query_test.dart +++ b/test/query_test.dart @@ -354,3 +354,4 @@ void main() { expect(query['method'], 'between'); }); } + diff --git a/test/services/account_test.dart b/test/services/account_test.dart index d5d61fe7..bd65aa32 100644 --- a/test/services/account_test.dart +++ b/test/services/account_test.dart @@ -24,11 +24,12 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -40,1356 +41,1540 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method( - #chunkedUpload, [path, params, paramName, idParamName, headers]), - returnValue: Response(data: {})); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Account test', () { - late MockClient client; - late Account account; + group('Account test', () { + late MockClient client; + late Account account; + + setUp(() { + client = MockClient(); + account = Account(client); + }); + + test('test method get()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.get( + ); + expect(response, isA()); - setUp(() { - client = MockClient(); - account = Account(client); - }); + }); + + test('test method create()', () async { - test('test method get()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.get(); - expect(response, isA()); - }); + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - test('test method create()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.create( - userId: '', - email: 'email@example.com', - password: 'password', - ); - expect(response, isA()); - }); - test('test method updateEmail()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateEmail( - email: 'email@example.com', - password: 'password', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - test('test method listIdentities()', () async { - final Map data = { - 'total': 5, - 'identities': [], - }; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final response = await account.create( + userId: '', + email: 'email@example.com', + password: 'password', + ); + expect(response, isA()); - final response = await account.listIdentities(); - expect(response, isA()); - }); + }); - test('test method deleteIdentity()', () async { - final data = ''; + test('test method updateEmail()', () async { - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - final response = await account.deleteIdentity( - identityId: '', - ); - }); - test('test method createJWT()', () async { - final Map data = { - 'jwt': - 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', - }; + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - final response = await account.createJWT(); - expect(response, isA()); - }); + final response = await account.updateEmail( + email: 'email@example.com', + password: 'password', + ); + expect(response, isA()); - test('test method listLogs()', () async { - final Map data = { - 'total': 5, - 'logs': [], - }; + }); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + test('test method listIdentities()', () async { - final response = await account.listLogs(); - expect(response, isA()); - }); + final Map data = { + 'total': 5, + 'identities': [],}; - test('test method updateMFA()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateMFA( - mfa: true, - ); - expect(response, isA()); - }); - test('test method createMfaAuthenticator()', () async { - final Map data = { - 'secret': '[SHARED_SECRET]', - 'uri': - 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createMfaAuthenticator( - type: enums.AuthenticatorType.totp, - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method createMFAAuthenticator()', () async { - final Map data = { - 'secret': '[SHARED_SECRET]', - 'uri': - 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createMFAAuthenticator( - type: enums.AuthenticatorType.totp, - ); - expect(response, isA()); - }); - test('test method updateMfaAuthenticator()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateMfaAuthenticator( - type: enums.AuthenticatorType.totp, - otp: '', - ); - expect(response, isA()); - }); + final response = await account.listIdentities( + ); + expect(response, isA()); - test('test method updateMFAAuthenticator()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateMFAAuthenticator( - type: enums.AuthenticatorType.totp, - otp: '', - ); - expect(response, isA()); - }); + }); - test('test method deleteMfaAuthenticator()', () async { - final data = ''; + test('test method deleteIdentity()', () async { - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + final data = ''; - final response = await account.deleteMfaAuthenticator( - type: enums.AuthenticatorType.totp, - ); - }); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - test('test method deleteMFAAuthenticator()', () async { - final data = ''; - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + final response = await account.deleteIdentity( + identityId: '', + ); + }); - final response = await account.deleteMFAAuthenticator( - type: enums.AuthenticatorType.totp, - ); - }); + test('test method createJWT()', () async { - test('test method createMfaChallenge()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'expire': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createMfaChallenge( - factor: enums.AuthenticationFactor.email, - ); - expect(response, isA()); - }); + final Map data = { + 'jwt': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c',}; - test('test method createMFAChallenge()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'expire': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createMFAChallenge( - factor: enums.AuthenticationFactor.email, - ); - expect(response, isA()); - }); - test('test method updateMfaChallenge()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateMfaChallenge( - challengeId: '', - otp: '', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - test('test method updateMFAChallenge()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateMFAChallenge( - challengeId: '', - otp: '', - ); - expect(response, isA()); - }); - test('test method listMfaFactors()', () async { - final Map data = { - 'totp': true, - 'phone': true, - 'email': true, - 'recoveryCode': true, - }; + final response = await account.createJWT( + ); + expect(response, isA()); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + }); - final response = await account.listMfaFactors(); - expect(response, isA()); - }); + test('test method listLogs()', () async { - test('test method listMFAFactors()', () async { - final Map data = { - 'totp': true, - 'phone': true, - 'email': true, - 'recoveryCode': true, - }; + final Map data = { + 'total': 5, + 'logs': [],}; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - final response = await account.listMFAFactors(); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method getMfaRecoveryCodes()', () async { - final Map data = { - 'recoveryCodes': [], - }; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final response = await account.listLogs( + ); + expect(response, isA()); - final response = await account.getMfaRecoveryCodes(); - expect(response, isA()); - }); + }); - test('test method getMFARecoveryCodes()', () async { - final Map data = { - 'recoveryCodes': [], - }; + test('test method updateMFA()', () async { - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - final response = await account.getMFARecoveryCodes(); - expect(response, isA()); - }); - test('test method createMfaRecoveryCodes()', () async { - final Map data = { - 'recoveryCodes': [], - }; + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - final response = await account.createMfaRecoveryCodes(); - expect(response, isA()); - }); + final response = await account.updateMFA( + mfa: true, + ); + expect(response, isA()); - test('test method createMFARecoveryCodes()', () async { - final Map data = { - 'recoveryCodes': [], - }; + }); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + test('test method createMfaAuthenticator()', () async { - final response = await account.createMFARecoveryCodes(); - expect(response, isA()); - }); + final Map data = { + 'secret': '[SHARED_SECRET]', + 'uri': 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite',}; - test('test method updateMfaRecoveryCodes()', () async { - final Map data = { - 'recoveryCodes': [], - }; - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - final response = await account.updateMfaRecoveryCodes(); - expect(response, isA()); - }); - test('test method updateMFARecoveryCodes()', () async { - final Map data = { - 'recoveryCodes': [], - }; + final response = await account.createMfaAuthenticator( + type: enums.AuthenticatorType.totp, + ); + expect(response, isA()); - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + }); - final response = await account.updateMFARecoveryCodes(); - expect(response, isA()); - }); + test('test method createMFAAuthenticator()', () async { - test('test method updateName()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateName( - name: '', - ); - expect(response, isA()); - }); + final Map data = { + 'secret': '[SHARED_SECRET]', + 'uri': 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite',}; - test('test method updatePassword()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updatePassword( - password: 'password', - ); - expect(response, isA()); - }); - test('test method updatePhone()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updatePhone( - phone: '+12065550100', - password: 'password', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - test('test method getPrefs()', () async { - final Map data = {}; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final response = await account.createMFAAuthenticator( + type: enums.AuthenticatorType.totp, + ); + expect(response, isA()); - final response = await account.getPrefs(); - expect(response, isA()); - }); + }); - test('test method updatePrefs()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updatePrefs( - prefs: {}, - ); - expect(response, isA()); - }); + test('test method updateMfaAuthenticator()', () async { - test('test method createRecovery()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createRecovery( - email: 'email@example.com', - url: 'https://example.com', - ); - expect(response, isA()); - }); + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - test('test method updateRecovery()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateRecovery( - userId: '', - secret: '', - password: 'password', - ); - expect(response, isA()); - }); - test('test method listSessions()', () async { - final Map data = { - 'total': 5, - 'sessions': [], - }; + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - final response = await account.listSessions(); - expect(response, isA()); - }); + final response = await account.updateMfaAuthenticator( + type: enums.AuthenticatorType.totp, + otp: '', + ); + expect(response, isA()); - test('test method deleteSessions()', () async { - final data = ''; + }); - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + test('test method updateMFAAuthenticator()', () async { - final response = await account.deleteSessions(); - }); + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - test('test method createAnonymousSession()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createAnonymousSession(); - expect(response, isA()); - }); - test('test method createEmailPasswordSession()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createEmailPasswordSession( - email: 'email@example.com', - password: 'password', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); - test('test method updateMagicURLSession()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateMagicURLSession( - userId: '', - secret: '', - ); - expect(response, isA()); - }); - test('test method createOAuth2Session()', () async { - when(client.webAuth( - argThat(isNotNull), - )).thenAnswer((_) async => 'done'); + final response = await account.updateMFAAuthenticator( + type: enums.AuthenticatorType.totp, + otp: '', + ); + expect(response, isA()); - final response = await account.createOAuth2Session( - provider: enums.OAuthProvider.amazon, - ); - expect(response, equals('done')); - }); + }); - test('test method updatePhoneSession()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updatePhoneSession( - userId: '', - secret: '', - ); - expect(response, isA()); - }); + test('test method deleteMfaAuthenticator()', () async { - test('test method createSession()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createSession( - userId: '', - secret: '', - ); - expect(response, isA()); - }); + final data = ''; - test('test method getSession()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.getSession( - sessionId: '', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - test('test method updateSession()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateSession( - sessionId: '', - ); - expect(response, isA()); - }); - test('test method deleteSession()', () async { - final data = ''; + final response = await account.deleteMfaAuthenticator( + type: enums.AuthenticatorType.totp, + ); + }); - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + test('test method deleteMFAAuthenticator()', () async { - final response = await account.deleteSession( - sessionId: '', - ); - }); + final data = ''; - test('test method updateStatus()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateStatus(); - expect(response, isA()); - }); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - test('test method createPushTarget()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'Apple iPhone 12', - 'userId': '259125845563242502', - 'providerType': 'email', - 'identifier': 'token', - 'expired': true, - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createPushTarget( - targetId: '', - identifier: '', - ); - expect(response, isA()); - }); - test('test method updatePushTarget()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'Apple iPhone 12', - 'userId': '259125845563242502', - 'providerType': 'email', - 'identifier': 'token', - 'expired': true, - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updatePushTarget( - targetId: '', - identifier: '', - ); - expect(response, isA()); - }); + final response = await account.deleteMFAAuthenticator( + type: enums.AuthenticatorType.totp, + ); + }); + + test('test method createMfaChallenge()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'expire': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createMfaChallenge( + factor: enums.AuthenticationFactor.email, + ); + expect(response, isA()); + + }); + + test('test method createMFAChallenge()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'expire': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createMFAChallenge( + factor: enums.AuthenticationFactor.email, + ); + expect(response, isA()); + + }); + + test('test method updateMfaChallenge()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - test('test method deletePushTarget()', () async { - final data = ''; - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); - final response = await account.deletePushTarget( - targetId: '', - ); - }); - test('test method createEmailToken()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createEmailToken( - userId: '', - email: 'email@example.com', - ); - expect(response, isA()); - }); + final response = await account.updateMfaChallenge( + challengeId: '', + otp: '', + ); + expect(response, isA()); - test('test method createMagicURLToken()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createMagicURLToken( - userId: '', - email: 'email@example.com', - ); - expect(response, isA()); - }); + }); - test('test method createOAuth2Token()', () async { - when(client.webAuth( - argThat(isNotNull), - )).thenAnswer((_) async => 'done'); + test('test method updateMFAChallenge()', () async { - final response = await account.createOAuth2Token( - provider: enums.OAuthProvider.amazon, - ); - expect(response, equals('done')); - }); + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - test('test method createPhoneToken()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createPhoneToken( - userId: '', - phone: '+12065550100', - ); - expect(response, isA()); - }); - test('test method createEmailVerification()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createEmailVerification( - url: 'https://example.com', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); - test('test method createVerification()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createVerification( - url: 'https://example.com', - ); - expect(response, isA()); - }); - test('test method updateEmailVerification()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateEmailVerification( - userId: '', - secret: '', - ); - expect(response, isA()); - }); + final response = await account.updateMFAChallenge( + challengeId: '', + otp: '', + ); + expect(response, isA()); - test('test method updateVerification()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updateVerification( - userId: '', - secret: '', - ); - expect(response, isA()); - }); + }); - test('test method createPhoneVerification()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.createPhoneVerification(); - expect(response, isA()); - }); + test('test method listMfaFactors()', () async { + + final Map data = { + 'totp': true, + 'phone': true, + 'email': true, + 'recoveryCode': true,}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.listMfaFactors( + ); + expect(response, isA()); + + }); + + test('test method listMFAFactors()', () async { + + final Map data = { + 'totp': true, + 'phone': true, + 'email': true, + 'recoveryCode': true,}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.listMFAFactors( + ); + expect(response, isA()); + + }); + + test('test method getMfaRecoveryCodes()', () async { + + final Map data = { + 'recoveryCodes': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.getMfaRecoveryCodes( + ); + expect(response, isA()); + + }); + + test('test method getMFARecoveryCodes()', () async { + + final Map data = { + 'recoveryCodes': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.getMFARecoveryCodes( + ); + expect(response, isA()); + + }); + + test('test method createMfaRecoveryCodes()', () async { + + final Map data = { + 'recoveryCodes': [],}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createMfaRecoveryCodes( + ); + expect(response, isA()); + + }); + + test('test method createMFARecoveryCodes()', () async { + + final Map data = { + 'recoveryCodes': [],}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createMFARecoveryCodes( + ); + expect(response, isA()); + + }); + + test('test method updateMfaRecoveryCodes()', () async { + + final Map data = { + 'recoveryCodes': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateMfaRecoveryCodes( + ); + expect(response, isA()); + + }); + + test('test method updateMFARecoveryCodes()', () async { + + final Map data = { + 'recoveryCodes': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateMFARecoveryCodes( + ); + expect(response, isA()); + + }); + + test('test method updateName()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateName( + name: '', + ); + expect(response, isA()); + + }); + + test('test method updatePassword()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updatePassword( + password: 'password', + ); + expect(response, isA()); + + }); + + test('test method updatePhone()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updatePhone( + phone: '+12065550100', + password: 'password', + ); + expect(response, isA()); + + }); + + test('test method getPrefs()', () async { + + final Map data = {}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.getPrefs( + ); + expect(response, isA()); + + }); + + test('test method updatePrefs()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updatePrefs( + prefs: {}, + ); + expect(response, isA()); + + }); + + test('test method createRecovery()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createRecovery( + email: 'email@example.com', + url: 'https://example.com', + ); + expect(response, isA()); + + }); + + test('test method updateRecovery()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateRecovery( + userId: '', + secret: '', + password: 'password', + ); + expect(response, isA()); + + }); + + test('test method listSessions()', () async { + + final Map data = { + 'total': 5, + 'sessions': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.listSessions( + ); + expect(response, isA()); + + }); + + test('test method deleteSessions()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.deleteSessions( + ); + }); + + test('test method createAnonymousSession()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createAnonymousSession( + ); + expect(response, isA()); + + }); + + test('test method createEmailPasswordSession()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createEmailPasswordSession( + email: 'email@example.com', + password: 'password', + ); + expect(response, isA()); + + }); + + test('test method updateMagicURLSession()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateMagicURLSession( + userId: '', + secret: '', + ); + expect(response, isA()); + + }); + + test('test method createOAuth2Session()', () async { + + + when(client.webAuth( + argThat(isNotNull), + )).thenAnswer((_) async => 'done'); + + + final response = await account.createOAuth2Session( + provider: enums.OAuthProvider.amazon, + ); + expect(response, equals('done')); + + }); + + test('test method updatePhoneSession()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updatePhoneSession( + userId: '', + secret: '', + ); + expect(response, isA()); + + }); + + test('test method createSession()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createSession( + userId: '', + secret: '', + ); + expect(response, isA()); + + }); + + test('test method getSession()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.getSession( + sessionId: '', + ); + expect(response, isA()); + + }); + + test('test method updateSession()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateSession( + sessionId: '', + ); + expect(response, isA()); + + }); + + test('test method deleteSession()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.deleteSession( + sessionId: '', + ); + }); + + test('test method updateStatus()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateStatus( + ); + expect(response, isA()); + + }); + + test('test method createPushTarget()', () async { + + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Apple iPhone 12', + 'userId': '259125845563242502', + 'providerType': 'email', + 'identifier': 'token', + 'expired': true,}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createPushTarget( + targetId: '', + identifier: '', + ); + expect(response, isA()); + + }); + + test('test method updatePushTarget()', () async { + + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Apple iPhone 12', + 'userId': '259125845563242502', + 'providerType': 'email', + 'identifier': 'token', + 'expired': true,}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updatePushTarget( + targetId: '', + identifier: '', + ); + expect(response, isA()); + + }); + + test('test method deletePushTarget()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.deletePushTarget( + targetId: '', + ); + }); + + test('test method createEmailToken()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createEmailToken( + userId: '', + email: 'email@example.com', + ); + expect(response, isA()); + + }); + + test('test method createMagicURLToken()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createMagicURLToken( + userId: '', + email: 'email@example.com', + ); + expect(response, isA()); + + }); + + test('test method createOAuth2Token()', () async { + + + when(client.webAuth( + argThat(isNotNull), + )).thenAnswer((_) async => 'done'); + + + final response = await account.createOAuth2Token( + provider: enums.OAuthProvider.amazon, + ); + expect(response, equals('done')); + + }); + + test('test method createPhoneToken()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createPhoneToken( + userId: '', + phone: '+12065550100', + ); + expect(response, isA()); + + }); + + test('test method createEmailVerification()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createEmailVerification( + url: 'https://example.com', + ); + expect(response, isA()); + + }); + + test('test method createVerification()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createVerification( + url: 'https://example.com', + ); + expect(response, isA()); + + }); + + test('test method updateEmailVerification()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateEmailVerification( + userId: '', + secret: '', + ); + expect(response, isA()); + + }); + + test('test method updateVerification()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateVerification( + userId: '', + secret: '', + ); + expect(response, isA()); + + }); + + test('test method createPhoneVerification()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createPhoneVerification( + ); + expect(response, isA()); + + }); + + test('test method updatePhoneVerification()', () async { + + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updatePhoneVerification( + userId: '', + secret: '', + ); + expect(response, isA()); + + }); - test('test method updatePhoneVerification()', () async { - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await account.updatePhoneVerification( - userId: '', - secret: '', - ); - expect(response, isA()); }); - }); } diff --git a/test/services/avatars_test.dart b/test/services/avatars_test.dart index 8d2c48fb..4bdb434d 100644 --- a/test/services/avatars_test.dart +++ b/test/services/avatars_test.dart @@ -24,11 +24,12 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -40,123 +41,138 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method( - #chunkedUpload, [path, params, paramName, idParamName, headers]), - returnValue: Response(data: {})); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Avatars test', () { - late MockClient client; - late Avatars avatars; + group('Avatars test', () { + late MockClient client; + late Avatars avatars; - setUp(() { - client = MockClient(); - avatars = Avatars(client); - }); + setUp(() { + client = MockClient(); + avatars = Avatars(client); + }); - test('test method getBrowser()', () async { - final Uint8List data = Uint8List.fromList([]); + test('test method getBrowser()', () async { +final Uint8List data = Uint8List.fromList([]); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await avatars.getBrowser( - code: enums.Browser.avantBrowser, - ); - expect(response, isA()); - }); - test('test method getCreditCard()', () async { - final Uint8List data = Uint8List.fromList([]); + final response = await avatars.getBrowser( + code: enums.Browser.avantBrowser, + ); + expect(response, isA()); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + }); - final response = await avatars.getCreditCard( - code: enums.CreditCard.americanExpress, - ); - expect(response, isA()); - }); + test('test method getCreditCard()', () async { +final Uint8List data = Uint8List.fromList([]); - test('test method getFavicon()', () async { - final Uint8List data = Uint8List.fromList([]); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - final response = await avatars.getFavicon( - url: 'https://example.com', - ); - expect(response, isA()); - }); + final response = await avatars.getCreditCard( + code: enums.CreditCard.americanExpress, + ); + expect(response, isA()); - test('test method getFlag()', () async { - final Uint8List data = Uint8List.fromList([]); + }); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + test('test method getFavicon()', () async { +final Uint8List data = Uint8List.fromList([]); - final response = await avatars.getFlag( - code: enums.Flag.afghanistan, - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method getImage()', () async { - final Uint8List data = Uint8List.fromList([]); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final response = await avatars.getFavicon( + url: 'https://example.com', + ); + expect(response, isA()); - final response = await avatars.getImage( - url: 'https://example.com', - ); - expect(response, isA()); - }); + }); - test('test method getInitials()', () async { - final Uint8List data = Uint8List.fromList([]); + test('test method getFlag()', () async { +final Uint8List data = Uint8List.fromList([]); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await avatars.getInitials(); - expect(response, isA()); - }); - test('test method getQR()', () async { - final Uint8List data = Uint8List.fromList([]); + final response = await avatars.getFlag( + code: enums.Flag.afghanistan, + ); + expect(response, isA()); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + }); + + test('test method getImage()', () async { +final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await avatars.getImage( + url: 'https://example.com', + ); + expect(response, isA()); + + }); + + test('test method getInitials()', () async { +final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await avatars.getInitials( + ); + expect(response, isA()); + + }); + + test('test method getQR()', () async { +final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await avatars.getQR( + text: '', + ); + expect(response, isA()); + + }); + + test('test method getScreenshot()', () async { +final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await avatars.getQR( - text: '', - ); - expect(response, isA()); - }); - test('test method getScreenshot()', () async { - final Uint8List data = Uint8List.fromList([]); + final response = await avatars.getScreenshot( + url: 'https://example.com', + ); + expect(response, isA()); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + }); - final response = await avatars.getScreenshot( - url: 'https://example.com', - ); - expect(response, isA()); }); - }); } diff --git a/test/services/databases_test.dart b/test/services/databases_test.dart index a3807093..a4b0a6cc 100644 --- a/test/services/databases_test.dart +++ b/test/services/databases_test.dart @@ -24,11 +24,12 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -40,297 +41,337 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method( - #chunkedUpload, [path, params, paramName, idParamName, headers]), - returnValue: Response(data: {})); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Databases test', () { - late MockClient client; - late Databases databases; + group('Databases test', () { + late MockClient client; + late Databases databases; - setUp(() { - client = MockClient(); - databases = Databases(client); - }); + setUp(() { + client = MockClient(); + databases = Databases(client); + }); - test('test method listTransactions()', () async { - final Map data = { - 'total': 5, - 'transactions': [], - }; + test('test method listTransactions()', () async { - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final Map data = { + 'total': 5, + 'transactions': [],}; - final response = await databases.listTransactions(); - expect(response, isA()); - }); - test('test method createTransaction()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await databases.createTransaction(); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method getTransaction()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await databases.getTransaction( - transactionId: '', - ); - expect(response, isA()); - }); - test('test method updateTransaction()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await databases.updateTransaction( - transactionId: '', - ); - expect(response, isA()); - }); + final response = await databases.listTransactions( + ); + expect(response, isA()); - test('test method deleteTransaction()', () async { - final data = ''; + }); - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + test('test method createTransaction()', () async { - final response = await databases.deleteTransaction( - transactionId: '', - ); - }); + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - test('test method createOperations()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await databases.createOperations( - transactionId: '', - ); - expect(response, isA()); - }); - test('test method listDocuments()', () async { - final Map data = { - 'total': 5, - 'documents': [], - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await databases.listDocuments( - databaseId: '', - collectionId: '', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - test('test method createDocument()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await databases.createDocument( - databaseId: '', - collectionId: '', - documentId: '', - data: {}, - ); - expect(response, isA()); - }); - test('test method getDocument()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await databases.getDocument( - databaseId: '', - collectionId: '', - documentId: '', - ); - expect(response, isA()); - }); + final response = await databases.createTransaction( + ); + expect(response, isA()); - test('test method upsertDocument()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await databases.upsertDocument( - databaseId: '', - collectionId: '', - documentId: '', - ); - expect(response, isA()); - }); + }); - test('test method updateDocument()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await databases.updateDocument( - databaseId: '', - collectionId: '', - documentId: '', - ); - expect(response, isA()); - }); + test('test method getTransaction()', () async { - test('test method deleteDocument()', () async { - final data = ''; + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - final response = await databases.deleteDocument( - databaseId: '', - collectionId: '', - documentId: '', - ); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method decrementDocumentAttribute()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await databases.decrementDocumentAttribute( - databaseId: '', - collectionId: '', - documentId: '', - attribute: '', - ); - expect(response, isA()); - }); - test('test method incrementDocumentAttribute()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await databases.incrementDocumentAttribute( - databaseId: '', - collectionId: '', - documentId: '', - attribute: '', - ); - expect(response, isA()); + final response = await databases.getTransaction( + transactionId: '', + ); + expect(response, isA()); + + }); + + test('test method updateTransaction()', () async { + + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.updateTransaction( + transactionId: '', + ); + expect(response, isA()); + + }); + + test('test method deleteTransaction()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.deleteTransaction( + transactionId: '', + ); + }); + + test('test method createOperations()', () async { + + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.createOperations( + transactionId: '', + ); + expect(response, isA()); + + }); + + test('test method listDocuments()', () async { + + final Map data = { + 'total': 5, + 'documents': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.listDocuments( + databaseId: '', + collectionId: '', + ); + expect(response, isA()); + + }); + + test('test method createDocument()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.createDocument( + databaseId: '', + collectionId: '', + documentId: '', + data: {}, + ); + expect(response, isA()); + + }); + + test('test method getDocument()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.getDocument( + databaseId: '', + collectionId: '', + documentId: '', + ); + expect(response, isA()); + + }); + + test('test method upsertDocument()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.upsertDocument( + databaseId: '', + collectionId: '', + documentId: '', + ); + expect(response, isA()); + + }); + + test('test method updateDocument()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.updateDocument( + databaseId: '', + collectionId: '', + documentId: '', + ); + expect(response, isA()); + + }); + + test('test method deleteDocument()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.deleteDocument( + databaseId: '', + collectionId: '', + documentId: '', + ); + }); + + test('test method decrementDocumentAttribute()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.decrementDocumentAttribute( + databaseId: '', + collectionId: '', + documentId: '', + attribute: '', + ); + expect(response, isA()); + + }); + + test('test method incrementDocumentAttribute()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.incrementDocumentAttribute( + databaseId: '', + collectionId: '', + documentId: '', + attribute: '', + ); + expect(response, isA()); + + }); + }); - }); } diff --git a/test/services/functions_test.dart b/test/services/functions_test.dart index c6e50a50..9b0d046f 100644 --- a/test/services/functions_test.dart +++ b/test/services/functions_test.dart @@ -24,11 +24,12 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -40,100 +41,107 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method( - #chunkedUpload, [path, params, paramName, idParamName, headers]), - returnValue: Response(data: {})); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Functions test', () { - late MockClient client; - late Functions functions; + group('Functions test', () { + late MockClient client; + late Functions functions; - setUp(() { - client = MockClient(); - functions = Functions(client); - }); + setUp(() { + client = MockClient(); + functions = Functions(client); + }); - test('test method listExecutions()', () async { - final Map data = { - 'total': 5, - 'executions': [], - }; + test('test method listExecutions()', () async { - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final Map data = { + 'total': 5, + 'executions': [],}; - final response = await functions.listExecutions( - functionId: '', - ); - expect(response, isA()); - }); - test('test method createExecution()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'functionId': '5e5ea6g16897e', - 'deploymentId': '5e5ea5c16897e', - 'trigger': 'http', - 'status': 'processing', - 'requestMethod': 'GET', - 'requestPath': '/articles?id=5', - 'requestHeaders': [], - 'responseStatusCode': 200, - 'responseBody': '', - 'responseHeaders': [], - 'logs': '', - 'errors': '', - 'duration': 0.4, - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await functions.createExecution( - functionId: '', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await functions.listExecutions( + functionId: '', + ); + expect(response, isA()); + + }); + + test('test method createExecution()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'functionId': '5e5ea6g16897e', + 'deploymentId': '5e5ea5c16897e', + 'trigger': 'http', + 'status': 'processing', + 'requestMethod': 'GET', + 'requestPath': '/articles?id=5', + 'requestHeaders': [], + 'responseStatusCode': 200, + 'responseBody': '', + 'responseHeaders': [], + 'logs': '', + 'errors': '', + 'duration': 0.4,}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await functions.createExecution( + functionId: '', + ); + expect(response, isA()); + + }); + + test('test method getExecution()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'functionId': '5e5ea6g16897e', + 'deploymentId': '5e5ea5c16897e', + 'trigger': 'http', + 'status': 'processing', + 'requestMethod': 'GET', + 'requestPath': '/articles?id=5', + 'requestHeaders': [], + 'responseStatusCode': 200, + 'responseBody': '', + 'responseHeaders': [], + 'logs': '', + 'errors': '', + 'duration': 0.4,}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await functions.getExecution( + functionId: '', + executionId: '', + ); + expect(response, isA()); + + }); - test('test method getExecution()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'functionId': '5e5ea6g16897e', - 'deploymentId': '5e5ea5c16897e', - 'trigger': 'http', - 'status': 'processing', - 'requestMethod': 'GET', - 'requestPath': '/articles?id=5', - 'requestHeaders': [], - 'responseStatusCode': 200, - 'responseBody': '', - 'responseHeaders': [], - 'logs': '', - 'errors': '', - 'duration': 0.4, - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await functions.getExecution( - functionId: '', - executionId: '', - ); - expect(response, isA()); }); - }); } diff --git a/test/services/graphql_test.dart b/test/services/graphql_test.dart index 84b7de1c..c548e414 100644 --- a/test/services/graphql_test.dart +++ b/test/services/graphql_test.dart @@ -24,11 +24,12 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -40,45 +41,47 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method( - #chunkedUpload, [path, params, paramName, idParamName, headers]), - returnValue: Response(data: {})); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Graphql test', () { - late MockClient client; - late Graphql graphql; + group('Graphql test', () { + late MockClient client; + late Graphql graphql; - setUp(() { - client = MockClient(); - graphql = Graphql(client); - }); + setUp(() { + client = MockClient(); + graphql = Graphql(client); + }); - test('test method query()', () async { - final data = ''; + test('test method query()', () async { - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + final data = ''; - final response = await graphql.query( - query: {}, - ); - }); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await graphql.query( + query: {}, + ); + }); + + test('test method mutation()', () async { + + final data = ''; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - test('test method mutation()', () async { - final data = ''; - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + final response = await graphql.mutation( + query: {}, + ); + }); - final response = await graphql.mutation( - query: {}, - ); }); - }); } diff --git a/test/services/locale_test.dart b/test/services/locale_test.dart index f9f6489d..42faaf72 100644 --- a/test/services/locale_test.dart +++ b/test/services/locale_test.dart @@ -24,11 +24,12 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -40,138 +41,168 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method( - #chunkedUpload, [path, params, paramName, idParamName, headers]), - returnValue: Response(data: {})); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Locale test', () { - late MockClient client; - late Locale locale; + group('Locale test', () { + late MockClient client; + late Locale locale; - setUp(() { - client = MockClient(); - locale = Locale(client); - }); + setUp(() { + client = MockClient(); + locale = Locale(client); + }); - test('test method get()', () async { - final Map data = { - 'ip': '127.0.0.1', - 'countryCode': 'US', - 'country': 'United States', - 'continentCode': 'NA', - 'continent': 'North America', - 'eu': true, - 'currency': 'USD', - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await locale.get(); - expect(response, isA()); - }); + test('test method get()', () async { - test('test method listCodes()', () async { - final Map data = { - 'total': 5, - 'localeCodes': [], - }; + final Map data = { + 'ip': '127.0.0.1', + 'countryCode': 'US', + 'country': 'United States', + 'continentCode': 'NA', + 'continent': 'North America', + 'eu': true, + 'currency': 'USD',}; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - final response = await locale.listCodes(); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method listContinents()', () async { - final Map data = { - 'total': 5, - 'continents': [], - }; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final response = await locale.get( + ); + expect(response, isA()); - final response = await locale.listContinents(); - expect(response, isA()); - }); + }); - test('test method listCountries()', () async { - final Map data = { - 'total': 5, - 'countries': [], - }; + test('test method listCodes()', () async { - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final Map data = { + 'total': 5, + 'localeCodes': [],}; - final response = await locale.listCountries(); - expect(response, isA()); - }); - test('test method listCountriesEU()', () async { - final Map data = { - 'total': 5, - 'countries': [], - }; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - final response = await locale.listCountriesEU(); - expect(response, isA()); - }); + final response = await locale.listCodes( + ); + expect(response, isA()); - test('test method listCountriesPhones()', () async { - final Map data = { - 'total': 5, - 'phones': [], - }; + }); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + test('test method listContinents()', () async { - final response = await locale.listCountriesPhones(); - expect(response, isA()); - }); + final Map data = { + 'total': 5, + 'continents': [],}; - test('test method listCurrencies()', () async { - final Map data = { - 'total': 5, - 'currencies': [], - }; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await locale.listContinents( + ); + expect(response, isA()); + + }); + + test('test method listCountries()', () async { + + final Map data = { + 'total': 5, + 'countries': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await locale.listCountries( + ); + expect(response, isA()); + + }); + + test('test method listCountriesEU()', () async { + + final Map data = { + 'total': 5, + 'countries': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await locale.listCountriesEU( + ); + expect(response, isA()); + + }); + + test('test method listCountriesPhones()', () async { + + final Map data = { + 'total': 5, + 'phones': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await locale.listCountriesPhones( + ); + expect(response, isA()); + + }); + + test('test method listCurrencies()', () async { + + final Map data = { + 'total': 5, + 'currencies': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await locale.listCurrencies( + ); + expect(response, isA()); + + }); + + test('test method listLanguages()', () async { + + final Map data = { + 'total': 5, + 'languages': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await locale.listCurrencies(); - expect(response, isA()); - }); - test('test method listLanguages()', () async { - final Map data = { - 'total': 5, - 'languages': [], - }; + final response = await locale.listLanguages( + ); + expect(response, isA()); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + }); - final response = await locale.listLanguages(); - expect(response, isA()); }); - }); } diff --git a/test/services/messaging_test.dart b/test/services/messaging_test.dart index 0c938eff..5899ace3 100644 --- a/test/services/messaging_test.dart +++ b/test/services/messaging_test.dart @@ -24,11 +24,12 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -40,68 +41,71 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method( - #chunkedUpload, [path, params, paramName, idParamName, headers]), - returnValue: Response(data: {})); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Messaging test', () { - late MockClient client; - late Messaging messaging; + group('Messaging test', () { + late MockClient client; + late Messaging messaging; - setUp(() { - client = MockClient(); - messaging = Messaging(client); - }); + setUp(() { + client = MockClient(); + messaging = Messaging(client); + }); - test('test method createSubscriber()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'targetId': '259125845563242502', - 'target': { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'Apple iPhone 12', - 'userId': '259125845563242502', - 'providerType': 'email', - 'identifier': 'token', - 'expired': true, - }, - 'userId': '5e5ea5c16897e', - 'userName': 'Aegon Targaryen', - 'topicId': '259125845563242502', - 'providerType': 'email', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await messaging.createSubscriber( - topicId: '', - subscriberId: '', - targetId: '', - ); - expect(response, isA()); - }); + test('test method createSubscriber()', () async { + + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'targetId': '259125845563242502', + 'target': { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Apple iPhone 12', + 'userId': '259125845563242502', + 'providerType': 'email', + 'identifier': 'token', + 'expired': true, + }, + 'userId': '5e5ea5c16897e', + 'userName': 'Aegon Targaryen', + 'topicId': '259125845563242502', + 'providerType': 'email',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.createSubscriber( + topicId: '', + subscriberId: '', + targetId: '', + ); + expect(response, isA()); + + }); + + test('test method deleteSubscriber()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - test('test method deleteSubscriber()', () async { - final data = ''; - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + final response = await messaging.deleteSubscriber( + topicId: '', + subscriberId: '', + ); + }); - final response = await messaging.deleteSubscriber( - topicId: '', - subscriberId: '', - ); }); - }); } diff --git a/test/services/presences_test.dart b/test/services/presences_test.dart index 7fed0439..7b99675f 100644 --- a/test/services/presences_test.dart +++ b/test/services/presences_test.dart @@ -24,11 +24,12 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -40,108 +41,121 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method( - #chunkedUpload, [path, params, paramName, idParamName, headers]), - returnValue: Response(data: {})); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Presences test', () { - late MockClient client; - late Presences presences; + group('Presences test', () { + late MockClient client; + late Presences presences; - setUp(() { - client = MockClient(); - presences = Presences(client); - }); + setUp(() { + client = MockClient(); + presences = Presences(client); + }); - test('test method list()', () async { - final Map data = { - 'total': 5, - 'presences': [], - }; + test('test method list()', () async { - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final Map data = { + 'total': 5, + 'presences': [],}; - final response = await presences.list(); - expect(response, isA()); - }); - test('test method get()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'userId': '674af8f3e12a5f9ac0be', - 'source': 'HTTP', - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await presences.get( - presenceId: '', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method upsert()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'userId': '674af8f3e12a5f9ac0be', - 'source': 'HTTP', - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await presences.upsert( - presenceId: '', - status: '', - ); - expect(response, isA()); - }); - test('test method update()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'userId': '674af8f3e12a5f9ac0be', - 'source': 'HTTP', - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await presences.update( - presenceId: '', - ); - expect(response, isA()); - }); + final response = await presences.list( + ); + expect(response, isA()); + + }); + + test('test method get()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'userId': '674af8f3e12a5f9ac0be', + 'source': 'HTTP',}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await presences.get( + presenceId: '', + ); + expect(response, isA()); + + }); + + test('test method upsert()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'userId': '674af8f3e12a5f9ac0be', + 'source': 'HTTP',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await presences.upsert( + presenceId: '', + status: '', + ); + expect(response, isA()); + + }); + + test('test method update()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'userId': '674af8f3e12a5f9ac0be', + 'source': 'HTTP',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await presences.update( + presenceId: '', + ); + expect(response, isA()); + + }); + + test('test method delete()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - test('test method delete()', () async { - final data = ''; - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + final response = await presences.delete( + presenceId: '', + ); + }); - final response = await presences.delete( - presenceId: '', - ); }); - }); } diff --git a/test/services/storage_test.dart b/test/services/storage_test.dart index 55a42f94..2390bfdd 100644 --- a/test/services/storage_test.dart +++ b/test/services/storage_test.dart @@ -24,11 +24,12 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -40,184 +41,202 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method( - #chunkedUpload, [path, params, paramName, idParamName, headers]), - returnValue: Response(data: {})); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Storage test', () { - late MockClient client; - late Storage storage; + group('Storage test', () { + late MockClient client; + late Storage storage; + + setUp(() { + client = MockClient(); + storage = Storage(client); + }); + + test('test method listFiles()', () async { + + final Map data = { + 'total': 5, + 'files': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await storage.listFiles( + bucketId: '', + ); + expect(response, isA()); + + }); + + test('test method createFile()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + 'bucketId': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'name': 'Pink.png', + 'signature': '5d529fd02b544198ae075bd57c1762bb', + 'mimeType': 'image/png', + 'sizeOriginal': 17890, + 'sizeActual': 12345, + 'chunksTotal': 17890, + 'chunksUploaded': 17890, + 'encryption': true, + 'compression': 'gzip',}; + - setUp(() { - client = MockClient(); - storage = Storage(client); - }); + when(client.chunkedUpload( + path: argThat(isNotNull), + params: argThat(isNotNull), + paramName: argThat(isNotNull), + idParamName: argThat(isNotNull), + headers: argThat(isNotNull), + )).thenAnswer((_) async => Response(data: data)); - test('test method listFiles()', () async { - final Map data = { - 'total': 5, - 'files': [], - }; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final response = await storage.createFile( + bucketId: '', + fileId: '', + file: InputFile.fromPath(path: './image.png'), + ); + expect(response, isA()); + + }); - final response = await storage.listFiles( - bucketId: '', - ); - expect(response, isA()); - }); + test('test method getFile()', () async { - test('test method createFile()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - 'bucketId': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'name': 'Pink.png', - 'signature': '5d529fd02b544198ae075bd57c1762bb', - 'mimeType': 'image/png', - 'sizeOriginal': 17890, - 'sizeActual': 12345, - 'chunksTotal': 17890, - 'chunksUploaded': 17890, - 'encryption': true, - 'compression': 'gzip', - }; - - when(client.chunkedUpload( - path: argThat(isNotNull), - params: argThat(isNotNull), - paramName: argThat(isNotNull), - idParamName: argThat(isNotNull), - headers: argThat(isNotNull), - )).thenAnswer((_) async => Response(data: data)); - - final response = await storage.createFile( - bucketId: '', - fileId: '', - file: InputFile.fromPath(path: './image.png'), - ); - expect(response, isA()); - }); + final Map data = { + '\$id': '5e5ea5c16897e', + 'bucketId': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'name': 'Pink.png', + 'signature': '5d529fd02b544198ae075bd57c1762bb', + 'mimeType': 'image/png', + 'sizeOriginal': 17890, + 'sizeActual': 12345, + 'chunksTotal': 17890, + 'chunksUploaded': 17890, + 'encryption': true, + 'compression': 'gzip',}; - test('test method getFile()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - 'bucketId': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'name': 'Pink.png', - 'signature': '5d529fd02b544198ae075bd57c1762bb', - 'mimeType': 'image/png', - 'sizeOriginal': 17890, - 'sizeActual': 12345, - 'chunksTotal': 17890, - 'chunksUploaded': 17890, - 'encryption': true, - 'compression': 'gzip', - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await storage.getFile( - bucketId: '', - fileId: '', - ); - expect(response, isA()); - }); - test('test method updateFile()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - 'bucketId': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'name': 'Pink.png', - 'signature': '5d529fd02b544198ae075bd57c1762bb', - 'mimeType': 'image/png', - 'sizeOriginal': 17890, - 'sizeActual': 12345, - 'chunksTotal': 17890, - 'chunksUploaded': 17890, - 'encryption': true, - 'compression': 'gzip', - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await storage.updateFile( - bucketId: '', - fileId: '', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method deleteFile()', () async { - final data = ''; - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + final response = await storage.getFile( + bucketId: '', + fileId: '', + ); + expect(response, isA()); - final response = await storage.deleteFile( - bucketId: '', - fileId: '', - ); - }); + }); - test('test method getFileDownload()', () async { - final Uint8List data = Uint8List.fromList([]); + test('test method updateFile()', () async { - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final Map data = { + '\$id': '5e5ea5c16897e', + 'bucketId': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'name': 'Pink.png', + 'signature': '5d529fd02b544198ae075bd57c1762bb', + 'mimeType': 'image/png', + 'sizeOriginal': 17890, + 'sizeActual': 12345, + 'chunksTotal': 17890, + 'chunksUploaded': 17890, + 'encryption': true, + 'compression': 'gzip',}; - final response = await storage.getFileDownload( - bucketId: '', - fileId: '', - ); - expect(response, isA()); - }); - test('test method getFilePreview()', () async { - final Uint8List data = Uint8List.fromList([]); + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - final response = await storage.getFilePreview( - bucketId: '', - fileId: '', - ); - expect(response, isA()); - }); + final response = await storage.updateFile( + bucketId: '', + fileId: '', + ); + expect(response, isA()); + + }); + + test('test method deleteFile()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await storage.deleteFile( + bucketId: '', + fileId: '', + ); + }); + + test('test method getFileDownload()', () async { +final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await storage.getFileDownload( + bucketId: '', + fileId: '', + ); + expect(response, isA()); + + }); + + test('test method getFilePreview()', () async { +final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await storage.getFilePreview( + bucketId: '', + fileId: '', + ); + expect(response, isA()); + + }); + + test('test method getFileView()', () async { +final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + - test('test method getFileView()', () async { - final Uint8List data = Uint8List.fromList([]); + final response = await storage.getFileView( + bucketId: '', + fileId: '', + ); + expect(response, isA()); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + }); - final response = await storage.getFileView( - bucketId: '', - fileId: '', - ); - expect(response, isA()); }); - }); } diff --git a/test/services/tables_db_test.dart b/test/services/tables_db_test.dart index f318cad2..5219d2bf 100644 --- a/test/services/tables_db_test.dart +++ b/test/services/tables_db_test.dart @@ -24,11 +24,12 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -40,297 +41,337 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method( - #chunkedUpload, [path, params, paramName, idParamName, headers]), - returnValue: Response(data: {})); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('TablesDB test', () { - late MockClient client; - late TablesDB tablesDB; + group('TablesDB test', () { + late MockClient client; + late TablesDB tablesDB; - setUp(() { - client = MockClient(); - tablesDB = TablesDB(client); - }); + setUp(() { + client = MockClient(); + tablesDB = TablesDB(client); + }); - test('test method listTransactions()', () async { - final Map data = { - 'total': 5, - 'transactions': [], - }; + test('test method listTransactions()', () async { - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final Map data = { + 'total': 5, + 'transactions': [],}; - final response = await tablesDB.listTransactions(); - expect(response, isA()); - }); - test('test method createTransaction()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.createTransaction(); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method getTransaction()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.getTransaction( - transactionId: '', - ); - expect(response, isA()); - }); - test('test method updateTransaction()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.updateTransaction( - transactionId: '', - ); - expect(response, isA()); - }); + final response = await tablesDB.listTransactions( + ); + expect(response, isA()); - test('test method deleteTransaction()', () async { - final data = ''; + }); - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + test('test method createTransaction()', () async { - final response = await tablesDB.deleteTransaction( - transactionId: '', - ); - }); + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - test('test method createOperations()', () async { - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.createOperations( - transactionId: '', - ); - expect(response, isA()); - }); - test('test method listRows()', () async { - final Map data = { - 'total': 5, - 'rows': [], - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.listRows( - databaseId: '', - tableId: '', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - test('test method createRow()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.createRow( - databaseId: '', - tableId: '', - rowId: '', - data: {}, - ); - expect(response, isA()); - }); - test('test method getRow()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.getRow( - databaseId: '', - tableId: '', - rowId: '', - ); - expect(response, isA()); - }); + final response = await tablesDB.createTransaction( + ); + expect(response, isA()); - test('test method upsertRow()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.upsertRow( - databaseId: '', - tableId: '', - rowId: '', - ); - expect(response, isA()); - }); + }); - test('test method updateRow()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.updateRow( - databaseId: '', - tableId: '', - rowId: '', - ); - expect(response, isA()); - }); + test('test method getTransaction()', () async { - test('test method deleteRow()', () async { - final data = ''; + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - final response = await tablesDB.deleteRow( - databaseId: '', - tableId: '', - rowId: '', - ); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method decrementRowColumn()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.decrementRowColumn( - databaseId: '', - tableId: '', - rowId: '', - column: '', - ); - expect(response, isA()); - }); - test('test method incrementRowColumn()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await tablesDB.incrementRowColumn( - databaseId: '', - tableId: '', - rowId: '', - column: '', - ); - expect(response, isA()); + final response = await tablesDB.getTransaction( + transactionId: '', + ); + expect(response, isA()); + + }); + + test('test method updateTransaction()', () async { + + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.updateTransaction( + transactionId: '', + ); + expect(response, isA()); + + }); + + test('test method deleteTransaction()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.deleteTransaction( + transactionId: '', + ); + }); + + test('test method createOperations()', () async { + + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.createOperations( + transactionId: '', + ); + expect(response, isA()); + + }); + + test('test method listRows()', () async { + + final Map data = { + 'total': 5, + 'rows': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.listRows( + databaseId: '', + tableId: '', + ); + expect(response, isA()); + + }); + + test('test method createRow()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.createRow( + databaseId: '', + tableId: '', + rowId: '', + data: {}, + ); + expect(response, isA()); + + }); + + test('test method getRow()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.getRow( + databaseId: '', + tableId: '', + rowId: '', + ); + expect(response, isA()); + + }); + + test('test method upsertRow()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.upsertRow( + databaseId: '', + tableId: '', + rowId: '', + ); + expect(response, isA()); + + }); + + test('test method updateRow()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.updateRow( + databaseId: '', + tableId: '', + rowId: '', + ); + expect(response, isA()); + + }); + + test('test method deleteRow()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.deleteRow( + databaseId: '', + tableId: '', + rowId: '', + ); + }); + + test('test method decrementRowColumn()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.decrementRowColumn( + databaseId: '', + tableId: '', + rowId: '', + column: '', + ); + expect(response, isA()); + + }); + + test('test method incrementRowColumn()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.incrementRowColumn( + databaseId: '', + tableId: '', + rowId: '', + column: '', + ); + expect(response, isA()); + + }); + }); - }); } diff --git a/test/services/teams_test.dart b/test/services/teams_test.dart index 83f2667b..ea72a432 100644 --- a/test/services/teams_test.dart +++ b/test/services/teams_test.dart @@ -24,11 +24,12 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -40,288 +41,326 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod( - Invocation.method( - #chunkedUpload, [path, params, paramName, idParamName, headers]), - returnValue: Response(data: {})); + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); } } void main() { - group('Teams test', () { - late MockClient client; - late Teams teams; + group('Teams test', () { + late MockClient client; + late Teams teams; - setUp(() { - client = MockClient(); - teams = Teams(client); - }); + setUp(() { + client = MockClient(); + teams = Teams(client); + }); - test('test method list()', () async { - final Map data = { - 'total': 5, - 'teams': [], - }; + test('test method list()', () async { - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final Map data = { + 'total': 5, + 'teams': [],}; - final response = await teams.list(); - expect(response, isA()); - }); - test('test method create()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'VIP', - 'total': 7, - 'prefs': {}, - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await teams.create( - teamId: '', - name: '', - ); - expect(response, isA()); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method get()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'VIP', - 'total': 7, - 'prefs': {}, - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await teams.get( - teamId: '', - ); - expect(response, isA()); - }); - test('test method updateName()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'VIP', - 'total': 7, - 'prefs': {}, - }; - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - final response = await teams.updateName( - teamId: '', - name: '', - ); - expect(response, isA()); - }); + final response = await teams.list( + ); + expect(response, isA()); - test('test method delete()', () async { - final data = ''; + }); - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + test('test method create()', () async { - final response = await teams.delete( - teamId: '', - ); - }); + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'VIP', + 'total': 7, + 'prefs': {},}; - test('test method listMemberships()', () async { - final Map data = { - 'total': 5, - 'memberships': [], - }; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - final response = await teams.listMemberships( - teamId: '', - ); - expect(response, isA()); - }); - test('test method createMembership()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [], - }; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - final response = await teams.createMembership( - teamId: '', - roles: [], - ); - expect(response, isA()); - }); + final response = await teams.create( + teamId: '', + name: '', + ); + expect(response, isA()); - test('test method getMembership()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [], - }; - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - final response = await teams.getMembership( - teamId: '', - membershipId: '', - ); - expect(response, isA()); - }); + }); - test('test method updateMembership()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [], - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await teams.updateMembership( - teamId: '', - membershipId: '', - roles: [], - ); - expect(response, isA()); - }); + test('test method get()', () async { - test('test method deleteMembership()', () async { - final data = ''; + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'VIP', + 'total': 7, + 'prefs': {},}; - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - final response = await teams.deleteMembership( - teamId: '', - membershipId: '', - ); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method updateMembershipStatus()', () async { - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [], - }; - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - final response = await teams.updateMembershipStatus( - teamId: '', - membershipId: '', - userId: '', - secret: '', - ); - expect(response, isA()); - }); - test('test method getPrefs()', () async { - final Map data = {}; + final response = await teams.get( + teamId: '', + ); + expect(response, isA()); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + }); + + test('test method updateName()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'VIP', + 'total': 7, + 'prefs': {},}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.updateName( + teamId: '', + name: '', + ); + expect(response, isA()); + + }); + + test('test method delete()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.delete( + teamId: '', + ); + }); + + test('test method listMemberships()', () async { + + final Map data = { + 'total': 5, + 'memberships': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.listMemberships( + teamId: '', + ); + expect(response, isA()); + + }); + + test('test method createMembership()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'userPhone': '+1 555 555 5555', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'roles': [],}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.createMembership( + teamId: '', + roles: [], + ); + expect(response, isA()); + + }); + + test('test method getMembership()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'userPhone': '+1 555 555 5555', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'roles': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.getMembership( + teamId: '', + membershipId: '', + ); + expect(response, isA()); + + }); + + test('test method updateMembership()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'userPhone': '+1 555 555 5555', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'roles': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.updateMembership( + teamId: '', + membershipId: '', + roles: [], + ); + expect(response, isA()); + + }); + + test('test method deleteMembership()', () async { + + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.deleteMembership( + teamId: '', + membershipId: '', + ); + }); + + test('test method updateMembershipStatus()', () async { + + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'userPhone': '+1 555 555 5555', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'roles': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.updateMembershipStatus( + teamId: '', + membershipId: '', + userId: '', + secret: '', + ); + expect(response, isA()); + + }); + + test('test method getPrefs()', () async { + + final Map data = {}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.getPrefs( + teamId: '', + ); + expect(response, isA()); + + }); + + test('test method updatePrefs()', () async { + + final Map data = {}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); - final response = await teams.getPrefs( - teamId: '', - ); - expect(response, isA()); - }); - test('test method updatePrefs()', () async { - final Map data = {}; + final response = await teams.updatePrefs( + teamId: '', + prefs: {}, + ); + expect(response, isA()); - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + }); - final response = await teams.updatePrefs( - teamId: '', - prefs: {}, - ); - expect(response, isA()); }); - }); } diff --git a/test/src/models/algo_argon2_test.dart b/test/src/models/algo_argon2_test.dart index 261daa46..15e85f5a 100644 --- a/test/src/models/algo_argon2_test.dart +++ b/test/src/models/algo_argon2_test.dart @@ -14,10 +14,10 @@ void main() { final map = model.toMap(); final result = AlgoArgon2.fromMap(map); - expect(result.type, 'argon2'); - expect(result.memoryCost, 65536); - expect(result.timeCost, 4); - expect(result.threads, 3); - }); + expect(result.type, 'argon2'); + expect(result.memoryCost, 65536); + expect(result.timeCost, 4); + expect(result.threads, 3); + }); }); } diff --git a/test/src/models/algo_bcrypt_test.dart b/test/src/models/algo_bcrypt_test.dart index 3da36624..87a3ca3c 100644 --- a/test/src/models/algo_bcrypt_test.dart +++ b/test/src/models/algo_bcrypt_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = AlgoBcrypt.fromMap(map); - expect(result.type, 'bcrypt'); - }); + expect(result.type, 'bcrypt'); + }); }); } diff --git a/test/src/models/algo_md5_test.dart b/test/src/models/algo_md5_test.dart index e58fa5b5..3b842e6c 100644 --- a/test/src/models/algo_md5_test.dart +++ b/test/src/models/algo_md5_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = AlgoMd5.fromMap(map); - expect(result.type, 'md5'); - }); + expect(result.type, 'md5'); + }); }); } diff --git a/test/src/models/algo_phpass_test.dart b/test/src/models/algo_phpass_test.dart index 3bcbb488..49b1e22c 100644 --- a/test/src/models/algo_phpass_test.dart +++ b/test/src/models/algo_phpass_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = AlgoPhpass.fromMap(map); - expect(result.type, 'phpass'); - }); + expect(result.type, 'phpass'); + }); }); } diff --git a/test/src/models/algo_scrypt_modified_test.dart b/test/src/models/algo_scrypt_modified_test.dart index b2084927..dd7fa8c3 100644 --- a/test/src/models/algo_scrypt_modified_test.dart +++ b/test/src/models/algo_scrypt_modified_test.dart @@ -8,18 +8,16 @@ void main() { type: 'scryptMod', salt: 'UxLMreBr6tYyjQ==', saltSeparator: 'Bw==', - signerKey: - 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ==', + signerKey: 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ==', ); final map = model.toMap(); final result = AlgoScryptModified.fromMap(map); - expect(result.type, 'scryptMod'); - expect(result.salt, 'UxLMreBr6tYyjQ=='); - expect(result.saltSeparator, 'Bw=='); - expect(result.signerKey, - 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ=='); - }); + expect(result.type, 'scryptMod'); + expect(result.salt, 'UxLMreBr6tYyjQ=='); + expect(result.saltSeparator, 'Bw=='); + expect(result.signerKey, 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ=='); + }); }); } diff --git a/test/src/models/algo_scrypt_test.dart b/test/src/models/algo_scrypt_test.dart index 8c131568..c7d9cdbf 100644 --- a/test/src/models/algo_scrypt_test.dart +++ b/test/src/models/algo_scrypt_test.dart @@ -15,11 +15,11 @@ void main() { final map = model.toMap(); final result = AlgoScrypt.fromMap(map); - expect(result.type, 'scrypt'); - expect(result.costCpu, 8); - expect(result.costMemory, 14); - expect(result.costParallel, 1); - expect(result.length, 64); - }); + expect(result.type, 'scrypt'); + expect(result.costCpu, 8); + expect(result.costMemory, 14); + expect(result.costParallel, 1); + expect(result.length, 64); + }); }); } diff --git a/test/src/models/algo_sha_test.dart b/test/src/models/algo_sha_test.dart index d080569c..ae58b57e 100644 --- a/test/src/models/algo_sha_test.dart +++ b/test/src/models/algo_sha_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = AlgoSha.fromMap(map); - expect(result.type, 'sha'); - }); + expect(result.type, 'sha'); + }); }); } diff --git a/test/src/models/continent_list_test.dart b/test/src/models/continent_list_test.dart index e71dcae1..8de695b0 100644 --- a/test/src/models/continent_list_test.dart +++ b/test/src/models/continent_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = ContinentList.fromMap(map); - expect(result.total, 5); - expect(result.continents, []); - }); + expect(result.total, 5); + expect(result.continents, []); + }); }); } diff --git a/test/src/models/continent_test.dart b/test/src/models/continent_test.dart index 85e559f5..d5242a4e 100644 --- a/test/src/models/continent_test.dart +++ b/test/src/models/continent_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = Continent.fromMap(map); - expect(result.name, 'Europe'); - expect(result.code, 'EU'); - }); + expect(result.name, 'Europe'); + expect(result.code, 'EU'); + }); }); } diff --git a/test/src/models/country_list_test.dart b/test/src/models/country_list_test.dart index 6df5c584..869f5db6 100644 --- a/test/src/models/country_list_test.dart +++ b/test/src/models/country_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = CountryList.fromMap(map); - expect(result.total, 5); - expect(result.countries, []); - }); + expect(result.total, 5); + expect(result.countries, []); + }); }); } diff --git a/test/src/models/country_test.dart b/test/src/models/country_test.dart index d5404a7f..bc66ab7b 100644 --- a/test/src/models/country_test.dart +++ b/test/src/models/country_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = Country.fromMap(map); - expect(result.name, 'United States'); - expect(result.code, 'US'); - }); + expect(result.name, 'United States'); + expect(result.code, 'US'); + }); }); } diff --git a/test/src/models/currency_list_test.dart b/test/src/models/currency_list_test.dart index d7410db8..09da675c 100644 --- a/test/src/models/currency_list_test.dart +++ b/test/src/models/currency_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = CurrencyList.fromMap(map); - expect(result.total, 5); - expect(result.currencies, []); - }); + expect(result.total, 5); + expect(result.currencies, []); + }); }); } diff --git a/test/src/models/currency_test.dart b/test/src/models/currency_test.dart index 00e046c7..29890008 100644 --- a/test/src/models/currency_test.dart +++ b/test/src/models/currency_test.dart @@ -17,13 +17,13 @@ void main() { final map = model.toMap(); final result = Currency.fromMap(map); - expect(result.symbol, '\$'); - expect(result.name, 'US dollar'); - expect(result.symbolNative, '\$'); - expect(result.decimalDigits, 2); - expect(result.rounding, 0); - expect(result.code, 'USD'); - expect(result.namePlural, 'US dollars'); - }); + expect(result.symbol, '\$'); + expect(result.name, 'US dollar'); + expect(result.symbolNative, '\$'); + expect(result.decimalDigits, 2); + expect(result.rounding, 0); + expect(result.code, 'USD'); + expect(result.namePlural, 'US dollars'); + }); }); } diff --git a/test/src/models/document_list_test.dart b/test/src/models/document_list_test.dart index 217d37e8..f1a5b3cc 100644 --- a/test/src/models/document_list_test.dart +++ b/test/src/models/document_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = DocumentList.fromMap(map); - expect(result.total, 5); - expect(result.documents, []); - }); + expect(result.total, 5); + expect(result.documents, []); + }); }); } diff --git a/test/src/models/document_test.dart b/test/src/models/document_test.dart index 397b5fab..6c1fbb77 100644 --- a/test/src/models/document_test.dart +++ b/test/src/models/document_test.dart @@ -18,13 +18,13 @@ void main() { final map = model.toMap(); final result = Document.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$sequence, '1'); - expect(result.$collectionId, '5e5ea5c15117e'); - expect(result.$databaseId, '5e5ea5c15117e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$sequence, '1'); + expect(result.$collectionId, '5e5ea5c15117e'); + expect(result.$databaseId, '5e5ea5c15117e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + }); }); } diff --git a/test/src/models/execution_list_test.dart b/test/src/models/execution_list_test.dart index a3305e55..fe74af58 100644 --- a/test/src/models/execution_list_test.dart +++ b/test/src/models/execution_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = ExecutionList.fromMap(map); - expect(result.total, 5); - expect(result.executions, []); - }); + expect(result.total, 5); + expect(result.executions, []); + }); }); } diff --git a/test/src/models/execution_test.dart b/test/src/models/execution_test.dart index 80ef508a..6d9bf33c 100644 --- a/test/src/models/execution_test.dart +++ b/test/src/models/execution_test.dart @@ -28,23 +28,23 @@ void main() { final map = model.toMap(); final result = Execution.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - expect(result.functionId, '5e5ea6g16897e'); - expect(result.deploymentId, '5e5ea5c16897e'); - expect(result.trigger, ExecutionTrigger.http); - expect(result.status, ExecutionStatus.waiting); - expect(result.requestMethod, 'GET'); - expect(result.requestPath, '/articles?id=5'); - expect(result.requestHeaders, []); - expect(result.responseStatusCode, 200); - expect(result.responseBody, ''); - expect(result.responseHeaders, []); - expect(result.logs, ''); - expect(result.errors, ''); - expect(result.duration, 0.4); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + expect(result.functionId, '5e5ea6g16897e'); + expect(result.deploymentId, '5e5ea5c16897e'); + expect(result.trigger, ExecutionTrigger.http); + expect(result.status, ExecutionStatus.waiting); + expect(result.requestMethod, 'GET'); + expect(result.requestPath, '/articles?id=5'); + expect(result.requestHeaders, []); + expect(result.responseStatusCode, 200); + expect(result.responseBody, ''); + expect(result.responseHeaders, []); + expect(result.logs, ''); + expect(result.errors, ''); + expect(result.duration, 0.4); + }); }); } diff --git a/test/src/models/file_list_test.dart b/test/src/models/file_list_test.dart index 8e02f65e..d8e6c95c 100644 --- a/test/src/models/file_list_test.dart +++ b/test/src/models/file_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = FileList.fromMap(map); - expect(result.total, 5); - expect(result.files, []); - }); + expect(result.total, 5); + expect(result.files, []); + }); }); } diff --git a/test/src/models/file_test.dart b/test/src/models/file_test.dart index 7f132646..8a734a08 100644 --- a/test/src/models/file_test.dart +++ b/test/src/models/file_test.dart @@ -24,20 +24,20 @@ void main() { final map = model.toMap(); final result = File.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.bucketId, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - expect(result.name, 'Pink.png'); - expect(result.signature, '5d529fd02b544198ae075bd57c1762bb'); - expect(result.mimeType, 'image/png'); - expect(result.sizeOriginal, 17890); - expect(result.sizeActual, 12345); - expect(result.chunksTotal, 17890); - expect(result.chunksUploaded, 17890); - expect(result.encryption, true); - expect(result.compression, 'gzip'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.bucketId, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + expect(result.name, 'Pink.png'); + expect(result.signature, '5d529fd02b544198ae075bd57c1762bb'); + expect(result.mimeType, 'image/png'); + expect(result.sizeOriginal, 17890); + expect(result.sizeActual, 12345); + expect(result.chunksTotal, 17890); + expect(result.chunksUploaded, 17890); + expect(result.encryption, true); + expect(result.compression, 'gzip'); + }); }); } diff --git a/test/src/models/headers_test.dart b/test/src/models/headers_test.dart index 9252b469..489891d4 100644 --- a/test/src/models/headers_test.dart +++ b/test/src/models/headers_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = Headers.fromMap(map); - expect(result.name, 'Content-Type'); - expect(result.value, 'application/json'); - }); + expect(result.name, 'Content-Type'); + expect(result.value, 'application/json'); + }); }); } diff --git a/test/src/models/identity_list_test.dart b/test/src/models/identity_list_test.dart index 8c35afec..65f562a7 100644 --- a/test/src/models/identity_list_test.dart +++ b/test/src/models/identity_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = IdentityList.fromMap(map); - expect(result.total, 5); - expect(result.identities, []); - }); + expect(result.total, 5); + expect(result.identities, []); + }); }); } diff --git a/test/src/models/identity_test.dart b/test/src/models/identity_test.dart index 525af4ea..708c8c60 100644 --- a/test/src/models/identity_test.dart +++ b/test/src/models/identity_test.dart @@ -20,16 +20,16 @@ void main() { final map = model.toMap(); final result = Identity.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5bb8c16897e'); - expect(result.provider, 'email'); - expect(result.providerUid, '5e5bb8c16897e'); - expect(result.providerEmail, 'user@example.com'); - expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); - expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5bb8c16897e'); + expect(result.provider, 'email'); + expect(result.providerUid, '5e5bb8c16897e'); + expect(result.providerEmail, 'user@example.com'); + expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); + expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + }); }); } diff --git a/test/src/models/jwt_test.dart b/test/src/models/jwt_test.dart index 93376af1..e616a956 100644 --- a/test/src/models/jwt_test.dart +++ b/test/src/models/jwt_test.dart @@ -5,15 +5,13 @@ void main() { group('Jwt', () { test('model', () { final model = Jwt( - jwt: - 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', + jwt: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', ); final map = model.toMap(); final result = Jwt.fromMap(map); - expect(result.jwt, - 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'); - }); + expect(result.jwt, 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'); + }); }); } diff --git a/test/src/models/language_list_test.dart b/test/src/models/language_list_test.dart index a07c0b5f..94c1e33f 100644 --- a/test/src/models/language_list_test.dart +++ b/test/src/models/language_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = LanguageList.fromMap(map); - expect(result.total, 5); - expect(result.languages, []); - }); + expect(result.total, 5); + expect(result.languages, []); + }); }); } diff --git a/test/src/models/language_test.dart b/test/src/models/language_test.dart index 4a6c96c1..d4087d5e 100644 --- a/test/src/models/language_test.dart +++ b/test/src/models/language_test.dart @@ -13,9 +13,9 @@ void main() { final map = model.toMap(); final result = Language.fromMap(map); - expect(result.name, 'Italian'); - expect(result.code, 'it'); - expect(result.nativeName, 'Italiano'); - }); + expect(result.name, 'Italian'); + expect(result.code, 'it'); + expect(result.nativeName, 'Italiano'); + }); }); } diff --git a/test/src/models/locale_code_list_test.dart b/test/src/models/locale_code_list_test.dart index 65b44ad1..b6de5137 100644 --- a/test/src/models/locale_code_list_test.dart +++ b/test/src/models/locale_code_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = LocaleCodeList.fromMap(map); - expect(result.total, 5); - expect(result.localeCodes, []); - }); + expect(result.total, 5); + expect(result.localeCodes, []); + }); }); } diff --git a/test/src/models/locale_code_test.dart b/test/src/models/locale_code_test.dart index 88cf157b..f0fcdbce 100644 --- a/test/src/models/locale_code_test.dart +++ b/test/src/models/locale_code_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = LocaleCode.fromMap(map); - expect(result.code, 'en-us'); - expect(result.name, 'US'); - }); + expect(result.code, 'en-us'); + expect(result.name, 'US'); + }); }); } diff --git a/test/src/models/locale_test.dart b/test/src/models/locale_test.dart index 49cb1fc9..72102045 100644 --- a/test/src/models/locale_test.dart +++ b/test/src/models/locale_test.dart @@ -17,13 +17,13 @@ void main() { final map = model.toMap(); final result = Locale.fromMap(map); - expect(result.ip, '127.0.0.1'); - expect(result.countryCode, 'US'); - expect(result.country, 'United States'); - expect(result.continentCode, 'NA'); - expect(result.continent, 'North America'); - expect(result.eu, true); - expect(result.currency, 'USD'); - }); + expect(result.ip, '127.0.0.1'); + expect(result.countryCode, 'US'); + expect(result.country, 'United States'); + expect(result.continentCode, 'NA'); + expect(result.continent, 'North America'); + expect(result.eu, true); + expect(result.currency, 'USD'); + }); }); } diff --git a/test/src/models/log_list_test.dart b/test/src/models/log_list_test.dart index b07ca8ee..84c560c8 100644 --- a/test/src/models/log_list_test.dart +++ b/test/src/models/log_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = LogList.fromMap(map); - expect(result.total, 5); - expect(result.logs, []); - }); + expect(result.total, 5); + expect(result.logs, []); + }); }); } diff --git a/test/src/models/log_test.dart b/test/src/models/log_test.dart index c8211d3b..1b463633 100644 --- a/test/src/models/log_test.dart +++ b/test/src/models/log_test.dart @@ -32,28 +32,28 @@ void main() { final map = model.toMap(); final result = Log.fromMap(map); - expect(result.event, 'account.sessions.create'); - expect(result.userId, '610fc2f985ee0'); - expect(result.userEmail, 'john@appwrite.io'); - expect(result.userName, 'John Doe'); - expect(result.mode, 'admin'); - expect(result.userType, 'user'); - expect(result.ip, '127.0.0.1'); - expect(result.time, '2020-10-15T06:38:00.000+00:00'); - expect(result.osCode, 'Mac'); - expect(result.osName, 'Mac'); - expect(result.osVersion, 'Mac'); - expect(result.clientType, 'browser'); - expect(result.clientCode, 'CM'); - expect(result.clientName, 'Chrome Mobile iOS'); - expect(result.clientVersion, '84.0'); - expect(result.clientEngine, 'WebKit'); - expect(result.clientEngineVersion, '605.1.15'); - expect(result.deviceName, 'smartphone'); - expect(result.deviceBrand, 'Google'); - expect(result.deviceModel, 'Nexus 5'); - expect(result.countryCode, 'US'); - expect(result.countryName, 'United States'); - }); + expect(result.event, 'account.sessions.create'); + expect(result.userId, '610fc2f985ee0'); + expect(result.userEmail, 'john@appwrite.io'); + expect(result.userName, 'John Doe'); + expect(result.mode, 'admin'); + expect(result.userType, 'user'); + expect(result.ip, '127.0.0.1'); + expect(result.time, '2020-10-15T06:38:00.000+00:00'); + expect(result.osCode, 'Mac'); + expect(result.osName, 'Mac'); + expect(result.osVersion, 'Mac'); + expect(result.clientType, 'browser'); + expect(result.clientCode, 'CM'); + expect(result.clientName, 'Chrome Mobile iOS'); + expect(result.clientVersion, '84.0'); + expect(result.clientEngine, 'WebKit'); + expect(result.clientEngineVersion, '605.1.15'); + expect(result.deviceName, 'smartphone'); + expect(result.deviceBrand, 'Google'); + expect(result.deviceModel, 'Nexus 5'); + expect(result.countryCode, 'US'); + expect(result.countryName, 'United States'); + }); }); } diff --git a/test/src/models/membership_list_test.dart b/test/src/models/membership_list_test.dart index 4f30c48e..bb1f0946 100644 --- a/test/src/models/membership_list_test.dart +++ b/test/src/models/membership_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = MembershipList.fromMap(map); - expect(result.total, 5); - expect(result.memberships, []); - }); + expect(result.total, 5); + expect(result.memberships, []); + }); }); } diff --git a/test/src/models/membership_test.dart b/test/src/models/membership_test.dart index b2b8bd3d..ab136c24 100644 --- a/test/src/models/membership_test.dart +++ b/test/src/models/membership_test.dart @@ -25,21 +25,21 @@ void main() { final map = model.toMap(); final result = Membership.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5ea5c16897e'); - expect(result.userName, 'John Doe'); - expect(result.userEmail, 'john@appwrite.io'); - expect(result.userPhone, '+1 555 555 5555'); - expect(result.teamId, '5e5ea5c16897e'); - expect(result.teamName, 'VIP'); - expect(result.invited, '2020-10-15T06:38:00.000+00:00'); - expect(result.joined, '2020-10-15T06:38:00.000+00:00'); - expect(result.confirm, true); - expect(result.mfa, true); - expect(result.userAccessedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.roles, []); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5ea5c16897e'); + expect(result.userName, 'John Doe'); + expect(result.userEmail, 'john@appwrite.io'); + expect(result.userPhone, '+1 555 555 5555'); + expect(result.teamId, '5e5ea5c16897e'); + expect(result.teamName, 'VIP'); + expect(result.invited, '2020-10-15T06:38:00.000+00:00'); + expect(result.joined, '2020-10-15T06:38:00.000+00:00'); + expect(result.confirm, true); + expect(result.mfa, true); + expect(result.userAccessedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.roles, []); + }); }); } diff --git a/test/src/models/mfa_challenge_test.dart b/test/src/models/mfa_challenge_test.dart index 5d3febca..9410baa3 100644 --- a/test/src/models/mfa_challenge_test.dart +++ b/test/src/models/mfa_challenge_test.dart @@ -14,10 +14,10 @@ void main() { final map = model.toMap(); final result = MfaChallenge.fromMap(map); - expect(result.$id, 'bb8ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5ea5c168bb8'); - expect(result.expire, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, 'bb8ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5ea5c168bb8'); + expect(result.expire, '2020-10-15T06:38:00.000+00:00'); + }); }); } diff --git a/test/src/models/mfa_factors_test.dart b/test/src/models/mfa_factors_test.dart index 64cc55e4..ed6467d3 100644 --- a/test/src/models/mfa_factors_test.dart +++ b/test/src/models/mfa_factors_test.dart @@ -14,10 +14,10 @@ void main() { final map = model.toMap(); final result = MfaFactors.fromMap(map); - expect(result.totp, true); - expect(result.phone, true); - expect(result.email, true); - expect(result.recoveryCode, true); - }); + expect(result.totp, true); + expect(result.phone, true); + expect(result.email, true); + expect(result.recoveryCode, true); + }); }); } diff --git a/test/src/models/mfa_recovery_codes_test.dart b/test/src/models/mfa_recovery_codes_test.dart index 500913c8..fa097a49 100644 --- a/test/src/models/mfa_recovery_codes_test.dart +++ b/test/src/models/mfa_recovery_codes_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = MfaRecoveryCodes.fromMap(map); - expect(result.recoveryCodes, []); - }); + expect(result.recoveryCodes, []); + }); }); } diff --git a/test/src/models/mfa_type_test.dart b/test/src/models/mfa_type_test.dart index 81657394..3f45d288 100644 --- a/test/src/models/mfa_type_test.dart +++ b/test/src/models/mfa_type_test.dart @@ -6,16 +6,14 @@ void main() { test('model', () { final model = MfaType( secret: '[SHARED_SECRET]', - uri: - 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', + uri: 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', ); final map = model.toMap(); final result = MfaType.fromMap(map); - expect(result.secret, '[SHARED_SECRET]'); - expect(result.uri, - 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite'); - }); + expect(result.secret, '[SHARED_SECRET]'); + expect(result.uri, 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite'); + }); }); } diff --git a/test/src/models/phone_list_test.dart b/test/src/models/phone_list_test.dart index bf22a5c7..6ca46a63 100644 --- a/test/src/models/phone_list_test.dart +++ b/test/src/models/phone_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = PhoneList.fromMap(map); - expect(result.total, 5); - expect(result.phones, []); - }); + expect(result.total, 5); + expect(result.phones, []); + }); }); } diff --git a/test/src/models/phone_test.dart b/test/src/models/phone_test.dart index f70db0e3..d0e5333b 100644 --- a/test/src/models/phone_test.dart +++ b/test/src/models/phone_test.dart @@ -13,9 +13,9 @@ void main() { final map = model.toMap(); final result = Phone.fromMap(map); - expect(result.code, '+1'); - expect(result.countryCode, 'US'); - expect(result.countryName, 'United States'); - }); + expect(result.code, '+1'); + expect(result.countryCode, 'US'); + expect(result.countryName, 'United States'); + }); }); } diff --git a/test/src/models/preferences_test.dart b/test/src/models/preferences_test.dart index 9db30b03..acde349c 100644 --- a/test/src/models/preferences_test.dart +++ b/test/src/models/preferences_test.dart @@ -10,6 +10,7 @@ void main() { final map = model.toMap(); final result = Preferences.fromMap(map); + }); }); } diff --git a/test/src/models/presence_list_test.dart b/test/src/models/presence_list_test.dart index 46f69af6..57a86348 100644 --- a/test/src/models/presence_list_test.dart +++ b/test/src/models/presence_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = PresenceList.fromMap(map); - expect(result.total, 5); - expect(result.presences, []); - }); + expect(result.total, 5); + expect(result.presences, []); + }); }); } diff --git a/test/src/models/presence_test.dart b/test/src/models/presence_test.dart index ef2ebe31..edcfe5f5 100644 --- a/test/src/models/presence_test.dart +++ b/test/src/models/presence_test.dart @@ -16,12 +16,12 @@ void main() { final map = model.toMap(); final result = Presence.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - expect(result.userId, '674af8f3e12a5f9ac0be'); - expect(result.source, 'HTTP'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + expect(result.userId, '674af8f3e12a5f9ac0be'); + expect(result.source, 'HTTP'); + }); }); } diff --git a/test/src/models/row_list_test.dart b/test/src/models/row_list_test.dart index 12693926..d4900dd4 100644 --- a/test/src/models/row_list_test.dart +++ b/test/src/models/row_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = RowList.fromMap(map); - expect(result.total, 5); - expect(result.rows, []); - }); + expect(result.total, 5); + expect(result.rows, []); + }); }); } diff --git a/test/src/models/row_test.dart b/test/src/models/row_test.dart index 564bf303..4e72a449 100644 --- a/test/src/models/row_test.dart +++ b/test/src/models/row_test.dart @@ -18,13 +18,13 @@ void main() { final map = model.toMap(); final result = Row.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$sequence, '1'); - expect(result.$tableId, '5e5ea5c15117e'); - expect(result.$databaseId, '5e5ea5c15117e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$sequence, '1'); + expect(result.$tableId, '5e5ea5c15117e'); + expect(result.$databaseId, '5e5ea5c15117e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + }); }); } diff --git a/test/src/models/session_list_test.dart b/test/src/models/session_list_test.dart index 708e0583..eaab249e 100644 --- a/test/src/models/session_list_test.dart +++ b/test/src/models/session_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = SessionList.fromMap(map); - expect(result.total, 5); - expect(result.sessions, []); - }); + expect(result.total, 5); + expect(result.sessions, []); + }); }); } diff --git a/test/src/models/session_test.dart b/test/src/models/session_test.dart index 689e6048..0177e477 100644 --- a/test/src/models/session_test.dart +++ b/test/src/models/session_test.dart @@ -39,35 +39,35 @@ void main() { final map = model.toMap(); final result = Session.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5bb8c16897e'); - expect(result.expire, '2020-10-15T06:38:00.000+00:00'); - expect(result.provider, 'email'); - expect(result.providerUid, 'user@example.com'); - expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); - expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - expect(result.ip, '127.0.0.1'); - expect(result.osCode, 'Mac'); - expect(result.osName, 'Mac'); - expect(result.osVersion, 'Mac'); - expect(result.clientType, 'browser'); - expect(result.clientCode, 'CM'); - expect(result.clientName, 'Chrome Mobile iOS'); - expect(result.clientVersion, '84.0'); - expect(result.clientEngine, 'WebKit'); - expect(result.clientEngineVersion, '605.1.15'); - expect(result.deviceName, 'smartphone'); - expect(result.deviceBrand, 'Google'); - expect(result.deviceModel, 'Nexus 5'); - expect(result.countryCode, 'US'); - expect(result.countryName, 'United States'); - expect(result.current, true); - expect(result.factors, []); - expect(result.secret, '5e5bb8c16897e'); - expect(result.mfaUpdatedAt, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5bb8c16897e'); + expect(result.expire, '2020-10-15T06:38:00.000+00:00'); + expect(result.provider, 'email'); + expect(result.providerUid, 'user@example.com'); + expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); + expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + expect(result.ip, '127.0.0.1'); + expect(result.osCode, 'Mac'); + expect(result.osName, 'Mac'); + expect(result.osVersion, 'Mac'); + expect(result.clientType, 'browser'); + expect(result.clientCode, 'CM'); + expect(result.clientName, 'Chrome Mobile iOS'); + expect(result.clientVersion, '84.0'); + expect(result.clientEngine, 'WebKit'); + expect(result.clientEngineVersion, '605.1.15'); + expect(result.deviceName, 'smartphone'); + expect(result.deviceBrand, 'Google'); + expect(result.deviceModel, 'Nexus 5'); + expect(result.countryCode, 'US'); + expect(result.countryName, 'United States'); + expect(result.current, true); + expect(result.factors, []); + expect(result.secret, '5e5bb8c16897e'); + expect(result.mfaUpdatedAt, '2020-10-15T06:38:00.000+00:00'); + }); }); } diff --git a/test/src/models/subscriber_test.dart b/test/src/models/subscriber_test.dart index 7445514c..94c6a502 100644 --- a/test/src/models/subscriber_test.dart +++ b/test/src/models/subscriber_test.dart @@ -10,15 +10,15 @@ void main() { $updatedAt: '2020-10-15T06:38:00.000+00:00', targetId: '259125845563242502', target: Target( - $id: '259125845563242502', - $createdAt: '2020-10-15T06:38:00.000+00:00', - $updatedAt: '2020-10-15T06:38:00.000+00:00', - name: 'Apple iPhone 12', - userId: '259125845563242502', - providerType: 'email', - identifier: 'token', - expired: true, - ), + $id: '259125845563242502', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Apple iPhone 12', + userId: '259125845563242502', + providerType: 'email', + identifier: 'token', + expired: true, + ), userId: '5e5ea5c16897e', userName: 'Aegon Targaryen', topicId: '259125845563242502', @@ -28,14 +28,14 @@ void main() { final map = model.toMap(); final result = Subscriber.fromMap(map); - expect(result.$id, '259125845563242502'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.targetId, '259125845563242502'); - expect(result.userId, '5e5ea5c16897e'); - expect(result.userName, 'Aegon Targaryen'); - expect(result.topicId, '259125845563242502'); - expect(result.providerType, 'email'); - }); + expect(result.$id, '259125845563242502'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.targetId, '259125845563242502'); + expect(result.userId, '5e5ea5c16897e'); + expect(result.userName, 'Aegon Targaryen'); + expect(result.topicId, '259125845563242502'); + expect(result.providerType, 'email'); + }); }); } diff --git a/test/src/models/target_test.dart b/test/src/models/target_test.dart index 49f1e75e..a49f3def 100644 --- a/test/src/models/target_test.dart +++ b/test/src/models/target_test.dart @@ -18,14 +18,14 @@ void main() { final map = model.toMap(); final result = Target.fromMap(map); - expect(result.$id, '259125845563242502'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.name, 'Apple iPhone 12'); - expect(result.userId, '259125845563242502'); - expect(result.providerType, 'email'); - expect(result.identifier, 'token'); - expect(result.expired, true); - }); + expect(result.$id, '259125845563242502'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.name, 'Apple iPhone 12'); + expect(result.userId, '259125845563242502'); + expect(result.providerType, 'email'); + expect(result.identifier, 'token'); + expect(result.expired, true); + }); }); } diff --git a/test/src/models/team_list_test.dart b/test/src/models/team_list_test.dart index fe2f4a85..a19b667d 100644 --- a/test/src/models/team_list_test.dart +++ b/test/src/models/team_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = TeamList.fromMap(map); - expect(result.total, 5); - expect(result.teams, []); - }); + expect(result.total, 5); + expect(result.teams, []); + }); }); } diff --git a/test/src/models/team_test.dart b/test/src/models/team_test.dart index f652f2c1..43b2e45c 100644 --- a/test/src/models/team_test.dart +++ b/test/src/models/team_test.dart @@ -16,11 +16,11 @@ void main() { final map = model.toMap(); final result = Team.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.name, 'VIP'); - expect(result.total, 7); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.name, 'VIP'); + expect(result.total, 7); + }); }); } diff --git a/test/src/models/token_test.dart b/test/src/models/token_test.dart index 8f0957c9..7ee4b268 100644 --- a/test/src/models/token_test.dart +++ b/test/src/models/token_test.dart @@ -16,12 +16,12 @@ void main() { final map = model.toMap(); final result = Token.fromMap(map); - expect(result.$id, 'bb8ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5ea5c168bb8'); - expect(result.secret, ''); - expect(result.expire, '2020-10-15T06:38:00.000+00:00'); - expect(result.phrase, 'Golden Fox'); - }); + expect(result.$id, 'bb8ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5ea5c168bb8'); + expect(result.secret, ''); + expect(result.expire, '2020-10-15T06:38:00.000+00:00'); + expect(result.phrase, 'Golden Fox'); + }); }); } diff --git a/test/src/models/transaction_list_test.dart b/test/src/models/transaction_list_test.dart index a524ef71..68023e18 100644 --- a/test/src/models/transaction_list_test.dart +++ b/test/src/models/transaction_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = TransactionList.fromMap(map); - expect(result.total, 5); - expect(result.transactions, []); - }); + expect(result.total, 5); + expect(result.transactions, []); + }); }); } diff --git a/test/src/models/transaction_test.dart b/test/src/models/transaction_test.dart index 0169427f..723ebac2 100644 --- a/test/src/models/transaction_test.dart +++ b/test/src/models/transaction_test.dart @@ -16,12 +16,12 @@ void main() { final map = model.toMap(); final result = Transaction.fromMap(map); - expect(result.$id, '259125845563242502'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.status, 'pending'); - expect(result.operations, 5); - expect(result.expiresAt, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, '259125845563242502'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.status, 'pending'); + expect(result.operations, 5); + expect(result.expiresAt, '2020-10-15T06:38:00.000+00:00'); + }); }); } diff --git a/test/src/models/user_test.dart b/test/src/models/user_test.dart index 77c7dd97..c058ea26 100644 --- a/test/src/models/user_test.dart +++ b/test/src/models/user_test.dart @@ -26,21 +26,21 @@ void main() { final map = model.toMap(); final result = User.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.name, 'John Doe'); - expect(result.registration, '2020-10-15T06:38:00.000+00:00'); - expect(result.status, true); - expect(result.labels, []); - expect(result.passwordUpdate, '2020-10-15T06:38:00.000+00:00'); - expect(result.email, 'john@appwrite.io'); - expect(result.phone, '+4930901820'); - expect(result.emailVerification, true); - expect(result.phoneVerification, true); - expect(result.mfa, true); - expect(result.targets, []); - expect(result.accessedAt, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.name, 'John Doe'); + expect(result.registration, '2020-10-15T06:38:00.000+00:00'); + expect(result.status, true); + expect(result.labels, []); + expect(result.passwordUpdate, '2020-10-15T06:38:00.000+00:00'); + expect(result.email, 'john@appwrite.io'); + expect(result.phone, '+4930901820'); + expect(result.emailVerification, true); + expect(result.phoneVerification, true); + expect(result.mfa, true); + expect(result.targets, []); + expect(result.accessedAt, '2020-10-15T06:38:00.000+00:00'); + }); }); } From d676e5ad37b14d8fc8523870439f25235f513d45 Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Thu, 25 Jun 2026 04:54:57 +0000 Subject: [PATCH 8/8] Commit from GitHub Actions (Format and push) --- lib/appwrite.dart | 2 +- lib/channel.dart | 20 +- lib/client_browser.dart | 2 +- lib/client_io.dart | 2 +- lib/operator.dart | 11 +- lib/query.dart | 91 +- lib/realtime_browser.dart | 2 +- lib/realtime_io.dart | 2 +- lib/role.dart | 2 +- lib/services/account.dart | 1560 +++++----- lib/services/avatars.dart | 351 ++- lib/services/databases.dart | 603 ++-- lib/services/functions.dart | 115 +- lib/services/graphql.dart | 50 +- lib/services/locale.dart | 142 +- lib/services/messaging.dart | 70 +- lib/services/presences.dart | 182 +- lib/services/storage.dart | 342 ++- lib/services/tables_db.dart | 547 ++-- lib/services/teams.dart | 421 +-- lib/src/client.dart | 4 +- lib/src/client_base.dart | 7 + lib/src/client_browser.dart | 15 +- lib/src/client_io.dart | 15 +- lib/src/client_mixin.dart | 9 +- lib/src/enums/authentication_factor.dart | 18 +- lib/src/enums/authenticator_type.dart | 12 +- lib/src/enums/browser.dart | 38 +- lib/src/enums/browser_permission.dart | 50 +- lib/src/enums/browser_theme.dart | 14 +- lib/src/enums/credit_card.dart | 44 +- lib/src/enums/execution_method.dart | 24 +- lib/src/enums/execution_status.dart | 20 +- lib/src/enums/execution_trigger.dart | 16 +- 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 | 96 +- lib/src/enums/timezone.dart | 848 +++--- lib/src/exception.dart | 2 +- lib/src/models/algo_argon2.dart | 62 +- lib/src/models/algo_bcrypt.dart | 32 +- lib/src/models/algo_md5.dart | 32 +- lib/src/models/algo_phpass.dart | 32 +- lib/src/models/algo_scrypt.dart | 86 +- lib/src/models/algo_scrypt_modified.dart | 62 +- lib/src/models/algo_sha.dart | 32 +- lib/src/models/continent.dart | 42 +- lib/src/models/continent_list.dart | 43 +- lib/src/models/country.dart | 42 +- lib/src/models/country_list.dart | 43 +- lib/src/models/currency.dart | 110 +- lib/src/models/currency_list.dart | 43 +- lib/src/models/document.dart | 102 +- lib/src/models/document_list.dart | 47 +- lib/src/models/execution.dart | 246 +- lib/src/models/execution_list.dart | 43 +- lib/src/models/file.dart | 194 +- lib/src/models/file_list.dart | 42 +- lib/src/models/headers.dart | 42 +- lib/src/models/identity.dart | 122 +- lib/src/models/identity_list.dart | 43 +- lib/src/models/jwt.dart | 32 +- lib/src/models/language.dart | 52 +- lib/src/models/language_list.dart | 43 +- lib/src/models/locale.dart | 110 +- lib/src/models/locale_code.dart | 42 +- lib/src/models/locale_code_list.dart | 43 +- lib/src/models/log.dart | 290 +- lib/src/models/log_list.dart | 42 +- lib/src/models/membership.dart | 206 +- lib/src/models/membership_list.dart | 43 +- lib/src/models/mfa_challenge.dart | 62 +- lib/src/models/mfa_factors.dart | 62 +- lib/src/models/mfa_recovery_codes.dart | 32 +- lib/src/models/mfa_type.dart | 42 +- lib/src/models/model.dart | 2 +- lib/src/models/phone.dart | 52 +- lib/src/models/phone_list.dart | 42 +- lib/src/models/preferences.dart | 32 +- lib/src/models/presence.dart | 112 +- lib/src/models/presence_list.dart | 43 +- lib/src/models/row.dart | 102 +- lib/src/models/row_list.dart | 46 +- lib/src/models/session.dart | 360 +-- lib/src/models/session_list.dart | 43 +- lib/src/models/subscriber.dart | 112 +- lib/src/models/target.dart | 112 +- lib/src/models/team.dart | 98 +- lib/src/models/team_list.dart | 42 +- lib/src/models/token.dart | 98 +- lib/src/models/transaction.dart | 98 +- lib/src/models/transaction_list.dart | 43 +- lib/src/models/user.dart | 332 +- lib/src/realtime.dart | 6 +- lib/src/realtime_io.dart | 4 +- lib/src/realtime_message.dart | 2 +- lib/src/realtime_mixin.dart | 31 +- lib/src/realtime_response.dart | 10 +- lib/src/realtime_stub.dart | 4 +- test/channel_test.dart | 42 +- test/query_test.dart | 1 - test/services/account_test.dart | 2691 ++++++++--------- test/services/avatars_test.dart | 204 +- test/services/databases_test.dart | 585 ++-- test/services/functions_test.dart | 188 +- test/services/graphql_test.dart | 71 +- test/services/locale_test.dart | 253 +- test/services/messaging_test.dart | 122 +- test/services/presences_test.dart | 202 +- test/services/storage_test.dart | 341 +-- test/services/tables_db_test.dart | 585 ++-- test/services/teams_test.dart | 555 ++-- test/src/models/algo_argon2_test.dart | 10 +- test/src/models/algo_bcrypt_test.dart | 4 +- test/src/models/algo_md5_test.dart | 4 +- test/src/models/algo_phpass_test.dart | 4 +- .../src/models/algo_scrypt_modified_test.dart | 14 +- test/src/models/algo_scrypt_test.dart | 12 +- test/src/models/algo_sha_test.dart | 4 +- test/src/models/continent_list_test.dart | 6 +- test/src/models/continent_test.dart | 6 +- test/src/models/country_list_test.dart | 6 +- test/src/models/country_test.dart | 6 +- test/src/models/currency_list_test.dart | 6 +- test/src/models/currency_test.dart | 16 +- test/src/models/document_list_test.dart | 6 +- test/src/models/document_test.dart | 16 +- test/src/models/execution_list_test.dart | 6 +- test/src/models/execution_test.dart | 36 +- test/src/models/file_list_test.dart | 6 +- test/src/models/file_test.dart | 30 +- test/src/models/headers_test.dart | 6 +- test/src/models/identity_list_test.dart | 6 +- test/src/models/identity_test.dart | 22 +- test/src/models/jwt_test.dart | 8 +- test/src/models/language_list_test.dart | 6 +- test/src/models/language_test.dart | 8 +- test/src/models/locale_code_list_test.dart | 6 +- test/src/models/locale_code_test.dart | 6 +- test/src/models/locale_test.dart | 16 +- test/src/models/log_list_test.dart | 6 +- test/src/models/log_test.dart | 46 +- test/src/models/membership_list_test.dart | 6 +- test/src/models/membership_test.dart | 32 +- test/src/models/mfa_challenge_test.dart | 10 +- test/src/models/mfa_factors_test.dart | 10 +- test/src/models/mfa_recovery_codes_test.dart | 4 +- test/src/models/mfa_type_test.dart | 10 +- test/src/models/phone_list_test.dart | 6 +- test/src/models/phone_test.dart | 8 +- test/src/models/preferences_test.dart | 1 - test/src/models/presence_list_test.dart | 6 +- test/src/models/presence_test.dart | 14 +- test/src/models/row_list_test.dart | 6 +- test/src/models/row_test.dart | 16 +- test/src/models/session_list_test.dart | 6 +- test/src/models/session_test.dart | 60 +- test/src/models/subscriber_test.dart | 36 +- test/src/models/target_test.dart | 18 +- test/src/models/team_list_test.dart | 6 +- test/src/models/team_test.dart | 12 +- test/src/models/token_test.dart | 14 +- test/src/models/transaction_list_test.dart | 6 +- test/src/models/transaction_test.dart | 14 +- test/src/models/user_test.dart | 32 +- 166 files changed, 8516 insertions(+), 8661 deletions(-) diff --git a/lib/appwrite.dart b/lib/appwrite.dart index 6615de8a..ae51be5e 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.9.x. +/// This SDK is compatible with Appwrite server version 1.9.x. /// For older versions, please check /// [previous releases](https://github.com/appwrite/sdk-for-flutter/releases). library appwrite; diff --git a/lib/channel.dart b/lib/channel.dart index d511f5a4..afc68efa 100644 --- a/lib/channel.dart +++ b/lib/channel.dart @@ -2,19 +2,33 @@ part of appwrite; // Marker classes for type safety class _Root {} + class _Database {} + class _Collection {} + class _Document {} + class _TablesDB {} + class _Table {} + class _Row {} + class _Bucket {} + class _File {} + class _Func {} + class _Execution {} + class _Team {} + class _Membership {} + class _Presence {} + class _Resolved {} // Helper function for normalizing ID @@ -99,15 +113,15 @@ extension DatabaseChannel on Channel<_Database> { /// Only available on Channel<_Collection> extension CollectionChannel on Channel<_Collection> { - Channel<_Document> document([String? id]) => _next<_Document>('documents', id); + Channel<_Document> document([String? id]) => + _next<_Document>('documents', id); } // --- TABLESDB ROUTE --- /// Only available on Channel<_TablesDB> extension TablesDBChannel on Channel<_TablesDB> { - Channel<_Table> table(String id) => - _next<_Table>('tables', id); + Channel<_Table> table(String id) => _next<_Table>('tables', id); } /// Only available on Channel<_Table> 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/operator.dart b/lib/operator.dart index 9dd7f4c7..337dda30 100644 --- a/lib/operator.dart +++ b/lib/operator.dart @@ -31,7 +31,7 @@ class Operator { result['method'] = method; - if(values != null) { + if (values != null) { result['values'] = values is List ? values : [values]; } @@ -147,8 +147,7 @@ class Operator { Operator._('arrayRemove', [value]).toString(); /// Remove duplicate values from an array attribute. - static String arrayUnique() => - Operator._('arrayUnique', []).toString(); + static String arrayUnique() => Operator._('arrayUnique', []).toString(); /// Keep only values that exist in both the current array and the provided array. static String arrayIntersect(List values) => @@ -173,8 +172,7 @@ class Operator { Operator._('stringReplace', [search, replace]).toString(); /// Toggle a boolean attribute. - static String toggle() => - Operator._('toggle', []).toString(); + static String toggle() => Operator._('toggle', []).toString(); /// Add days to a date attribute. static String dateAddDays(int days) => @@ -185,6 +183,5 @@ class Operator { Operator._('dateSubDays', [days]).toString(); /// Set a date attribute to the current date and time. - static String dateSetNow() => - Operator._('dateSetNow', []).toString(); + static String dateSetNow() => Operator._('dateSetNow', []).toString(); } diff --git a/lib/query.dart b/lib/query.dart index 95365bf7..3693dce6 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. @@ -140,50 +140,46 @@ class Query { Query._('notEndsWith', attribute, value).toString(); /// Filter resources where document was created before [value]. - static String createdBefore(String value) => - lessThan('\$createdAt', value); + static String createdBefore(String value) => lessThan('\$createdAt', value); /// Filter resources where document was created after [value]. - static String createdAfter(String value) => - greaterThan('\$createdAt', value); + static String createdAfter(String value) => greaterThan('\$createdAt', value); /// Filter resources where document was created between [start] and [end] (inclusive). static String createdBetween(String start, String end) => between('\$createdAt', start, end); /// Filter resources where document was updated before [value]. - static String updatedBefore(String value) => - lessThan('\$updatedAt', value); + static String updatedBefore(String value) => lessThan('\$updatedAt', value); /// Filter resources where document was updated after [value]. - static String updatedAfter(String value) => - greaterThan('\$updatedAt', value); + static String updatedAfter(String value) => greaterThan('\$updatedAt', value); /// Filter resources where document was updated between [start] and [end] (inclusive). static String updatedBetween(String start, String end) => between('\$updatedAt', start, end); static String or(List queries) => Query._( - 'or', - null, - queries.map((query) => jsonDecode(query)).toList(), - ).toString(); + 'or', + null, + queries.map((query) => jsonDecode(query)).toList(), + ).toString(); static String and(List queries) => Query._( - 'and', - null, - queries.map((query) => jsonDecode(query)).toList(), - ).toString(); + 'and', + null, + queries.map((query) => jsonDecode(query)).toList(), + ).toString(); /// Filter array elements where at least one element matches all the specified queries. /// /// [attribute] The attribute containing the array to filter on. /// [queries] The list of query strings to match against array elements. static String elemMatch(String attribute, List queries) => Query._( - 'elemMatch', - attribute, - queries.map((query) => jsonDecode(query)).toList(), - ).toString(); + 'elemMatch', + attribute, + queries.map((query) => jsonDecode(query)).toList(), + ).toString(); /// Specify which attributes should be returned by the API call. static String select(List attributes) => @@ -198,18 +194,17 @@ class Query { Query._('orderDesc', attribute).toString(); /// Sort results randomly. - static String orderRandom() => - Query._('orderRandom').toString(); + static String orderRandom() => Query._('orderRandom').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) => @@ -219,27 +214,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) => @@ -272,4 +283,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 9c021e93..48b60041 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 { final String apiPath = '/account'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -30,29 +29,30 @@ 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 { final String apiPath = '/account'; - final Map apiParams = { - 'userId': userId, - - 'email': email, - - 'password': password, - - if (name != null) 'name': name, - - }; + final Map apiParams = { + 'userId': userId, + 'email': email, + 'password': password, + if (name != null) 'name': name, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - 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 @@ -62,66 +62,65 @@ 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 { final String apiPath = '/account/email'; - final Map apiParams = { - 'email': email, - - 'password': password, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + 'email': email, + 'password': password, + }; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 list of identities for the currently logged in user. - Future listIdentities({List? queries, bool? total}) async { + Future listIdentities( + {List? queries, bool? total}) async { final String apiPath = '/account/identities'; - final Map apiParams = { - if (queries != null) 'queries': queries, + final Map apiParams = { + if (queries != null) 'queries': queries, + if (total != null) 'total': total, + }; - if (total != null) 'total': total, + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: 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 Map apiParams = { - }; + final String apiPath = '/account/identities/{identityId}' + .replaceAll('{identityId}', identityId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - 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 @@ -132,20 +131,20 @@ class Account extends Service { Future createJWT({int? duration}) async { final String apiPath = '/account/jwts'; - final Map apiParams = { - if (duration != null) 'duration': duration, + final Map apiParams = { + if (duration != null) 'duration': duration, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - 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 @@ -153,212 +152,224 @@ class Account extends Service { Future listLogs({List? queries, bool? total}) async { final String apiPath = '/account/logs'; - final Map apiParams = { - if (queries != null) 'queries': queries, - - if (total != null) 'total': total, - - }; + final Map apiParams = { + if (queries != null) 'queries': queries, + if (total != null) 'total': total, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 { final String apiPath = '/account/mfa'; - final Map apiParams = { - 'mfa': mfa, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + 'mfa': mfa, + }; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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); + @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 apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.MfaType.fromMap(res.data); + 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 = { - }; + Future createMFAAuthenticator( + {required enums.AuthenticatorType type}) async { + final String apiPath = + '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - return models.MfaType.fromMap(res.data); + 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, - - }; + Future updateMFAAuthenticator( + {required enums.AuthenticatorType type, required String otp}) async { + final String apiPath = + '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + 'otp': otp, + }; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - return models.User.fromMap(res.data); + 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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 { final String apiPath = '/account/mfa/challenges'; - final Map apiParams = { - 'factor': factor.value, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + 'factor': factor.value, + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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); } /// 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 { final String apiPath = '/account/mfa/challenges'; - final Map apiParams = { - 'factor': factor.value, + final Map apiParams = { + 'factor': factor.value, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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); } /// Complete the MFA challenge by providing the one-time password. Finish the @@ -366,26 +377,27 @@ 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 { final String apiPath = '/account/mfa/challenges'; - final Map apiParams = { - 'challengeId': challengeId, - - 'otp': otp, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 @@ -393,84 +405,83 @@ 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 { final String apiPath = '/account/mfa/challenges'; - final Map apiParams = { - 'challengeId': challengeId, + final Map apiParams = { + 'challengeId': challengeId, + 'otp': otp, + }; - 'otp': otp, + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 { final String apiPath = '/account/mfa/factors'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 { final String apiPath = '/account/mfa/factors'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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); } /// 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 { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -480,18 +491,17 @@ class Account extends Service { Future getMFARecoveryCodes() async { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -499,22 +509,23 @@ 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 { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 @@ -525,40 +536,41 @@ class Account extends Service { Future createMFARecoveryCodes() async { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 @@ -568,62 +580,62 @@ class Account extends Service { Future updateMFARecoveryCodes() async { final String apiPath = '/account/mfa/recovery-codes'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - 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 { final String apiPath = '/account/name'; - final Map apiParams = { - 'name': name, - - }; + final Map apiParams = { + 'name': name, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 { final String apiPath = '/account/password'; - final Map apiParams = { - 'password': password, - - if (oldPassword != null) 'oldPassword': oldPassword, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + 'password': password, + if (oldPassword != null) 'oldPassword': oldPassword, + }; - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 @@ -631,43 +643,42 @@ 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 { final String apiPath = '/account/phone'; - final Map apiParams = { - 'phone': phone, + final Map apiParams = { + 'phone': phone, + 'password': password, + }; - 'password': password, + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 preferences as a key-value object for the currently logged in user. Future getPrefs() async { final String apiPath = '/account/prefs'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -676,20 +687,20 @@ class Account extends Service { Future updatePrefs({required Map prefs}) async { final String apiPath = '/account/prefs'; - final Map apiParams = { - 'prefs': prefs, + final Map apiParams = { + 'prefs': prefs, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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. @@ -700,25 +711,25 @@ 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 { final String apiPath = '/account/recovery'; - final Map apiParams = { - 'email': email, - - 'url': url, - - }; + final Map apiParams = { + 'email': email, + 'url': url, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 account password reset. Both the @@ -726,32 +737,33 @@ 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 { final 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - 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 @@ -759,18 +771,17 @@ class Account extends Service { Future listSessions() async { final String apiPath = '/account/sessions'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -778,18 +789,17 @@ class Account extends Service { Future deleteSessions() async { final String apiPath = '/account/sessions'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - 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 @@ -802,213 +812,216 @@ class Account extends Service { Future createAnonymousSession() async { final String apiPath = '/account/sessions/anonymous'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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); } /// 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 { final String apiPath = '/account/sessions/email'; - final Map apiParams = { - 'email': email, - - 'password': password, + final Map apiParams = { + 'email': email, + 'password': password, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 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 { final String apiPath = '/account/sessions/magic-url'; - final Map apiParams = { - 'userId': userId, - - 'secret': secret, - - }; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 = { - - if (success != null) 'success': success, - - if (failure != null) 'failure': failure, - - if (scopes != null) 'scopes': scopes, - - - 'project': client.config['project'], - }; - - final List query = []; - - params.forEach((key, value) { - if (value is List) { - for (var item in value) { - query.add( + /// + 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 = { + if (success != null) 'success': success, + if (failure != null) 'failure': failure, + if (scopes != null) '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); + } + } 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 { final String apiPath = '/account/sessions/phone'; - final Map apiParams = { - 'userId': userId, - - 'secret': secret, + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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); } /// 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 { final String apiPath = '/account/sessions/token'; - final Map apiParams = { - 'userId': userId, - - 'secret': secret, - - }; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 String apiPath = + '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, @@ -1017,20 +1030,20 @@ 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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 @@ -1039,18 +1052,18 @@ class Account extends Service { Future updateStatus() async { final String apiPath = '/account/status'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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); } /// Use this endpoint to register a device for push notifications. Provide a @@ -1058,27 +1071,28 @@ 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 { final String apiPath = '/account/targets/push'; - final Map apiParams = { - 'targetId': targetId, - - 'identifier': identifier, - - if (providerId != null) 'providerId': providerId, - - }; + final Map apiParams = { + 'targetId': targetId, + 'identifier': identifier, + if (providerId != null) 'providerId': providerId, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 @@ -1086,43 +1100,45 @@ 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, + 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Target.fromMap(res.data); + 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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 @@ -1134,32 +1150,31 @@ 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 { final String apiPath = '/account/tokens/email'; - final Map apiParams = { - 'userId': userId, + final Map apiParams = { + 'userId': userId, + 'email': email, + if (phrase != null) 'phrase': phrase, + }; - 'email': email, + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - if (phrase != null) 'phrase': phrase, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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); } /// Sends the user an email with a secret key for creating a session. If the @@ -1171,87 +1186,88 @@ 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 { final String apiPath = '/account/tokens/magic-url'; - final Map apiParams = { - 'userId': userId, - - 'email': email, - - if (url != null) 'url': url, - - if (phrase != null) 'phrase': phrase, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + 'userId': userId, + 'email': email, + if (url != null) 'url': url, + if (phrase != null) 'phrase': phrase, + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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); } /// 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 = { - - if (success != null) 'success': success, - - if (failure != null) 'failure': failure, - - if (scopes != null) 'scopes': scopes, - - - 'project': client.config['project'], - }; - - final List query = []; - - params.forEach((key, value) { - if (value is List) { - for (var item in value) { - query.add( + 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 = { + if (success != null) 'success': success, + if (failure != null) 'failure': failure, + if (scopes != null) '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); + } + } 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 @@ -1260,29 +1276,29 @@ 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 { final String apiPath = '/account/tokens/phone'; - final Map apiParams = { - 'userId': userId, - - 'phone': phone, + final Map apiParams = { + 'userId': userId, + 'phone': phone, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 @@ -1294,29 +1310,29 @@ 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 createEmailVerification({required String url}) async { final String apiPath = '/account/verifications/email'; - final Map apiParams = { - 'url': url, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + 'url': url, + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 send a verification message to your user email address @@ -1328,81 +1344,83 @@ 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. - /// - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.createEmailVerification` instead.') + /// + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.createEmailVerification` instead.') Future createVerification({required String url}) async { final String apiPath = '/account/verifications/email'; - final Map apiParams = { - 'url': url, + final Map apiParams = { + 'url': url, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 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 updateEmailVerification({required String userId, required String secret}) async { + Future updateEmailVerification( + {required String userId, required String secret}) async { final String apiPath = '/account/verifications/email'; - final Map apiParams = { - 'userId': userId, - - 'secret': secret, - - }; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - 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 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. - @Deprecated('This API has been deprecated since 1.8.0. Please use `Account.updateEmailVerification` instead.') - Future updateVerification({required String userId, required String secret}) async { + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `Account.updateEmailVerification` instead.') + Future updateVerification( + {required String userId, required String secret}) async { final String apiPath = '/account/verifications/email'; - final Map apiParams = { - 'userId': userId, - - 'secret': secret, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 @@ -1416,42 +1434,42 @@ class Account extends Service { Future createPhoneVerification() async { final String apiPath = '/account/verifications/phone'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 { final String apiPath = '/account/verifications/phone'; - final Map apiParams = { - 'userId': userId, - - 'secret': secret, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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); } } diff --git a/lib/services/avatars.dart b/lib/services/avatars.dart index 4dca3b16..cdd93e6e 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,139 +11,134 @@ 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 = { - - if (width != null) 'width': width, - - if (height != null) 'height': height, - - if (quality != null) 'quality': quality, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + if (width != null) 'width': width, + if (height != null) 'height': height, + if (quality != null) 'quality': quality, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 = { - - if (width != null) 'width': width, - - if (height != null) 'height': height, - - if (quality != null) 'quality': quality, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + if (width != null) 'width': width, + if (height != null) 'height': height, + if (quality != null) 'quality': quality, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 { final String apiPath = '/avatars/favicon'; - final Map params = { - - 'url': url, + final Map params = { + 'url': url, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { - - if (width != null) 'width': width, - - if (height != null) 'height': height, - - if (quality != null) 'quality': quality, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + if (width != null) 'width': width, + if (height != null) 'height': height, + if (quality != null) 'quality': quality, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 { final String apiPath = '/avatars/image'; - final Map params = { - - 'url': url, - - if (width != null) 'width': width, - - if (height != null) 'height': height, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + 'url': url, + if (width != null) 'width': width, + if (height != null) 'height': height, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 @@ -151,125 +146,117 @@ 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 { final String apiPath = '/avatars/initials'; - final Map params = { - - if (name != null) 'name': name, - - if (width != null) 'width': width, - - if (height != null) 'height': height, - - if (background != null) 'background': background, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + if (name != null) 'name': name, + if (width != null) 'width': width, + if (height != null) 'height': height, + if (background != null) 'background': background, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 { final String apiPath = '/avatars/qr'; - final Map params = { - - 'text': text, - - if (size != null) 'size': size, - - if (margin != null) 'margin': margin, - - if (download != null) 'download': download, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + 'text': text, + if (size != null) 'size': size, + if (margin != null) 'margin': margin, + if (download != null) 'download': download, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + final res = await client.call(HttpMethod.get, + path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } /// Use this endpoint to capture a screenshot of any website URL. This endpoint /// uses a headless browser to render the webpage and capture it as an image. - /// + /// /// You can configure the browser viewport size, theme, user agent, /// geolocation, permissions, and more. Capture either just the viewport or the /// full page scroll. - /// + /// /// When width and height are specified, the image is resized accordingly. If /// both dimensions are 0, the API provides an image at original size. If /// dimensions are not specified, the default viewport size is 1280x720px. - Future getScreenshot({required String url, Map? headers, int? viewportWidth, int? viewportHeight, double? scale, enums.BrowserTheme? theme, String? userAgent, bool? fullpage, String? locale, enums.Timezone? timezone, double? latitude, double? longitude, double? accuracy, bool? touch, List? permissions, int? sleep, int? width, int? height, int? quality, enums.ImageFormat? output}) async { + Future getScreenshot( + {required String url, + Map? headers, + int? viewportWidth, + int? viewportHeight, + double? scale, + enums.BrowserTheme? theme, + String? userAgent, + bool? fullpage, + String? locale, + enums.Timezone? timezone, + double? latitude, + double? longitude, + double? accuracy, + bool? touch, + List? permissions, + int? sleep, + int? width, + int? height, + int? quality, + enums.ImageFormat? output}) async { final String apiPath = '/avatars/screenshots'; - final Map params = { - - 'url': url, - - if (headers != null) 'headers': headers, - - if (viewportWidth != null) 'viewportWidth': viewportWidth, - - if (viewportHeight != null) 'viewportHeight': viewportHeight, - - if (scale != null) 'scale': scale, - - if (theme != null) 'theme': theme.value, - - if (userAgent != null) 'userAgent': userAgent, - - if (fullpage != null) 'fullpage': fullpage, - - if (locale != null) 'locale': locale, - - if (timezone != null) 'timezone': timezone.value, - - if (latitude != null) 'latitude': latitude, - - if (longitude != null) 'longitude': longitude, - - if (accuracy != null) 'accuracy': accuracy, - - if (touch != null) 'touch': touch, - - if (permissions != null) 'permissions': permissions.map((e) => e.value).toList(), - - if (sleep != null) 'sleep': sleep, - - if (width != null) 'width': width, - - if (height != null) 'height': height, - - if (quality != null) 'quality': quality, - - if (output != null) 'output': output.value, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); - return res.data; + final Map params = { + 'url': url, + if (headers != null) 'headers': headers, + if (viewportWidth != null) 'viewportWidth': viewportWidth, + if (viewportHeight != null) 'viewportHeight': viewportHeight, + if (scale != null) 'scale': scale, + if (theme != null) 'theme': theme.value, + if (userAgent != null) 'userAgent': userAgent, + if (fullpage != null) 'fullpage': fullpage, + if (locale != null) 'locale': locale, + if (timezone != null) 'timezone': timezone.value, + if (latitude != null) 'latitude': latitude, + if (longitude != null) 'longitude': longitude, + if (accuracy != null) 'accuracy': accuracy, + if (touch != null) 'touch': touch, + if (permissions != null) + 'permissions': permissions.map((e) => e.value).toList(), + if (sleep != null) 'sleep': sleep, + if (width != null) 'width': width, + if (height != null) 'height': height, + if (quality != null) 'quality': quality, + if (output != null) 'output': output.value, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + final res = await client.call(HttpMethod.get, + path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } } diff --git a/lib/services/databases.dart b/lib/services/databases.dart index 0bfd935a..0ff3fb72 100644 --- a/lib/services/databases.dart +++ b/lib/services/databases.dart @@ -1,339 +1,418 @@ 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); /// List transactions across all databases. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.listTransactions` instead.') - Future listTransactions({List? queries}) async { + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.listTransactions` instead.') + Future listTransactions( + {List? queries}) async { final String apiPath = '/databases/transactions'; - final Map apiParams = { - if (queries != null) 'queries': queries, + final Map apiParams = { + if (queries != null) 'queries': queries, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.TransactionList.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.TransactionList.fromMap(res.data); } /// Create a new transaction. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.createTransaction` instead.') + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.createTransaction` instead.') Future createTransaction({int? ttl}) async { final String apiPath = '/databases/transactions'; - final Map apiParams = { - if (ttl != null) 'ttl': ttl, - - }; + final Map apiParams = { + if (ttl != null) 'ttl': ttl, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Transaction.fromMap(res.data); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.Transaction.fromMap(res.data); } /// Get a transaction by its unique ID. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.getTransaction` instead.') - Future getTransaction({required String transactionId}) async { - final String apiPath = '/databases/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - }; + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.getTransaction` instead.') + Future getTransaction( + {required String transactionId}) async { + final String apiPath = '/databases/transactions/{transactionId}' + .replaceAll('{transactionId}', transactionId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - return models.Transaction.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.Transaction.fromMap(res.data); } /// Update a transaction, to either commit or roll back its operations. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.updateTransaction` instead.') - Future updateTransaction({required String transactionId, bool? commit, bool? rollback}) async { - final String apiPath = '/databases/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - if (commit != null) 'commit': commit, - - if (rollback != null) 'rollback': rollback, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Transaction.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.updateTransaction` instead.') + Future updateTransaction( + {required String transactionId, bool? commit, bool? rollback}) async { + final String apiPath = '/databases/transactions/{transactionId}' + .replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + if (commit != null) 'commit': commit, + if (rollback != null) 'rollback': rollback, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Transaction.fromMap(res.data); } /// Delete a transaction by its unique ID. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.deleteTransaction` instead.') + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.deleteTransaction` instead.') Future deleteTransaction({required String transactionId}) async { - final String apiPath = '/databases/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - }; + final String apiPath = '/databases/transactions/{transactionId}' + .replaceAll('{transactionId}', transactionId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - return res.data; + final res = await client.call(HttpMethod.delete, + path: apiPath, params: apiParams, headers: apiHeaders); + return res.data; } /// Create multiple operations in a single transaction. - @Deprecated('This API has been deprecated since 1.8.0. Please use `TablesDB.createOperations` instead.') - Future createOperations({required String transactionId, List? operations}) async { - final String apiPath = '/databases/transactions/{transactionId}/operations'.replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - if (operations != null) 'operations': operations, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Transaction.fromMap(res.data); - + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.createOperations` instead.') + Future createOperations( + {required String transactionId, List? operations}) async { + final String apiPath = '/databases/transactions/{transactionId}/operations' + .replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + if (operations != null) 'operations': operations, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Transaction.fromMap(res.data); } /// 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, String? transactionId, bool? total, int? ttl}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - - if (transactionId != null) 'transactionId': transactionId, - - if (total != null) 'total': total, - - if (ttl != null) 'ttl': ttl, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, + String? transactionId, + bool? total, + int? ttl}) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + if (transactionId != null) 'transactionId': transactionId, + if (total != null) 'total': total, + if (ttl != null) 'ttl': ttl, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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, String? transactionId}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); - - final Map apiParams = { - 'documentId': documentId, - - 'data': data, - - 'permissions': permissions, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + String? transactionId}) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId); + + final Map apiParams = { + 'documentId': documentId, + 'data': data, + 'permissions': permissions, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, String? transactionId}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - - if (transactionId != null) 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, + String? transactionId}) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + if (transactionId != null) 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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, Map? data, List? permissions, String? transactionId}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - - final Map apiParams = { - if (data != null) 'data': data, - - 'permissions': permissions, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + Map? data, + List? permissions, + String? transactionId}) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId); + + final Map apiParams = { + if (data != null) 'data': data, + 'permissions': permissions, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, String? transactionId}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - - final Map apiParams = { - if (data != null) 'data': data, - - 'permissions': permissions, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + String? transactionId}) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId); + + final Map apiParams = { + if (data != null) 'data': data, + 'permissions': permissions, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, String? transactionId}) async { - final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); - - final Map apiParams = { - if (transactionId != null) 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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, + String? transactionId}) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{documentId}', documentId); + + final Map apiParams = { + if (transactionId != null) 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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, String? transactionId}) 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 = { - if (value != null) 'value': value, - - 'min': min, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + String? transactionId}) 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 = { + if (value != null) 'value': value, + 'min': min, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, String? transactionId}) 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 = { - if (value != null) 'value': value, - - 'max': max, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + String? transactionId}) 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 = { + if (value != null) 'value': value, + 'max': max, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Document.fromMap(res.data); } } diff --git a/lib/services/functions.dart b/lib/services/functions.dart index 0640f80f..ed97921b 100644 --- a/lib/services/functions.dart +++ b/lib/services/functions.dart @@ -1,82 +1,87 @@ 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, bool? total}) async { - final String apiPath = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); + Future listExecutions( + {required String functionId, List? queries, bool? total}) async { + final String apiPath = '/functions/{functionId}/executions' + .replaceAll('{functionId}', functionId); - final Map apiParams = { - if (queries != null) 'queries': queries, + final Map apiParams = { + if (queries != null) 'queries': queries, + if (total != null) 'total': total, + }; - if (total != null) 'total': total, + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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 = { - if (body != null) 'body': body, - - if (xasync != null) 'async': xasync, - - if (path != null) 'path': path, - - if (method != null) 'method': method.value, - - if (headers != null) 'headers': headers, - - 'scheduledAt': scheduledAt, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + if (body != null) 'body': body, + if (xasync != null) 'async': xasync, + if (path != null) 'path': path, + if (method != null) 'method': method.value, + if (headers != null) 'headers': headers, + 'scheduledAt': scheduledAt, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 = { - }; + Future getExecution( + {required String functionId, required String executionId}) async { + final String apiPath = '/functions/{functionId}/executions/{executionId}' + .replaceAll('{functionId}', functionId) + .replaceAll('{executionId}', executionId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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); } } diff --git a/lib/services/graphql.dart b/lib/services/graphql.dart index 978331fa..c86f3719 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,39 +10,41 @@ class Graphql extends Service { Future query({required Map query}) async { final String apiPath = '/graphql'; - final Map apiParams = { - 'query': query, + final Map apiParams = { + 'query': query, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'x-sdk-graphql': 'true', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'x-sdk-graphql': 'true', 'content-type': 'application/json', 'accept': '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 { final String apiPath = '/graphql/mutation'; - final Map apiParams = { - 'query': query, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'x-sdk-graphql': 'true', 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + 'query': query, + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'x-sdk-graphql': 'true', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - return res.data; + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); + return res.data; } } diff --git a/lib/services/locale.dart b/lib/services/locale.dart index c45a1269..87ea162e 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 { final String apiPath = '/locale'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -34,18 +33,17 @@ class Locale extends Service { Future listCodes() async { final String apiPath = '/locale/codes'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -53,18 +51,17 @@ class Locale extends Service { Future listContinents() async { final String apiPath = '/locale/continents'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -72,18 +69,17 @@ class Locale extends Service { Future listCountries() async { final String apiPath = '/locale/countries'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -91,18 +87,17 @@ class Locale extends Service { Future listCountriesEU() async { final String apiPath = '/locale/countries/eu'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -110,18 +105,17 @@ class Locale extends Service { Future listCountriesPhones() async { final String apiPath = '/locale/countries/phones'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -130,18 +124,17 @@ class Locale extends Service { Future listCurrencies() async { final String apiPath = '/locale/currencies'; - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 @@ -149,17 +142,16 @@ class Locale extends Service { Future listLanguages() async { final String apiPath = '/locale/languages'; - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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); } } diff --git a/lib/services/messaging.dart b/lib/services/messaging.dart index 3dffe41b..61ecefee 100644 --- a/lib/services/messaging.dart +++ b/lib/services/messaging.dart @@ -1,48 +1,54 @@ 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - return res.data; + final res = await client.call(HttpMethod.delete, + path: apiPath, params: apiParams, headers: apiHeaders); + return res.data; } } diff --git a/lib/services/presences.dart b/lib/services/presences.dart index 088700cb..1c9b651b 100644 --- a/lib/services/presences.dart +++ b/lib/services/presences.dart @@ -5,123 +5,127 @@ class Presences extends Service { Presences(super.client); /// List presence logs. Expired entries are filtered out automatically. - /// - Future list({List? queries, bool? total, int? ttl}) async { + /// + Future list( + {List? queries, bool? total, int? ttl}) async { final String apiPath = '/presences'; - final Map apiParams = { - if (queries != null) 'queries': queries, + final Map apiParams = { + if (queries != null) 'queries': queries, + if (total != null) 'total': total, + if (ttl != null) 'ttl': ttl, + }; - if (total != null) 'total': total, + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - if (ttl != null) 'ttl': ttl, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.PresenceList.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.PresenceList.fromMap(res.data); } /// Get a presence log by its unique ID. Entries whose `expiresAt` is in the /// past are treated as not found. - /// + /// Future get({required String presenceId}) async { - final String apiPath = '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); + final String apiPath = + '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); - final Map apiParams = { - }; + final Map apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Presence.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.Presence.fromMap(res.data); } /// Create or update a presence log by its user ID. - /// - Future upsert({required String presenceId, required String status, List? permissions, String? expiresAt, Map? metadata}) async { - final String apiPath = '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); - - final Map apiParams = { - 'status': status, - - if (permissions != null) 'permissions': permissions, - - if (expiresAt != null) 'expiresAt': expiresAt, - - if (metadata != null) 'metadata': metadata, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Presence.fromMap(res.data); - + /// + Future upsert( + {required String presenceId, + required String status, + List? permissions, + String? expiresAt, + Map? metadata}) async { + final String apiPath = + '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); + + final Map apiParams = { + 'status': status, + if (permissions != null) 'permissions': permissions, + if (expiresAt != null) 'expiresAt': expiresAt, + if (metadata != null) 'metadata': metadata, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Presence.fromMap(res.data); } /// Update a presence log by its unique ID. Using the patch method you can pass /// only specific fields that will get updated. - /// - Future update({required String presenceId, String? status, String? expiresAt, Map? metadata, List? permissions, bool? purge}) async { - final String apiPath = '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); - - final Map apiParams = { - if (status != null) 'status': status, - - if (expiresAt != null) 'expiresAt': expiresAt, - - if (metadata != null) 'metadata': metadata, - - if (permissions != null) 'permissions': permissions, - - if (purge != null) 'purge': purge, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Presence.fromMap(res.data); - + /// + Future update( + {required String presenceId, + String? status, + String? expiresAt, + Map? metadata, + List? permissions, + bool? purge}) async { + final String apiPath = + '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); + + final Map apiParams = { + if (status != null) 'status': status, + if (expiresAt != null) 'expiresAt': expiresAt, + if (metadata != null) 'metadata': metadata, + if (permissions != null) 'permissions': permissions, + if (purge != null) 'purge': purge, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Presence.fromMap(res.data); } /// Delete a presence log by its unique ID. - /// + /// Future delete({required String presenceId}) async { - final String apiPath = '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); - - final Map apiParams = { - }; + final String apiPath = + '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - return res.data; + final res = await client.call(HttpMethod.delete, + path: apiPath, params: apiParams, headers: apiHeaders); + return res.data; } } diff --git a/lib/services/storage.dart b/lib/services/storage.dart index c9499a99..cdb626de 100644 --- a/lib/services/storage.dart +++ b/lib/services/storage.dart @@ -1,166 +1,178 @@ 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, bool? total}) async { - final String apiPath = '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - - if (search != null) 'search': search, - - if (total != null) 'total': total, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, + bool? total}) async { + final String apiPath = + '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + if (search != null) 'search': search, + if (total != null) 'total': total, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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, - - if (permissions != null) 'permissions': permissions, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'multipart/form-data', 'accept': 'application/json', - }; - - 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, + if (permissions != null) 'permissions': permissions, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'multipart/form-data', + 'accept': 'application/json', + }; + + 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); + 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 apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.File.fromMap(res.data); + 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 = { - if (name != null) 'name': name, - - 'permissions': permissions, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + if (name != null) 'name': name, + 'permissions': permissions, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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 = { - - if (token != null) 'token': token, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + if (token != null) 'token': token, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 @@ -168,60 +180,64 @@ 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 = { - - if (width != null) 'width': width, - - if (height != null) 'height': height, - - if (gravity != null) 'gravity': gravity.value, - - if (quality != null) 'quality': quality, - - if (borderWidth != null) 'borderWidth': borderWidth, - - if (borderColor != null) 'borderColor': borderColor, - - if (borderRadius != null) 'borderRadius': borderRadius, - - if (opacity != null) 'opacity': opacity, - - if (rotation != null) 'rotation': rotation, - - if (background != null) 'background': background, - - if (output != null) 'output': output.value, - - if (token != null) 'token': token, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + if (width != null) 'width': width, + if (height != null) 'height': height, + if (gravity != null) 'gravity': gravity.value, + if (quality != null) 'quality': quality, + if (borderWidth != null) 'borderWidth': borderWidth, + if (borderColor != null) 'borderColor': borderColor, + if (borderRadius != null) 'borderRadius': borderRadius, + if (opacity != null) 'opacity': opacity, + if (rotation != null) 'rotation': rotation, + if (background != null) 'background': background, + if (output != null) 'output': output.value, + if (token != null) 'token': token, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + 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 = { - - if (token != null) 'token': token, - - - 'project': client.config['project'], - 'impersonateuserid': client.config['impersonateuserid'], - }; - - 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 = { + if (token != null) 'token': token, + 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], + }; + + final res = await client.call(HttpMethod.get, + path: apiPath, params: params, responseType: ResponseType.bytes); + return res.data; } } diff --git a/lib/services/tables_db.dart b/lib/services/tables_db.dart index 42572021..8b6284b3 100644 --- a/lib/services/tables_db.dart +++ b/lib/services/tables_db.dart @@ -5,319 +5,382 @@ class TablesDB extends Service { TablesDB(super.client); /// List transactions across all databases. - Future listTransactions({List? queries}) async { + Future listTransactions( + {List? queries}) async { final String apiPath = '/tablesdb/transactions'; - final Map apiParams = { - if (queries != null) 'queries': queries, + final Map apiParams = { + if (queries != null) 'queries': queries, + }; - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.TransactionList.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.TransactionList.fromMap(res.data); } /// Create a new transaction. Future createTransaction({int? ttl}) async { final String apiPath = '/tablesdb/transactions'; - final Map apiParams = { - if (ttl != null) 'ttl': ttl, - - }; + final Map apiParams = { + if (ttl != null) 'ttl': ttl, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Transaction.fromMap(res.data); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.Transaction.fromMap(res.data); } /// Get a transaction by its unique ID. - Future getTransaction({required String transactionId}) async { - final String apiPath = '/tablesdb/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - }; + Future getTransaction( + {required String transactionId}) async { + final String apiPath = '/tablesdb/transactions/{transactionId}' + .replaceAll('{transactionId}', transactionId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - return models.Transaction.fromMap(res.data); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.Transaction.fromMap(res.data); } /// Update a transaction, to either commit or roll back its operations. - Future updateTransaction({required String transactionId, bool? commit, bool? rollback}) async { - final String apiPath = '/tablesdb/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - if (commit != null) 'commit': commit, - - if (rollback != null) 'rollback': rollback, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; - - final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); - - return models.Transaction.fromMap(res.data); - + Future updateTransaction( + {required String transactionId, bool? commit, bool? rollback}) async { + final String apiPath = '/tablesdb/transactions/{transactionId}' + .replaceAll('{transactionId}', transactionId); + + final Map apiParams = { + if (commit != null) 'commit': commit, + if (rollback != null) 'rollback': rollback, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Transaction.fromMap(res.data); } /// Delete a transaction by its unique ID. Future deleteTransaction({required String transactionId}) async { - final String apiPath = '/tablesdb/transactions/{transactionId}'.replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - }; + final String apiPath = '/tablesdb/transactions/{transactionId}' + .replaceAll('{transactionId}', transactionId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - return res.data; + final res = await client.call(HttpMethod.delete, + path: apiPath, params: apiParams, headers: apiHeaders); + return res.data; } /// Create multiple operations in a single transaction. - Future createOperations({required String transactionId, List? operations}) async { - final String apiPath = '/tablesdb/transactions/{transactionId}/operations'.replaceAll('{transactionId}', transactionId); - - final Map apiParams = { - if (operations != null) 'operations': operations, - - }; + Future createOperations( + {required String transactionId, List? operations}) async { + final String apiPath = '/tablesdb/transactions/{transactionId}/operations' + .replaceAll('{transactionId}', transactionId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + if (operations != null) 'operations': operations, + }; - final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - return models.Transaction.fromMap(res.data); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); + return models.Transaction.fromMap(res.data); } /// 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, String? transactionId, bool? total, int? ttl}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - - if (transactionId != null) 'transactionId': transactionId, - - if (total != null) 'total': total, - - if (ttl != null) 'ttl': ttl, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, + String? transactionId, + bool? total, + int? ttl}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + if (transactionId != null) 'transactionId': transactionId, + if (total != null) 'total': total, + if (ttl != null) 'ttl': ttl, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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/references/cloud/server-dart/tablesDB#createTable) /// API or directly from your database console. - Future createRow({required String databaseId, required String tableId, required String rowId, required Map data, List? permissions, String? transactionId}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId); - - final Map apiParams = { - 'rowId': rowId, - - 'data': data, - - 'permissions': permissions, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + String? transactionId}) async { + final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId); + + final Map apiParams = { + 'rowId': rowId, + 'data': data, + 'permissions': permissions, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, String? transactionId}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - - if (transactionId != null) 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, + String? transactionId}) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + if (transactionId != null) 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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/references/cloud/server-dart/tablesDB#createTable) /// API or directly from your database console. - Future upsertRow({required String databaseId, required String tableId, required String rowId, Map? data, List? permissions, String? transactionId}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - if (data != null) 'data': data, - - 'permissions': permissions, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + String? transactionId}) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId); + + final Map apiParams = { + if (data != null) 'data': data, + 'permissions': permissions, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, String? transactionId}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - if (data != null) 'data': data, - - 'permissions': permissions, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + String? transactionId}) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId); + + final Map apiParams = { + if (data != null) 'data': data, + 'permissions': permissions, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, String? transactionId}) async { - final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}'.replaceAll('{databaseId}', databaseId).replaceAll('{tableId}', tableId).replaceAll('{rowId}', rowId); - - final Map apiParams = { - if (transactionId != null) 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - '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, + String? transactionId}) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{rowId}', rowId); + + final Map apiParams = { + if (transactionId != null) 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + '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, String? transactionId}) 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 = { - if (value != null) 'value': value, - - 'min': min, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + String? transactionId}) 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 = { + if (value != null) 'value': value, + 'min': min, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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, String? transactionId}) 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 = { - if (value != null) 'value': value, - - 'max': max, - - 'transactionId': transactionId, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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, + String? transactionId}) 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 = { + if (value != null) 'value': value, + 'max': max, + 'transactionId': transactionId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Row.fromMap(res.data); } } diff --git a/lib/services/teams.dart b/lib/services/teams.dart index 27bc561e..1f4022f6 100644 --- a/lib/services/teams.dart +++ b/lib/services/teams.dart @@ -1,98 +1,97 @@ 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); /// Get a list of all the teams in which the current user is a member. You can /// use the parameters to filter your results. - Future list({List? queries, String? search, bool? total}) async { + Future list( + {List? queries, String? search, bool? total}) async { final String apiPath = '/teams'; - final Map apiParams = { - if (queries != null) 'queries': queries, + final Map apiParams = { + if (queries != null) 'queries': queries, + if (search != null) 'search': search, + if (total != null) 'total': total, + }; - if (search != null) 'search': search, + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - if (total != null) 'total': total, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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 { final String apiPath = '/teams'; - final Map apiParams = { - 'teamId': teamId, - - 'name': name, - - if (roles != null) 'roles': roles, - - }; + final Map apiParams = { + 'teamId': teamId, + 'name': name, + if (roles != null) 'roles': roles, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 apiParams = { + 'name': name, + }; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); - - 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 @@ -100,44 +99,45 @@ class Teams extends Service { Future delete({required String teamId}) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map apiParams = { - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - 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, bool? total}) async { - final String apiPath = '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); - - final Map apiParams = { - if (queries != null) 'queries': queries, - - if (search != null) 'search': search, - - if (total != null) 'total': total, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; - - 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, + bool? total}) async { + final String apiPath = + '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); + + final Map apiParams = { + if (queries != null) 'queries': queries, + if (search != null) 'search': search, + if (total != null) 'total': total, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + 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 @@ -146,180 +146,199 @@ 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 = { - if (email != null) 'email': email, - - if (userId != null) 'userId': userId, - - if (phone != null) 'phone': phone, - - 'roles': roles, - - if (url != null) 'url': url, - - if (name != null) 'name': name, - - }; - - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + if (email != null) 'email': email, + if (userId != null) 'userId': userId, + if (phone != null) 'phone': phone, + 'roles': roles, + if (url != null) 'url': url, + if (name != null) 'name': name, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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); + 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 apiParams = {}; - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 = { - }; + Future deleteMembership( + {required String teamId, required String membershipId}) async { + final String apiPath = '/teams/{teamId}/memberships/{membershipId}' + .replaceAll('{teamId}', teamId) + .replaceAll('{membershipId}', membershipId); - final Map apiHeaders = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', - }; + final Map apiParams = {}; - final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + }; - 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': '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 = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'accept': 'application/json', - }; + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; - 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 = { - 'X-Appwrite-Project': client.config['project'] ?? '', - 'content-type': 'application/json', 'accept': 'application/json', - }; + final Map apiParams = { + 'prefs': prefs, + }; - final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': '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); } } diff --git a/lib/src/client.dart b/lib/src/client.dart index 65b2f044..cc077e56 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -27,7 +27,8 @@ abstract class Client { factory Client({ String endPoint = 'https://cloud.appwrite.io/v1', bool selfSigned = false, - }) => createClient(endPoint: endPoint, selfSigned: selfSigned); + }) => + createClient(endPoint: endPoint, selfSigned: selfSigned); /// Handle OAuth2 session creation. Future webAuth(Uri url, {String? callbackUrlScheme}); @@ -107,7 +108,6 @@ abstract class Client { /// Send a ping to project as part of onboarding. Future ping(); - /// Send the API request. Future call( HttpMethod method, { diff --git a/lib/src/client_base.dart b/lib/src/client_base.dart index 9e964a79..da1a5225 100644 --- a/lib/src/client_base.dart +++ b/lib/src/client_base.dart @@ -6,26 +6,33 @@ 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); + /// The user cookie to authenticate with. Used by SDKs that forward an incoming Cookie header in server-side runtimes. @override ClientBase setCookie(value); + /// Impersonate a user by ID @override ClientBase setImpersonateUserId(value); + /// Impersonate a user by email @override ClientBase setImpersonateUserEmail(value); + /// Impersonate a user by phone @override ClientBase setImpersonateUserPhone(value); diff --git a/lib/src/client_browser.dart b/lib/src/client_browser.dart index 2f4c7b48..32945efd 100644 --- a/lib/src/client_browser.dart +++ b/lib/src/client_browser.dart @@ -62,6 +62,7 @@ class ClientBrowser extends ClientBase with ClientMixin { config['project'] = value; return this; } + /// Your secret JSON Web Token @override ClientBrowser setJWT(value) { @@ -69,12 +70,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) { @@ -82,6 +85,7 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Session', value); return this; } + /// Your secret dev API key @override ClientBrowser setDevKey(value) { @@ -89,6 +93,7 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Dev-Key', value); return this; } + /// The user cookie to authenticate with. Used by SDKs that forward an incoming Cookie header in server-side runtimes. @override ClientBrowser setCookie(value) { @@ -96,6 +101,7 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('Cookie', value); return this; } + /// Impersonate a user by ID @override ClientBrowser setImpersonateUserId(value) { @@ -103,6 +109,7 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Impersonate-User-Id', value); return this; } + /// Impersonate a user by email @override ClientBrowser setImpersonateUserEmail(value) { @@ -110,6 +117,7 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Impersonate-User-Email', value); return this; } + /// Impersonate a user by phone @override ClientBrowser setImpersonateUserPhone(value) { @@ -219,7 +227,8 @@ class ClientBrowser extends ClientBase with ClientMixin { final totalChunks = (size / chunkSize).ceil(); - Future uploadChunk(int index, int start, int end, String? id) async { + Future uploadChunk( + int index, int start, int end, String? id) async { List chunk = []; chunk = file.bytes!.getRange(start, end).toList(); @@ -257,7 +266,9 @@ class ClientBrowser extends ClientBase with ClientMixin { bool isUploadComplete(Response response) { final chunksUploaded = response.data['chunksUploaded']; final chunksTotal = response.data['chunksTotal'] ?? totalChunks; - return chunksUploaded is num && chunksTotal is num && chunksUploaded >= chunksTotal; + return chunksUploaded is num && + chunksTotal is num && + chunksUploaded >= chunksTotal; } final progress = UploadProgress( diff --git a/lib/src/client_io.dart b/lib/src/client_io.dart index 6e6e2ee8..78a368ae 100644 --- a/lib/src/client_io.dart +++ b/lib/src/client_io.dart @@ -88,6 +88,7 @@ class ClientIO extends ClientBase with ClientMixin { config['project'] = value; return this; } + /// Your secret JSON Web Token @override ClientIO setJWT(value) { @@ -95,12 +96,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) { @@ -108,6 +111,7 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Session', value); return this; } + /// Your secret dev API key @override ClientIO setDevKey(value) { @@ -115,6 +119,7 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Dev-Key', value); return this; } + /// The user cookie to authenticate with. Used by SDKs that forward an incoming Cookie header in server-side runtimes. @override ClientIO setCookie(value) { @@ -122,6 +127,7 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('Cookie', value); return this; } + /// Impersonate a user by ID @override ClientIO setImpersonateUserId(value) { @@ -129,6 +135,7 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Impersonate-User-Id', value); return this; } + /// Impersonate a user by email @override ClientIO setImpersonateUserEmail(value) { @@ -136,6 +143,7 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Impersonate-User-Email', value); return this; } + /// Impersonate a user by phone @override ClientIO setImpersonateUserPhone(value) { @@ -394,7 +402,9 @@ class ClientIO extends ClientBase with ClientMixin { bool isUploadComplete(Response response) { final chunksUploaded = response.data['chunksUploaded']; final chunksTotal = response.data['chunksTotal'] ?? totalChunks; - return chunksUploaded is num && chunksTotal is num && chunksUploaded >= chunksTotal; + return chunksUploaded is num && + chunksTotal is num && + chunksUploaded >= chunksTotal; } final progress = UploadProgress( @@ -418,7 +428,8 @@ class ClientIO extends ClientBase with ClientMixin { var nextChunk = 0; Future uploadNext() async { - final raf = file.bytes == null ? await iofile!.open(mode: FileMode.read) : null; + final raf = + file.bytes == null ? await iofile!.open(mode: FileMode.read) : null; try { while (nextChunk < chunks.length) { final chunk = chunks[nextChunk++]; diff --git a/lib/src/client_mixin.dart b/lib/src/client_mixin.dart index 40484946..89aad359 100644 --- a/lib/src/client_mixin.dart +++ b/lib/src/client_mixin.dart @@ -12,7 +12,6 @@ mixin ClientMixin { required Map headers, required Map params, }) { - http.BaseRequest request = http.Request(method.name(), uri); if (headers['content-type'] == 'multipart/form-data') { request = http.MultipartRequest(method.name(), uri); @@ -128,9 +127,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/browser_permission.dart b/lib/src/enums/browser_permission.dart index 765b3e0c..fb4983db 100644 --- a/lib/src/enums/browser_permission.dart +++ b/lib/src/enums/browser_permission.dart @@ -1,32 +1,30 @@ part of '../../enums.dart'; enum BrowserPermission { - geolocation(value: 'geolocation'), - camera(value: 'camera'), - microphone(value: 'microphone'), - notifications(value: 'notifications'), - midi(value: 'midi'), - push(value: 'push'), - clipboardRead(value: 'clipboard-read'), - clipboardWrite(value: 'clipboard-write'), - paymentHandler(value: 'payment-handler'), - usb(value: 'usb'), - bluetooth(value: 'bluetooth'), - accelerometer(value: 'accelerometer'), - gyroscope(value: 'gyroscope'), - magnetometer(value: 'magnetometer'), - ambientLightSensor(value: 'ambient-light-sensor'), - backgroundSync(value: 'background-sync'), - persistentStorage(value: 'persistent-storage'), - screenWakeLock(value: 'screen-wake-lock'), - webShare(value: 'web-share'), - xrSpatialTracking(value: 'xr-spatial-tracking'); + geolocation(value: 'geolocation'), + camera(value: 'camera'), + microphone(value: 'microphone'), + notifications(value: 'notifications'), + midi(value: 'midi'), + push(value: 'push'), + clipboardRead(value: 'clipboard-read'), + clipboardWrite(value: 'clipboard-write'), + paymentHandler(value: 'payment-handler'), + usb(value: 'usb'), + bluetooth(value: 'bluetooth'), + accelerometer(value: 'accelerometer'), + gyroscope(value: 'gyroscope'), + magnetometer(value: 'magnetometer'), + ambientLightSensor(value: 'ambient-light-sensor'), + backgroundSync(value: 'background-sync'), + persistentStorage(value: 'persistent-storage'), + screenWakeLock(value: 'screen-wake-lock'), + webShare(value: 'web-share'), + xrSpatialTracking(value: 'xr-spatial-tracking'); - const BrowserPermission({ - required this.value - }); + const BrowserPermission({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_theme.dart b/lib/src/enums/browser_theme.dart index e81a0f68..1e059c2c 100644 --- a/lib/src/enums/browser_theme.dart +++ b/lib/src/enums/browser_theme.dart @@ -1,14 +1,12 @@ part of '../../enums.dart'; enum BrowserTheme { - light(value: 'light'), - dark(value: 'dark'); + light(value: 'light'), + dark(value: 'dark'); - const BrowserTheme({ - required this.value - }); + const BrowserTheme({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/execution_status.dart b/lib/src/enums/execution_status.dart index f54859c9..7ea9865e 100644 --- a/lib/src/enums/execution_status.dart +++ b/lib/src/enums/execution_status.dart @@ -1,17 +1,15 @@ part of '../../enums.dart'; enum ExecutionStatus { - waiting(value: 'waiting'), - processing(value: 'processing'), - completed(value: 'completed'), - failed(value: 'failed'), - scheduled(value: 'scheduled'); + waiting(value: 'waiting'), + processing(value: 'processing'), + completed(value: 'completed'), + failed(value: 'failed'), + scheduled(value: 'scheduled'); - const ExecutionStatus({ - required this.value - }); + const ExecutionStatus({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_trigger.dart b/lib/src/enums/execution_trigger.dart index 8a14ae60..fb05eb7d 100644 --- a/lib/src/enums/execution_trigger.dart +++ b/lib/src/enums/execution_trigger.dart @@ -1,15 +1,13 @@ part of '../../enums.dart'; enum ExecutionTrigger { - http(value: 'http'), - schedule(value: 'schedule'), - event(value: 'event'); + http(value: 'http'), + schedule(value: 'schedule'), + event(value: 'event'); - const ExecutionTrigger({ - required this.value - }); + const ExecutionTrigger({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 8ed7ecff..b88e0a55 100644 --- a/lib/src/enums/o_auth_provider.dart +++ b/lib/src/enums/o_auth_provider.dart @@ -1,55 +1,53 @@ 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'), - fusionauth(value: 'fusionauth'), - github(value: 'github'), - gitlab(value: 'gitlab'), - google(value: 'google'), - keycloak(value: 'keycloak'), - kick(value: 'kick'), - 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'), - x(value: 'x'), - yahoo(value: 'yahoo'), - yammer(value: 'yammer'), - yandex(value: 'yandex'), - zoho(value: 'zoho'), - zoom(value: 'zoom'); + 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'), + fusionauth(value: 'fusionauth'), + github(value: 'github'), + gitlab(value: 'gitlab'), + google(value: 'google'), + keycloak(value: 'keycloak'), + kick(value: 'kick'), + 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'), + x(value: 'x'), + yahoo(value: 'yahoo'), + yammer(value: 'yammer'), + yandex(value: 'yandex'), + zoho(value: 'zoho'), + zoom(value: 'zoom'); - 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/enums/timezone.dart b/lib/src/enums/timezone.dart index 4a8de1ce..d5d8d94a 100644 --- a/lib/src/enums/timezone.dart +++ b/lib/src/enums/timezone.dart @@ -1,431 +1,429 @@ part of '../../enums.dart'; enum Timezone { - africaAbidjan(value: 'africa/abidjan'), - africaAccra(value: 'africa/accra'), - africaAddisAbaba(value: 'africa/addis_ababa'), - africaAlgiers(value: 'africa/algiers'), - africaAsmara(value: 'africa/asmara'), - africaBamako(value: 'africa/bamako'), - africaBangui(value: 'africa/bangui'), - africaBanjul(value: 'africa/banjul'), - africaBissau(value: 'africa/bissau'), - africaBlantyre(value: 'africa/blantyre'), - africaBrazzaville(value: 'africa/brazzaville'), - africaBujumbura(value: 'africa/bujumbura'), - africaCairo(value: 'africa/cairo'), - africaCasablanca(value: 'africa/casablanca'), - africaCeuta(value: 'africa/ceuta'), - africaConakry(value: 'africa/conakry'), - africaDakar(value: 'africa/dakar'), - africaDarEsSalaam(value: 'africa/dar_es_salaam'), - africaDjibouti(value: 'africa/djibouti'), - africaDouala(value: 'africa/douala'), - africaElAaiun(value: 'africa/el_aaiun'), - africaFreetown(value: 'africa/freetown'), - africaGaborone(value: 'africa/gaborone'), - africaHarare(value: 'africa/harare'), - africaJohannesburg(value: 'africa/johannesburg'), - africaJuba(value: 'africa/juba'), - africaKampala(value: 'africa/kampala'), - africaKhartoum(value: 'africa/khartoum'), - africaKigali(value: 'africa/kigali'), - africaKinshasa(value: 'africa/kinshasa'), - africaLagos(value: 'africa/lagos'), - africaLibreville(value: 'africa/libreville'), - africaLome(value: 'africa/lome'), - africaLuanda(value: 'africa/luanda'), - africaLubumbashi(value: 'africa/lubumbashi'), - africaLusaka(value: 'africa/lusaka'), - africaMalabo(value: 'africa/malabo'), - africaMaputo(value: 'africa/maputo'), - africaMaseru(value: 'africa/maseru'), - africaMbabane(value: 'africa/mbabane'), - africaMogadishu(value: 'africa/mogadishu'), - africaMonrovia(value: 'africa/monrovia'), - africaNairobi(value: 'africa/nairobi'), - africaNdjamena(value: 'africa/ndjamena'), - africaNiamey(value: 'africa/niamey'), - africaNouakchott(value: 'africa/nouakchott'), - africaOuagadougou(value: 'africa/ouagadougou'), - africaPortoNovo(value: 'africa/porto-novo'), - africaSaoTome(value: 'africa/sao_tome'), - africaTripoli(value: 'africa/tripoli'), - africaTunis(value: 'africa/tunis'), - africaWindhoek(value: 'africa/windhoek'), - americaAdak(value: 'america/adak'), - americaAnchorage(value: 'america/anchorage'), - americaAnguilla(value: 'america/anguilla'), - americaAntigua(value: 'america/antigua'), - americaAraguaina(value: 'america/araguaina'), - americaArgentinaBuenosAires(value: 'america/argentina/buenos_aires'), - americaArgentinaCatamarca(value: 'america/argentina/catamarca'), - americaArgentinaCordoba(value: 'america/argentina/cordoba'), - americaArgentinaJujuy(value: 'america/argentina/jujuy'), - americaArgentinaLaRioja(value: 'america/argentina/la_rioja'), - americaArgentinaMendoza(value: 'america/argentina/mendoza'), - americaArgentinaRioGallegos(value: 'america/argentina/rio_gallegos'), - americaArgentinaSalta(value: 'america/argentina/salta'), - americaArgentinaSanJuan(value: 'america/argentina/san_juan'), - americaArgentinaSanLuis(value: 'america/argentina/san_luis'), - americaArgentinaTucuman(value: 'america/argentina/tucuman'), - americaArgentinaUshuaia(value: 'america/argentina/ushuaia'), - americaAruba(value: 'america/aruba'), - americaAsuncion(value: 'america/asuncion'), - americaAtikokan(value: 'america/atikokan'), - americaBahia(value: 'america/bahia'), - americaBahiaBanderas(value: 'america/bahia_banderas'), - americaBarbados(value: 'america/barbados'), - americaBelem(value: 'america/belem'), - americaBelize(value: 'america/belize'), - americaBlancSablon(value: 'america/blanc-sablon'), - americaBoaVista(value: 'america/boa_vista'), - americaBogota(value: 'america/bogota'), - americaBoise(value: 'america/boise'), - americaCambridgeBay(value: 'america/cambridge_bay'), - americaCampoGrande(value: 'america/campo_grande'), - americaCancun(value: 'america/cancun'), - americaCaracas(value: 'america/caracas'), - americaCayenne(value: 'america/cayenne'), - americaCayman(value: 'america/cayman'), - americaChicago(value: 'america/chicago'), - americaChihuahua(value: 'america/chihuahua'), - americaCiudadJuarez(value: 'america/ciudad_juarez'), - americaCostaRica(value: 'america/costa_rica'), - americaCoyhaique(value: 'america/coyhaique'), - americaCreston(value: 'america/creston'), - americaCuiaba(value: 'america/cuiaba'), - americaCuracao(value: 'america/curacao'), - americaDanmarkshavn(value: 'america/danmarkshavn'), - americaDawson(value: 'america/dawson'), - americaDawsonCreek(value: 'america/dawson_creek'), - americaDenver(value: 'america/denver'), - americaDetroit(value: 'america/detroit'), - americaDominica(value: 'america/dominica'), - americaEdmonton(value: 'america/edmonton'), - americaEirunepe(value: 'america/eirunepe'), - americaElSalvador(value: 'america/el_salvador'), - americaFortNelson(value: 'america/fort_nelson'), - americaFortaleza(value: 'america/fortaleza'), - americaGlaceBay(value: 'america/glace_bay'), - americaGooseBay(value: 'america/goose_bay'), - americaGrandTurk(value: 'america/grand_turk'), - americaGrenada(value: 'america/grenada'), - americaGuadeloupe(value: 'america/guadeloupe'), - americaGuatemala(value: 'america/guatemala'), - americaGuayaquil(value: 'america/guayaquil'), - americaGuyana(value: 'america/guyana'), - americaHalifax(value: 'america/halifax'), - americaHavana(value: 'america/havana'), - americaHermosillo(value: 'america/hermosillo'), - americaIndianaIndianapolis(value: 'america/indiana/indianapolis'), - americaIndianaKnox(value: 'america/indiana/knox'), - americaIndianaMarengo(value: 'america/indiana/marengo'), - americaIndianaPetersburg(value: 'america/indiana/petersburg'), - americaIndianaTellCity(value: 'america/indiana/tell_city'), - americaIndianaVevay(value: 'america/indiana/vevay'), - americaIndianaVincennes(value: 'america/indiana/vincennes'), - americaIndianaWinamac(value: 'america/indiana/winamac'), - americaInuvik(value: 'america/inuvik'), - americaIqaluit(value: 'america/iqaluit'), - americaJamaica(value: 'america/jamaica'), - americaJuneau(value: 'america/juneau'), - americaKentuckyLouisville(value: 'america/kentucky/louisville'), - americaKentuckyMonticello(value: 'america/kentucky/monticello'), - americaKralendijk(value: 'america/kralendijk'), - americaLaPaz(value: 'america/la_paz'), - americaLima(value: 'america/lima'), - americaLosAngeles(value: 'america/los_angeles'), - americaLowerPrinces(value: 'america/lower_princes'), - americaMaceio(value: 'america/maceio'), - americaManagua(value: 'america/managua'), - americaManaus(value: 'america/manaus'), - americaMarigot(value: 'america/marigot'), - americaMartinique(value: 'america/martinique'), - americaMatamoros(value: 'america/matamoros'), - americaMazatlan(value: 'america/mazatlan'), - americaMenominee(value: 'america/menominee'), - americaMerida(value: 'america/merida'), - americaMetlakatla(value: 'america/metlakatla'), - americaMexicoCity(value: 'america/mexico_city'), - americaMiquelon(value: 'america/miquelon'), - americaMoncton(value: 'america/moncton'), - americaMonterrey(value: 'america/monterrey'), - americaMontevideo(value: 'america/montevideo'), - americaMontserrat(value: 'america/montserrat'), - americaNassau(value: 'america/nassau'), - americaNewYork(value: 'america/new_york'), - americaNome(value: 'america/nome'), - americaNoronha(value: 'america/noronha'), - americaNorthDakotaBeulah(value: 'america/north_dakota/beulah'), - americaNorthDakotaCenter(value: 'america/north_dakota/center'), - americaNorthDakotaNewSalem(value: 'america/north_dakota/new_salem'), - americaNuuk(value: 'america/nuuk'), - americaOjinaga(value: 'america/ojinaga'), - americaPanama(value: 'america/panama'), - americaParamaribo(value: 'america/paramaribo'), - americaPhoenix(value: 'america/phoenix'), - americaPortAuPrince(value: 'america/port-au-prince'), - americaPortOfSpain(value: 'america/port_of_spain'), - americaPortoVelho(value: 'america/porto_velho'), - americaPuertoRico(value: 'america/puerto_rico'), - americaPuntaArenas(value: 'america/punta_arenas'), - americaRankinInlet(value: 'america/rankin_inlet'), - americaRecife(value: 'america/recife'), - americaRegina(value: 'america/regina'), - americaResolute(value: 'america/resolute'), - americaRioBranco(value: 'america/rio_branco'), - americaSantarem(value: 'america/santarem'), - americaSantiago(value: 'america/santiago'), - americaSantoDomingo(value: 'america/santo_domingo'), - americaSaoPaulo(value: 'america/sao_paulo'), - americaScoresbysund(value: 'america/scoresbysund'), - americaSitka(value: 'america/sitka'), - americaStBarthelemy(value: 'america/st_barthelemy'), - americaStJohns(value: 'america/st_johns'), - americaStKitts(value: 'america/st_kitts'), - americaStLucia(value: 'america/st_lucia'), - americaStThomas(value: 'america/st_thomas'), - americaStVincent(value: 'america/st_vincent'), - americaSwiftCurrent(value: 'america/swift_current'), - americaTegucigalpa(value: 'america/tegucigalpa'), - americaThule(value: 'america/thule'), - americaTijuana(value: 'america/tijuana'), - americaToronto(value: 'america/toronto'), - americaTortola(value: 'america/tortola'), - americaVancouver(value: 'america/vancouver'), - americaWhitehorse(value: 'america/whitehorse'), - americaWinnipeg(value: 'america/winnipeg'), - americaYakutat(value: 'america/yakutat'), - antarcticaCasey(value: 'antarctica/casey'), - antarcticaDavis(value: 'antarctica/davis'), - antarcticaDumontdurville(value: 'antarctica/dumontdurville'), - antarcticaMacquarie(value: 'antarctica/macquarie'), - antarcticaMawson(value: 'antarctica/mawson'), - antarcticaMcmurdo(value: 'antarctica/mcmurdo'), - antarcticaPalmer(value: 'antarctica/palmer'), - antarcticaRothera(value: 'antarctica/rothera'), - antarcticaSyowa(value: 'antarctica/syowa'), - antarcticaTroll(value: 'antarctica/troll'), - antarcticaVostok(value: 'antarctica/vostok'), - arcticLongyearbyen(value: 'arctic/longyearbyen'), - asiaAden(value: 'asia/aden'), - asiaAlmaty(value: 'asia/almaty'), - asiaAmman(value: 'asia/amman'), - asiaAnadyr(value: 'asia/anadyr'), - asiaAqtau(value: 'asia/aqtau'), - asiaAqtobe(value: 'asia/aqtobe'), - asiaAshgabat(value: 'asia/ashgabat'), - asiaAtyrau(value: 'asia/atyrau'), - asiaBaghdad(value: 'asia/baghdad'), - asiaBahrain(value: 'asia/bahrain'), - asiaBaku(value: 'asia/baku'), - asiaBangkok(value: 'asia/bangkok'), - asiaBarnaul(value: 'asia/barnaul'), - asiaBeirut(value: 'asia/beirut'), - asiaBishkek(value: 'asia/bishkek'), - asiaBrunei(value: 'asia/brunei'), - asiaChita(value: 'asia/chita'), - asiaColombo(value: 'asia/colombo'), - asiaDamascus(value: 'asia/damascus'), - asiaDhaka(value: 'asia/dhaka'), - asiaDili(value: 'asia/dili'), - asiaDubai(value: 'asia/dubai'), - asiaDushanbe(value: 'asia/dushanbe'), - asiaFamagusta(value: 'asia/famagusta'), - asiaGaza(value: 'asia/gaza'), - asiaHebron(value: 'asia/hebron'), - asiaHoChiMinh(value: 'asia/ho_chi_minh'), - asiaHongKong(value: 'asia/hong_kong'), - asiaHovd(value: 'asia/hovd'), - asiaIrkutsk(value: 'asia/irkutsk'), - asiaJakarta(value: 'asia/jakarta'), - asiaJayapura(value: 'asia/jayapura'), - asiaJerusalem(value: 'asia/jerusalem'), - asiaKabul(value: 'asia/kabul'), - asiaKamchatka(value: 'asia/kamchatka'), - asiaKarachi(value: 'asia/karachi'), - asiaKathmandu(value: 'asia/kathmandu'), - asiaKhandyga(value: 'asia/khandyga'), - asiaKolkata(value: 'asia/kolkata'), - asiaKrasnoyarsk(value: 'asia/krasnoyarsk'), - asiaKualaLumpur(value: 'asia/kuala_lumpur'), - asiaKuching(value: 'asia/kuching'), - asiaKuwait(value: 'asia/kuwait'), - asiaMacau(value: 'asia/macau'), - asiaMagadan(value: 'asia/magadan'), - asiaMakassar(value: 'asia/makassar'), - asiaManila(value: 'asia/manila'), - asiaMuscat(value: 'asia/muscat'), - asiaNicosia(value: 'asia/nicosia'), - asiaNovokuznetsk(value: 'asia/novokuznetsk'), - asiaNovosibirsk(value: 'asia/novosibirsk'), - asiaOmsk(value: 'asia/omsk'), - asiaOral(value: 'asia/oral'), - asiaPhnomPenh(value: 'asia/phnom_penh'), - asiaPontianak(value: 'asia/pontianak'), - asiaPyongyang(value: 'asia/pyongyang'), - asiaQatar(value: 'asia/qatar'), - asiaQostanay(value: 'asia/qostanay'), - asiaQyzylorda(value: 'asia/qyzylorda'), - asiaRiyadh(value: 'asia/riyadh'), - asiaSakhalin(value: 'asia/sakhalin'), - asiaSamarkand(value: 'asia/samarkand'), - asiaSeoul(value: 'asia/seoul'), - asiaShanghai(value: 'asia/shanghai'), - asiaSingapore(value: 'asia/singapore'), - asiaSrednekolymsk(value: 'asia/srednekolymsk'), - asiaTaipei(value: 'asia/taipei'), - asiaTashkent(value: 'asia/tashkent'), - asiaTbilisi(value: 'asia/tbilisi'), - asiaTehran(value: 'asia/tehran'), - asiaThimphu(value: 'asia/thimphu'), - asiaTokyo(value: 'asia/tokyo'), - asiaTomsk(value: 'asia/tomsk'), - asiaUlaanbaatar(value: 'asia/ulaanbaatar'), - asiaUrumqi(value: 'asia/urumqi'), - asiaUstNera(value: 'asia/ust-nera'), - asiaVientiane(value: 'asia/vientiane'), - asiaVladivostok(value: 'asia/vladivostok'), - asiaYakutsk(value: 'asia/yakutsk'), - asiaYangon(value: 'asia/yangon'), - asiaYekaterinburg(value: 'asia/yekaterinburg'), - asiaYerevan(value: 'asia/yerevan'), - atlanticAzores(value: 'atlantic/azores'), - atlanticBermuda(value: 'atlantic/bermuda'), - atlanticCanary(value: 'atlantic/canary'), - atlanticCapeVerde(value: 'atlantic/cape_verde'), - atlanticFaroe(value: 'atlantic/faroe'), - atlanticMadeira(value: 'atlantic/madeira'), - atlanticReykjavik(value: 'atlantic/reykjavik'), - atlanticSouthGeorgia(value: 'atlantic/south_georgia'), - atlanticStHelena(value: 'atlantic/st_helena'), - atlanticStanley(value: 'atlantic/stanley'), - australiaAdelaide(value: 'australia/adelaide'), - australiaBrisbane(value: 'australia/brisbane'), - australiaBrokenHill(value: 'australia/broken_hill'), - australiaDarwin(value: 'australia/darwin'), - australiaEucla(value: 'australia/eucla'), - australiaHobart(value: 'australia/hobart'), - australiaLindeman(value: 'australia/lindeman'), - australiaLordHowe(value: 'australia/lord_howe'), - australiaMelbourne(value: 'australia/melbourne'), - australiaPerth(value: 'australia/perth'), - australiaSydney(value: 'australia/sydney'), - europeAmsterdam(value: 'europe/amsterdam'), - europeAndorra(value: 'europe/andorra'), - europeAstrakhan(value: 'europe/astrakhan'), - europeAthens(value: 'europe/athens'), - europeBelgrade(value: 'europe/belgrade'), - europeBerlin(value: 'europe/berlin'), - europeBratislava(value: 'europe/bratislava'), - europeBrussels(value: 'europe/brussels'), - europeBucharest(value: 'europe/bucharest'), - europeBudapest(value: 'europe/budapest'), - europeBusingen(value: 'europe/busingen'), - europeChisinau(value: 'europe/chisinau'), - europeCopenhagen(value: 'europe/copenhagen'), - europeDublin(value: 'europe/dublin'), - europeGibraltar(value: 'europe/gibraltar'), - europeGuernsey(value: 'europe/guernsey'), - europeHelsinki(value: 'europe/helsinki'), - europeIsleOfMan(value: 'europe/isle_of_man'), - europeIstanbul(value: 'europe/istanbul'), - europeJersey(value: 'europe/jersey'), - europeKaliningrad(value: 'europe/kaliningrad'), - europeKirov(value: 'europe/kirov'), - europeKyiv(value: 'europe/kyiv'), - europeLisbon(value: 'europe/lisbon'), - europeLjubljana(value: 'europe/ljubljana'), - europeLondon(value: 'europe/london'), - europeLuxembourg(value: 'europe/luxembourg'), - europeMadrid(value: 'europe/madrid'), - europeMalta(value: 'europe/malta'), - europeMariehamn(value: 'europe/mariehamn'), - europeMinsk(value: 'europe/minsk'), - europeMonaco(value: 'europe/monaco'), - europeMoscow(value: 'europe/moscow'), - europeOslo(value: 'europe/oslo'), - europeParis(value: 'europe/paris'), - europePodgorica(value: 'europe/podgorica'), - europePrague(value: 'europe/prague'), - europeRiga(value: 'europe/riga'), - europeRome(value: 'europe/rome'), - europeSamara(value: 'europe/samara'), - europeSanMarino(value: 'europe/san_marino'), - europeSarajevo(value: 'europe/sarajevo'), - europeSaratov(value: 'europe/saratov'), - europeSimferopol(value: 'europe/simferopol'), - europeSkopje(value: 'europe/skopje'), - europeSofia(value: 'europe/sofia'), - europeStockholm(value: 'europe/stockholm'), - europeTallinn(value: 'europe/tallinn'), - europeTirane(value: 'europe/tirane'), - europeUlyanovsk(value: 'europe/ulyanovsk'), - europeVaduz(value: 'europe/vaduz'), - europeVatican(value: 'europe/vatican'), - europeVienna(value: 'europe/vienna'), - europeVilnius(value: 'europe/vilnius'), - europeVolgograd(value: 'europe/volgograd'), - europeWarsaw(value: 'europe/warsaw'), - europeZagreb(value: 'europe/zagreb'), - europeZurich(value: 'europe/zurich'), - indianAntananarivo(value: 'indian/antananarivo'), - indianChagos(value: 'indian/chagos'), - indianChristmas(value: 'indian/christmas'), - indianCocos(value: 'indian/cocos'), - indianComoro(value: 'indian/comoro'), - indianKerguelen(value: 'indian/kerguelen'), - indianMahe(value: 'indian/mahe'), - indianMaldives(value: 'indian/maldives'), - indianMauritius(value: 'indian/mauritius'), - indianMayotte(value: 'indian/mayotte'), - indianReunion(value: 'indian/reunion'), - pacificApia(value: 'pacific/apia'), - pacificAuckland(value: 'pacific/auckland'), - pacificBougainville(value: 'pacific/bougainville'), - pacificChatham(value: 'pacific/chatham'), - pacificChuuk(value: 'pacific/chuuk'), - pacificEaster(value: 'pacific/easter'), - pacificEfate(value: 'pacific/efate'), - pacificFakaofo(value: 'pacific/fakaofo'), - pacificFiji(value: 'pacific/fiji'), - pacificFunafuti(value: 'pacific/funafuti'), - pacificGalapagos(value: 'pacific/galapagos'), - pacificGambier(value: 'pacific/gambier'), - pacificGuadalcanal(value: 'pacific/guadalcanal'), - pacificGuam(value: 'pacific/guam'), - pacificHonolulu(value: 'pacific/honolulu'), - pacificKanton(value: 'pacific/kanton'), - pacificKiritimati(value: 'pacific/kiritimati'), - pacificKosrae(value: 'pacific/kosrae'), - pacificKwajalein(value: 'pacific/kwajalein'), - pacificMajuro(value: 'pacific/majuro'), - pacificMarquesas(value: 'pacific/marquesas'), - pacificMidway(value: 'pacific/midway'), - pacificNauru(value: 'pacific/nauru'), - pacificNiue(value: 'pacific/niue'), - pacificNorfolk(value: 'pacific/norfolk'), - pacificNoumea(value: 'pacific/noumea'), - pacificPagoPago(value: 'pacific/pago_pago'), - pacificPalau(value: 'pacific/palau'), - pacificPitcairn(value: 'pacific/pitcairn'), - pacificPohnpei(value: 'pacific/pohnpei'), - pacificPortMoresby(value: 'pacific/port_moresby'), - pacificRarotonga(value: 'pacific/rarotonga'), - pacificSaipan(value: 'pacific/saipan'), - pacificTahiti(value: 'pacific/tahiti'), - pacificTarawa(value: 'pacific/tarawa'), - pacificTongatapu(value: 'pacific/tongatapu'), - pacificWake(value: 'pacific/wake'), - pacificWallis(value: 'pacific/wallis'), - utc(value: 'utc'); + africaAbidjan(value: 'africa/abidjan'), + africaAccra(value: 'africa/accra'), + africaAddisAbaba(value: 'africa/addis_ababa'), + africaAlgiers(value: 'africa/algiers'), + africaAsmara(value: 'africa/asmara'), + africaBamako(value: 'africa/bamako'), + africaBangui(value: 'africa/bangui'), + africaBanjul(value: 'africa/banjul'), + africaBissau(value: 'africa/bissau'), + africaBlantyre(value: 'africa/blantyre'), + africaBrazzaville(value: 'africa/brazzaville'), + africaBujumbura(value: 'africa/bujumbura'), + africaCairo(value: 'africa/cairo'), + africaCasablanca(value: 'africa/casablanca'), + africaCeuta(value: 'africa/ceuta'), + africaConakry(value: 'africa/conakry'), + africaDakar(value: 'africa/dakar'), + africaDarEsSalaam(value: 'africa/dar_es_salaam'), + africaDjibouti(value: 'africa/djibouti'), + africaDouala(value: 'africa/douala'), + africaElAaiun(value: 'africa/el_aaiun'), + africaFreetown(value: 'africa/freetown'), + africaGaborone(value: 'africa/gaborone'), + africaHarare(value: 'africa/harare'), + africaJohannesburg(value: 'africa/johannesburg'), + africaJuba(value: 'africa/juba'), + africaKampala(value: 'africa/kampala'), + africaKhartoum(value: 'africa/khartoum'), + africaKigali(value: 'africa/kigali'), + africaKinshasa(value: 'africa/kinshasa'), + africaLagos(value: 'africa/lagos'), + africaLibreville(value: 'africa/libreville'), + africaLome(value: 'africa/lome'), + africaLuanda(value: 'africa/luanda'), + africaLubumbashi(value: 'africa/lubumbashi'), + africaLusaka(value: 'africa/lusaka'), + africaMalabo(value: 'africa/malabo'), + africaMaputo(value: 'africa/maputo'), + africaMaseru(value: 'africa/maseru'), + africaMbabane(value: 'africa/mbabane'), + africaMogadishu(value: 'africa/mogadishu'), + africaMonrovia(value: 'africa/monrovia'), + africaNairobi(value: 'africa/nairobi'), + africaNdjamena(value: 'africa/ndjamena'), + africaNiamey(value: 'africa/niamey'), + africaNouakchott(value: 'africa/nouakchott'), + africaOuagadougou(value: 'africa/ouagadougou'), + africaPortoNovo(value: 'africa/porto-novo'), + africaSaoTome(value: 'africa/sao_tome'), + africaTripoli(value: 'africa/tripoli'), + africaTunis(value: 'africa/tunis'), + africaWindhoek(value: 'africa/windhoek'), + americaAdak(value: 'america/adak'), + americaAnchorage(value: 'america/anchorage'), + americaAnguilla(value: 'america/anguilla'), + americaAntigua(value: 'america/antigua'), + americaAraguaina(value: 'america/araguaina'), + americaArgentinaBuenosAires(value: 'america/argentina/buenos_aires'), + americaArgentinaCatamarca(value: 'america/argentina/catamarca'), + americaArgentinaCordoba(value: 'america/argentina/cordoba'), + americaArgentinaJujuy(value: 'america/argentina/jujuy'), + americaArgentinaLaRioja(value: 'america/argentina/la_rioja'), + americaArgentinaMendoza(value: 'america/argentina/mendoza'), + americaArgentinaRioGallegos(value: 'america/argentina/rio_gallegos'), + americaArgentinaSalta(value: 'america/argentina/salta'), + americaArgentinaSanJuan(value: 'america/argentina/san_juan'), + americaArgentinaSanLuis(value: 'america/argentina/san_luis'), + americaArgentinaTucuman(value: 'america/argentina/tucuman'), + americaArgentinaUshuaia(value: 'america/argentina/ushuaia'), + americaAruba(value: 'america/aruba'), + americaAsuncion(value: 'america/asuncion'), + americaAtikokan(value: 'america/atikokan'), + americaBahia(value: 'america/bahia'), + americaBahiaBanderas(value: 'america/bahia_banderas'), + americaBarbados(value: 'america/barbados'), + americaBelem(value: 'america/belem'), + americaBelize(value: 'america/belize'), + americaBlancSablon(value: 'america/blanc-sablon'), + americaBoaVista(value: 'america/boa_vista'), + americaBogota(value: 'america/bogota'), + americaBoise(value: 'america/boise'), + americaCambridgeBay(value: 'america/cambridge_bay'), + americaCampoGrande(value: 'america/campo_grande'), + americaCancun(value: 'america/cancun'), + americaCaracas(value: 'america/caracas'), + americaCayenne(value: 'america/cayenne'), + americaCayman(value: 'america/cayman'), + americaChicago(value: 'america/chicago'), + americaChihuahua(value: 'america/chihuahua'), + americaCiudadJuarez(value: 'america/ciudad_juarez'), + americaCostaRica(value: 'america/costa_rica'), + americaCoyhaique(value: 'america/coyhaique'), + americaCreston(value: 'america/creston'), + americaCuiaba(value: 'america/cuiaba'), + americaCuracao(value: 'america/curacao'), + americaDanmarkshavn(value: 'america/danmarkshavn'), + americaDawson(value: 'america/dawson'), + americaDawsonCreek(value: 'america/dawson_creek'), + americaDenver(value: 'america/denver'), + americaDetroit(value: 'america/detroit'), + americaDominica(value: 'america/dominica'), + americaEdmonton(value: 'america/edmonton'), + americaEirunepe(value: 'america/eirunepe'), + americaElSalvador(value: 'america/el_salvador'), + americaFortNelson(value: 'america/fort_nelson'), + americaFortaleza(value: 'america/fortaleza'), + americaGlaceBay(value: 'america/glace_bay'), + americaGooseBay(value: 'america/goose_bay'), + americaGrandTurk(value: 'america/grand_turk'), + americaGrenada(value: 'america/grenada'), + americaGuadeloupe(value: 'america/guadeloupe'), + americaGuatemala(value: 'america/guatemala'), + americaGuayaquil(value: 'america/guayaquil'), + americaGuyana(value: 'america/guyana'), + americaHalifax(value: 'america/halifax'), + americaHavana(value: 'america/havana'), + americaHermosillo(value: 'america/hermosillo'), + americaIndianaIndianapolis(value: 'america/indiana/indianapolis'), + americaIndianaKnox(value: 'america/indiana/knox'), + americaIndianaMarengo(value: 'america/indiana/marengo'), + americaIndianaPetersburg(value: 'america/indiana/petersburg'), + americaIndianaTellCity(value: 'america/indiana/tell_city'), + americaIndianaVevay(value: 'america/indiana/vevay'), + americaIndianaVincennes(value: 'america/indiana/vincennes'), + americaIndianaWinamac(value: 'america/indiana/winamac'), + americaInuvik(value: 'america/inuvik'), + americaIqaluit(value: 'america/iqaluit'), + americaJamaica(value: 'america/jamaica'), + americaJuneau(value: 'america/juneau'), + americaKentuckyLouisville(value: 'america/kentucky/louisville'), + americaKentuckyMonticello(value: 'america/kentucky/monticello'), + americaKralendijk(value: 'america/kralendijk'), + americaLaPaz(value: 'america/la_paz'), + americaLima(value: 'america/lima'), + americaLosAngeles(value: 'america/los_angeles'), + americaLowerPrinces(value: 'america/lower_princes'), + americaMaceio(value: 'america/maceio'), + americaManagua(value: 'america/managua'), + americaManaus(value: 'america/manaus'), + americaMarigot(value: 'america/marigot'), + americaMartinique(value: 'america/martinique'), + americaMatamoros(value: 'america/matamoros'), + americaMazatlan(value: 'america/mazatlan'), + americaMenominee(value: 'america/menominee'), + americaMerida(value: 'america/merida'), + americaMetlakatla(value: 'america/metlakatla'), + americaMexicoCity(value: 'america/mexico_city'), + americaMiquelon(value: 'america/miquelon'), + americaMoncton(value: 'america/moncton'), + americaMonterrey(value: 'america/monterrey'), + americaMontevideo(value: 'america/montevideo'), + americaMontserrat(value: 'america/montserrat'), + americaNassau(value: 'america/nassau'), + americaNewYork(value: 'america/new_york'), + americaNome(value: 'america/nome'), + americaNoronha(value: 'america/noronha'), + americaNorthDakotaBeulah(value: 'america/north_dakota/beulah'), + americaNorthDakotaCenter(value: 'america/north_dakota/center'), + americaNorthDakotaNewSalem(value: 'america/north_dakota/new_salem'), + americaNuuk(value: 'america/nuuk'), + americaOjinaga(value: 'america/ojinaga'), + americaPanama(value: 'america/panama'), + americaParamaribo(value: 'america/paramaribo'), + americaPhoenix(value: 'america/phoenix'), + americaPortAuPrince(value: 'america/port-au-prince'), + americaPortOfSpain(value: 'america/port_of_spain'), + americaPortoVelho(value: 'america/porto_velho'), + americaPuertoRico(value: 'america/puerto_rico'), + americaPuntaArenas(value: 'america/punta_arenas'), + americaRankinInlet(value: 'america/rankin_inlet'), + americaRecife(value: 'america/recife'), + americaRegina(value: 'america/regina'), + americaResolute(value: 'america/resolute'), + americaRioBranco(value: 'america/rio_branco'), + americaSantarem(value: 'america/santarem'), + americaSantiago(value: 'america/santiago'), + americaSantoDomingo(value: 'america/santo_domingo'), + americaSaoPaulo(value: 'america/sao_paulo'), + americaScoresbysund(value: 'america/scoresbysund'), + americaSitka(value: 'america/sitka'), + americaStBarthelemy(value: 'america/st_barthelemy'), + americaStJohns(value: 'america/st_johns'), + americaStKitts(value: 'america/st_kitts'), + americaStLucia(value: 'america/st_lucia'), + americaStThomas(value: 'america/st_thomas'), + americaStVincent(value: 'america/st_vincent'), + americaSwiftCurrent(value: 'america/swift_current'), + americaTegucigalpa(value: 'america/tegucigalpa'), + americaThule(value: 'america/thule'), + americaTijuana(value: 'america/tijuana'), + americaToronto(value: 'america/toronto'), + americaTortola(value: 'america/tortola'), + americaVancouver(value: 'america/vancouver'), + americaWhitehorse(value: 'america/whitehorse'), + americaWinnipeg(value: 'america/winnipeg'), + americaYakutat(value: 'america/yakutat'), + antarcticaCasey(value: 'antarctica/casey'), + antarcticaDavis(value: 'antarctica/davis'), + antarcticaDumontdurville(value: 'antarctica/dumontdurville'), + antarcticaMacquarie(value: 'antarctica/macquarie'), + antarcticaMawson(value: 'antarctica/mawson'), + antarcticaMcmurdo(value: 'antarctica/mcmurdo'), + antarcticaPalmer(value: 'antarctica/palmer'), + antarcticaRothera(value: 'antarctica/rothera'), + antarcticaSyowa(value: 'antarctica/syowa'), + antarcticaTroll(value: 'antarctica/troll'), + antarcticaVostok(value: 'antarctica/vostok'), + arcticLongyearbyen(value: 'arctic/longyearbyen'), + asiaAden(value: 'asia/aden'), + asiaAlmaty(value: 'asia/almaty'), + asiaAmman(value: 'asia/amman'), + asiaAnadyr(value: 'asia/anadyr'), + asiaAqtau(value: 'asia/aqtau'), + asiaAqtobe(value: 'asia/aqtobe'), + asiaAshgabat(value: 'asia/ashgabat'), + asiaAtyrau(value: 'asia/atyrau'), + asiaBaghdad(value: 'asia/baghdad'), + asiaBahrain(value: 'asia/bahrain'), + asiaBaku(value: 'asia/baku'), + asiaBangkok(value: 'asia/bangkok'), + asiaBarnaul(value: 'asia/barnaul'), + asiaBeirut(value: 'asia/beirut'), + asiaBishkek(value: 'asia/bishkek'), + asiaBrunei(value: 'asia/brunei'), + asiaChita(value: 'asia/chita'), + asiaColombo(value: 'asia/colombo'), + asiaDamascus(value: 'asia/damascus'), + asiaDhaka(value: 'asia/dhaka'), + asiaDili(value: 'asia/dili'), + asiaDubai(value: 'asia/dubai'), + asiaDushanbe(value: 'asia/dushanbe'), + asiaFamagusta(value: 'asia/famagusta'), + asiaGaza(value: 'asia/gaza'), + asiaHebron(value: 'asia/hebron'), + asiaHoChiMinh(value: 'asia/ho_chi_minh'), + asiaHongKong(value: 'asia/hong_kong'), + asiaHovd(value: 'asia/hovd'), + asiaIrkutsk(value: 'asia/irkutsk'), + asiaJakarta(value: 'asia/jakarta'), + asiaJayapura(value: 'asia/jayapura'), + asiaJerusalem(value: 'asia/jerusalem'), + asiaKabul(value: 'asia/kabul'), + asiaKamchatka(value: 'asia/kamchatka'), + asiaKarachi(value: 'asia/karachi'), + asiaKathmandu(value: 'asia/kathmandu'), + asiaKhandyga(value: 'asia/khandyga'), + asiaKolkata(value: 'asia/kolkata'), + asiaKrasnoyarsk(value: 'asia/krasnoyarsk'), + asiaKualaLumpur(value: 'asia/kuala_lumpur'), + asiaKuching(value: 'asia/kuching'), + asiaKuwait(value: 'asia/kuwait'), + asiaMacau(value: 'asia/macau'), + asiaMagadan(value: 'asia/magadan'), + asiaMakassar(value: 'asia/makassar'), + asiaManila(value: 'asia/manila'), + asiaMuscat(value: 'asia/muscat'), + asiaNicosia(value: 'asia/nicosia'), + asiaNovokuznetsk(value: 'asia/novokuznetsk'), + asiaNovosibirsk(value: 'asia/novosibirsk'), + asiaOmsk(value: 'asia/omsk'), + asiaOral(value: 'asia/oral'), + asiaPhnomPenh(value: 'asia/phnom_penh'), + asiaPontianak(value: 'asia/pontianak'), + asiaPyongyang(value: 'asia/pyongyang'), + asiaQatar(value: 'asia/qatar'), + asiaQostanay(value: 'asia/qostanay'), + asiaQyzylorda(value: 'asia/qyzylorda'), + asiaRiyadh(value: 'asia/riyadh'), + asiaSakhalin(value: 'asia/sakhalin'), + asiaSamarkand(value: 'asia/samarkand'), + asiaSeoul(value: 'asia/seoul'), + asiaShanghai(value: 'asia/shanghai'), + asiaSingapore(value: 'asia/singapore'), + asiaSrednekolymsk(value: 'asia/srednekolymsk'), + asiaTaipei(value: 'asia/taipei'), + asiaTashkent(value: 'asia/tashkent'), + asiaTbilisi(value: 'asia/tbilisi'), + asiaTehran(value: 'asia/tehran'), + asiaThimphu(value: 'asia/thimphu'), + asiaTokyo(value: 'asia/tokyo'), + asiaTomsk(value: 'asia/tomsk'), + asiaUlaanbaatar(value: 'asia/ulaanbaatar'), + asiaUrumqi(value: 'asia/urumqi'), + asiaUstNera(value: 'asia/ust-nera'), + asiaVientiane(value: 'asia/vientiane'), + asiaVladivostok(value: 'asia/vladivostok'), + asiaYakutsk(value: 'asia/yakutsk'), + asiaYangon(value: 'asia/yangon'), + asiaYekaterinburg(value: 'asia/yekaterinburg'), + asiaYerevan(value: 'asia/yerevan'), + atlanticAzores(value: 'atlantic/azores'), + atlanticBermuda(value: 'atlantic/bermuda'), + atlanticCanary(value: 'atlantic/canary'), + atlanticCapeVerde(value: 'atlantic/cape_verde'), + atlanticFaroe(value: 'atlantic/faroe'), + atlanticMadeira(value: 'atlantic/madeira'), + atlanticReykjavik(value: 'atlantic/reykjavik'), + atlanticSouthGeorgia(value: 'atlantic/south_georgia'), + atlanticStHelena(value: 'atlantic/st_helena'), + atlanticStanley(value: 'atlantic/stanley'), + australiaAdelaide(value: 'australia/adelaide'), + australiaBrisbane(value: 'australia/brisbane'), + australiaBrokenHill(value: 'australia/broken_hill'), + australiaDarwin(value: 'australia/darwin'), + australiaEucla(value: 'australia/eucla'), + australiaHobart(value: 'australia/hobart'), + australiaLindeman(value: 'australia/lindeman'), + australiaLordHowe(value: 'australia/lord_howe'), + australiaMelbourne(value: 'australia/melbourne'), + australiaPerth(value: 'australia/perth'), + australiaSydney(value: 'australia/sydney'), + europeAmsterdam(value: 'europe/amsterdam'), + europeAndorra(value: 'europe/andorra'), + europeAstrakhan(value: 'europe/astrakhan'), + europeAthens(value: 'europe/athens'), + europeBelgrade(value: 'europe/belgrade'), + europeBerlin(value: 'europe/berlin'), + europeBratislava(value: 'europe/bratislava'), + europeBrussels(value: 'europe/brussels'), + europeBucharest(value: 'europe/bucharest'), + europeBudapest(value: 'europe/budapest'), + europeBusingen(value: 'europe/busingen'), + europeChisinau(value: 'europe/chisinau'), + europeCopenhagen(value: 'europe/copenhagen'), + europeDublin(value: 'europe/dublin'), + europeGibraltar(value: 'europe/gibraltar'), + europeGuernsey(value: 'europe/guernsey'), + europeHelsinki(value: 'europe/helsinki'), + europeIsleOfMan(value: 'europe/isle_of_man'), + europeIstanbul(value: 'europe/istanbul'), + europeJersey(value: 'europe/jersey'), + europeKaliningrad(value: 'europe/kaliningrad'), + europeKirov(value: 'europe/kirov'), + europeKyiv(value: 'europe/kyiv'), + europeLisbon(value: 'europe/lisbon'), + europeLjubljana(value: 'europe/ljubljana'), + europeLondon(value: 'europe/london'), + europeLuxembourg(value: 'europe/luxembourg'), + europeMadrid(value: 'europe/madrid'), + europeMalta(value: 'europe/malta'), + europeMariehamn(value: 'europe/mariehamn'), + europeMinsk(value: 'europe/minsk'), + europeMonaco(value: 'europe/monaco'), + europeMoscow(value: 'europe/moscow'), + europeOslo(value: 'europe/oslo'), + europeParis(value: 'europe/paris'), + europePodgorica(value: 'europe/podgorica'), + europePrague(value: 'europe/prague'), + europeRiga(value: 'europe/riga'), + europeRome(value: 'europe/rome'), + europeSamara(value: 'europe/samara'), + europeSanMarino(value: 'europe/san_marino'), + europeSarajevo(value: 'europe/sarajevo'), + europeSaratov(value: 'europe/saratov'), + europeSimferopol(value: 'europe/simferopol'), + europeSkopje(value: 'europe/skopje'), + europeSofia(value: 'europe/sofia'), + europeStockholm(value: 'europe/stockholm'), + europeTallinn(value: 'europe/tallinn'), + europeTirane(value: 'europe/tirane'), + europeUlyanovsk(value: 'europe/ulyanovsk'), + europeVaduz(value: 'europe/vaduz'), + europeVatican(value: 'europe/vatican'), + europeVienna(value: 'europe/vienna'), + europeVilnius(value: 'europe/vilnius'), + europeVolgograd(value: 'europe/volgograd'), + europeWarsaw(value: 'europe/warsaw'), + europeZagreb(value: 'europe/zagreb'), + europeZurich(value: 'europe/zurich'), + indianAntananarivo(value: 'indian/antananarivo'), + indianChagos(value: 'indian/chagos'), + indianChristmas(value: 'indian/christmas'), + indianCocos(value: 'indian/cocos'), + indianComoro(value: 'indian/comoro'), + indianKerguelen(value: 'indian/kerguelen'), + indianMahe(value: 'indian/mahe'), + indianMaldives(value: 'indian/maldives'), + indianMauritius(value: 'indian/mauritius'), + indianMayotte(value: 'indian/mayotte'), + indianReunion(value: 'indian/reunion'), + pacificApia(value: 'pacific/apia'), + pacificAuckland(value: 'pacific/auckland'), + pacificBougainville(value: 'pacific/bougainville'), + pacificChatham(value: 'pacific/chatham'), + pacificChuuk(value: 'pacific/chuuk'), + pacificEaster(value: 'pacific/easter'), + pacificEfate(value: 'pacific/efate'), + pacificFakaofo(value: 'pacific/fakaofo'), + pacificFiji(value: 'pacific/fiji'), + pacificFunafuti(value: 'pacific/funafuti'), + pacificGalapagos(value: 'pacific/galapagos'), + pacificGambier(value: 'pacific/gambier'), + pacificGuadalcanal(value: 'pacific/guadalcanal'), + pacificGuam(value: 'pacific/guam'), + pacificHonolulu(value: 'pacific/honolulu'), + pacificKanton(value: 'pacific/kanton'), + pacificKiritimati(value: 'pacific/kiritimati'), + pacificKosrae(value: 'pacific/kosrae'), + pacificKwajalein(value: 'pacific/kwajalein'), + pacificMajuro(value: 'pacific/majuro'), + pacificMarquesas(value: 'pacific/marquesas'), + pacificMidway(value: 'pacific/midway'), + pacificNauru(value: 'pacific/nauru'), + pacificNiue(value: 'pacific/niue'), + pacificNorfolk(value: 'pacific/norfolk'), + pacificNoumea(value: 'pacific/noumea'), + pacificPagoPago(value: 'pacific/pago_pago'), + pacificPalau(value: 'pacific/palau'), + pacificPitcairn(value: 'pacific/pitcairn'), + pacificPohnpei(value: 'pacific/pohnpei'), + pacificPortMoresby(value: 'pacific/port_moresby'), + pacificRarotonga(value: 'pacific/rarotonga'), + pacificSaipan(value: 'pacific/saipan'), + pacificTahiti(value: 'pacific/tahiti'), + pacificTarawa(value: 'pacific/tarawa'), + pacificTongatapu(value: 'pacific/tongatapu'), + pacificWake(value: 'pacific/wake'), + pacificWallis(value: 'pacific/wallis'), + utc(value: 'utc'); - const Timezone({ - required this.value - }); + const Timezone({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 f80fa854..344a8770 100644 --- a/lib/src/models/algo_argon2.dart +++ b/lib/src/models/algo_argon2.dart @@ -2,41 +2,41 @@ 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'], + ); + } - @override - Map toMap() { - return { - "type": type, - "memoryCost": memoryCost, - "timeCost": timeCost, - "threads": threads, - }; - } + @override + 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 c51da4bb..9909265e 100644 --- a/lib/src/models/algo_bcrypt.dart +++ b/lib/src/models/algo_bcrypt.dart @@ -2,23 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return { - "type": type, - }; - } + @override + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_md5.dart b/lib/src/models/algo_md5.dart index 43523ab1..746fbd52 100644 --- a/lib/src/models/algo_md5.dart +++ b/lib/src/models/algo_md5.dart @@ -2,23 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return { - "type": type, - }; - } + @override + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_phpass.dart b/lib/src/models/algo_phpass.dart index 8562c4e3..cab45e49 100644 --- a/lib/src/models/algo_phpass.dart +++ b/lib/src/models/algo_phpass.dart @@ -2,23 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return { - "type": type, - }; - } + @override + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/algo_scrypt.dart b/lib/src/models/algo_scrypt.dart index 8e844839..a1648843 100644 --- a/lib/src/models/algo_scrypt.dart +++ b/lib/src/models/algo_scrypt.dart @@ -2,47 +2,47 @@ 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'], - ); - } - - @override - 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'], + ); + } + + @override + 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 5202db05..33ef4a6f 100644 --- a/lib/src/models/algo_scrypt_modified.dart +++ b/lib/src/models/algo_scrypt_modified.dart @@ -2,41 +2,41 @@ 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(), + ); + } - @override - Map toMap() { - return { - "type": type, - "salt": salt, - "saltSeparator": saltSeparator, - "signerKey": signerKey, - }; - } + @override + 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 3d08af9f..4984df75 100644 --- a/lib/src/models/algo_sha.dart +++ b/lib/src/models/algo_sha.dart @@ -2,23 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return { - "type": type, - }; - } + @override + Map toMap() { + return { + "type": type, + }; + } } diff --git a/lib/src/models/continent.dart b/lib/src/models/continent.dart index 930900bf..ec3c41be 100644 --- a/lib/src/models/continent.dart +++ b/lib/src/models/continent.dart @@ -2,29 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return { - "name": name, - "code": code, - }; - } + @override + Map toMap() { + return { + "name": name, + "code": code, + }; + } } diff --git a/lib/src/models/continent_list.dart b/lib/src/models/continent_list.dart index 753bcacc..df28f04b 100644 --- a/lib/src/models/continent_list.dart +++ b/lib/src/models/continent_list.dart @@ -2,29 +2,30 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "continents": continents.map((p) => p.toMap()).toList(), - }; - } + @override + 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 c4838ba3..3bcbb76d 100644 --- a/lib/src/models/country.dart +++ b/lib/src/models/country.dart @@ -2,29 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return { - "name": name, - "code": code, - }; - } + @override + Map toMap() { + return { + "name": name, + "code": code, + }; + } } diff --git a/lib/src/models/country_list.dart b/lib/src/models/country_list.dart index f363a54b..79cb1256 100644 --- a/lib/src/models/country_list.dart +++ b/lib/src/models/country_list.dart @@ -2,29 +2,30 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "countries": countries.map((p) => p.toMap()).toList(), - }; - } + @override + 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 b6bb455f..f2b18093 100644 --- a/lib/src/models/currency.dart +++ b/lib/src/models/currency.dart @@ -2,59 +2,59 @@ 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(), - ); - } - - @override - 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(), + ); + } + + @override + 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 eb2bad19..6c39ae2e 100644 --- a/lib/src/models/currency_list.dart +++ b/lib/src/models/currency_list.dart @@ -2,29 +2,30 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "currencies": currencies.map((p) => p.toMap()).toList(), - }; - } + @override + 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 0d1fdeb0..be08d599 100644 --- a/lib/src/models/document.dart +++ b/lib/src/models/document.dart @@ -2,66 +2,66 @@ part of '../../models.dart'; /// Document class Document implements Model { - /// Document ID. - final String $id; + /// Document ID. + final String $id; - /// Document sequence ID. - final String $sequence; + /// Document sequence ID. + final String $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'].toString(), - $collectionId: map['\$collectionId'].toString(), - $databaseId: map['\$databaseId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - data: map["data"] ?? map, - ); - } + factory Document.fromMap(Map map) { + return Document( + $id: map['\$id'].toString(), + $sequence: map['\$sequence'].toString(), + $collectionId: map['\$collectionId'].toString(), + $databaseId: map['\$databaseId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + data: map["data"] ?? map, + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$sequence": $sequence, - "\$collectionId": $collectionId, - "\$databaseId": $databaseId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "data": data, - }; - } + @override + 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 0e30844a..76a07309 100644 --- a/lib/src/models/document_list.dart +++ b/lib/src/models/document_list.dart @@ -2,32 +2,33 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "documents": documents.map((p) => p.toMap()).toList(), - }; - } + @override + 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 3e767ca3..3629e1d6 100644 --- a/lib/src/models/execution.dart +++ b/lib/src/models/execution.dart @@ -2,125 +2,129 @@ 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 enums.ExecutionTrigger trigger; - - /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, `failed`, or `scheduled`. - final enums.ExecutionStatus status; - - /// HTTP request method type. - final String requestMethod; - - /// HTTP request path and query. - final String requestPath; - - /// HTTP request 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: enums.ExecutionTrigger.values.firstWhere((e) => e.value == map['trigger']), - status: enums.ExecutionStatus.values.firstWhere((e) => e.value == map['status']), - 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(), - ); - } - - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "functionId": functionId, - "deploymentId": deploymentId, - "trigger": trigger.value, - "status": status.value, - "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 enums.ExecutionTrigger trigger; + + /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, `failed`, or `scheduled`. + final enums.ExecutionStatus status; + + /// HTTP request method type. + final String requestMethod; + + /// HTTP request path and query. + final String requestPath; + + /// HTTP request 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: enums.ExecutionTrigger.values + .firstWhere((e) => e.value == map['trigger']), + status: enums.ExecutionStatus.values + .firstWhere((e) => e.value == map['status']), + 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(), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "functionId": functionId, + "deploymentId": deploymentId, + "trigger": trigger.value, + "status": status.value, + "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 45b60682..63c2ad7e 100644 --- a/lib/src/models/execution_list.dart +++ b/lib/src/models/execution_list.dart @@ -2,29 +2,30 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "executions": executions.map((p) => p.toMap()).toList(), - }; - } + @override + 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 9e5f9eb1..01cdcb3a 100644 --- a/lib/src/models/file.dart +++ b/lib/src/models/file.dart @@ -2,101 +2,101 @@ part of '../../models.dart'; /// File class File implements Model { - /// File ID. - final String $id; - - /// Bucket ID. - final String bucketId; - - /// File creation date in ISO 8601 format. - final String $createdAt; - - /// 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 name. - final String name; - - /// File MD5 signature. - final String signature; - - /// File mime type. - final String mimeType; - - /// File original size in bytes. - final int sizeOriginal; - - /// File actual stored size in bytes after compression and/or encryption. - final int sizeActual; - - /// Total number of chunks available - final int chunksTotal; - - /// Total number of chunks uploaded - final int chunksUploaded; - - /// Whether file contents are encrypted at rest. - final bool encryption; - - /// Compression algorithm used for the file. Will be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd). - final String compression; - - 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.sizeActual, - required this.chunksTotal, - required this.chunksUploaded, - required this.encryption, - required this.compression, - }); - - 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'], - sizeActual: map['sizeActual'], - chunksTotal: map['chunksTotal'], - chunksUploaded: map['chunksUploaded'], - encryption: map['encryption'], - compression: map['compression'].toString(), - ); - } - - @override - Map toMap() { - return { - "\$id": $id, - "bucketId": bucketId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "name": name, - "signature": signature, - "mimeType": mimeType, - "sizeOriginal": sizeOriginal, - "sizeActual": sizeActual, - "chunksTotal": chunksTotal, - "chunksUploaded": chunksUploaded, - "encryption": encryption, - "compression": compression, - }; - } + /// File ID. + final String $id; + + /// Bucket ID. + final String bucketId; + + /// File creation date in ISO 8601 format. + final String $createdAt; + + /// 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 name. + final String name; + + /// File MD5 signature. + final String signature; + + /// File mime type. + final String mimeType; + + /// File original size in bytes. + final int sizeOriginal; + + /// File actual stored size in bytes after compression and/or encryption. + final int sizeActual; + + /// Total number of chunks available + final int chunksTotal; + + /// Total number of chunks uploaded + final int chunksUploaded; + + /// Whether file contents are encrypted at rest. + final bool encryption; + + /// Compression algorithm used for the file. Will be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd). + final String compression; + + 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.sizeActual, + required this.chunksTotal, + required this.chunksUploaded, + required this.encryption, + required this.compression, + }); + + 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'], + sizeActual: map['sizeActual'], + chunksTotal: map['chunksTotal'], + chunksUploaded: map['chunksUploaded'], + encryption: map['encryption'], + compression: map['compression'].toString(), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "bucketId": bucketId, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "name": name, + "signature": signature, + "mimeType": mimeType, + "sizeOriginal": sizeOriginal, + "sizeActual": sizeActual, + "chunksTotal": chunksTotal, + "chunksUploaded": chunksUploaded, + "encryption": encryption, + "compression": compression, + }; + } } diff --git a/lib/src/models/file_list.dart b/lib/src/models/file_list.dart index 84c54b2e..1157554a 100644 --- a/lib/src/models/file_list.dart +++ b/lib/src/models/file_list.dart @@ -2,29 +2,29 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "files": files.map((p) => p.toMap()).toList(), - }; - } + @override + 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 bbccf88a..fa054420 100644 --- a/lib/src/models/headers.dart +++ b/lib/src/models/headers.dart @@ -2,29 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return { - "name": name, - "value": value, - }; - } + @override + Map toMap() { + return { + "name": name, + "value": value, + }; + } } diff --git a/lib/src/models/identity.dart b/lib/src/models/identity.dart index 7e90020c..cc659043 100644 --- a/lib/src/models/identity.dart +++ b/lib/src/models/identity.dart @@ -2,77 +2,77 @@ 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(), + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "userId": userId, - "provider": provider, - "providerUid": providerUid, - "providerEmail": providerEmail, - "providerAccessToken": providerAccessToken, - "providerAccessTokenExpiry": providerAccessTokenExpiry, - "providerRefreshToken": providerRefreshToken, - }; - } + @override + 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 d9cc09a2..a5d39ea0 100644 --- a/lib/src/models/identity_list.dart +++ b/lib/src/models/identity_list.dart @@ -2,29 +2,30 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "identities": identities.map((p) => p.toMap()).toList(), - }; - } + @override + 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 2000acb6..cda66c70 100644 --- a/lib/src/models/jwt.dart +++ b/lib/src/models/jwt.dart @@ -2,23 +2,23 @@ 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(), + ); + } - @override - Map toMap() { - return { - "jwt": jwt, - }; - } + @override + Map toMap() { + return { + "jwt": jwt, + }; + } } diff --git a/lib/src/models/language.dart b/lib/src/models/language.dart index 1422d065..87dc3606 100644 --- a/lib/src/models/language.dart +++ b/lib/src/models/language.dart @@ -2,35 +2,35 @@ 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(), + ); + } - @override - Map toMap() { - return { - "name": name, - "code": code, - "nativeName": nativeName, - }; - } + @override + 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 5d78a367..6198d61e 100644 --- a/lib/src/models/language_list.dart +++ b/lib/src/models/language_list.dart @@ -2,29 +2,30 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "languages": languages.map((p) => p.toMap()).toList(), - }; - } + @override + 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 3292a896..54dd0c29 100644 --- a/lib/src/models/locale.dart +++ b/lib/src/models/locale.dart @@ -2,59 +2,59 @@ 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(), - ); - } - - @override - 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(), + ); + } + + @override + 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 49ef3b0b..21405aff 100644 --- a/lib/src/models/locale_code.dart +++ b/lib/src/models/locale_code.dart @@ -2,29 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return { - "code": code, - "name": name, - }; - } + @override + 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 a3a26b61..202355a4 100644 --- a/lib/src/models/locale_code_list.dart +++ b/lib/src/models/locale_code_list.dart @@ -2,29 +2,30 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "localeCodes": localeCodes.map((p) => p.toMap()).toList(), - }; - } + @override + 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 406fcbcf..572cce50 100644 --- a/lib/src/models/log.dart +++ b/lib/src/models/log.dart @@ -2,149 +2,149 @@ part of '../../models.dart'; /// Log class Log implements Model { - /// Event name. - final String event; - - /// User ID of the actor recorded for this log. During impersonation, this is the original impersonator, not the impersonated target user. - final String userId; - - /// User email of the actor recorded for this log. During impersonation, this is the original impersonator. - final String userEmail; - - /// User name of the actor recorded for this log. During impersonation, this is the original impersonator. - final String userName; - - /// API mode when event triggered. - final String mode; - - /// User type who triggered the audit log. Possible values: user, admin, guest, keyProject, keyAccount, keyOrganization. - final String userType; - - /// 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.userType, - 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(), - userType: map['userType'].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(), - ); - } - - @override - Map toMap() { - return { - "event": event, - "userId": userId, - "userEmail": userEmail, - "userName": userName, - "mode": mode, - "userType": userType, - "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 of the actor recorded for this log. During impersonation, this is the original impersonator, not the impersonated target user. + final String userId; + + /// User email of the actor recorded for this log. During impersonation, this is the original impersonator. + final String userEmail; + + /// User name of the actor recorded for this log. During impersonation, this is the original impersonator. + final String userName; + + /// API mode when event triggered. + final String mode; + + /// User type who triggered the audit log. Possible values: user, admin, guest, keyProject, keyAccount, keyOrganization. + final String userType; + + /// 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.userType, + 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(), + userType: map['userType'].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(), + ); + } + + @override + Map toMap() { + return { + "event": event, + "userId": userId, + "userEmail": userEmail, + "userName": userName, + "mode": mode, + "userType": userType, + "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 ebf593c2..3494b111 100644 --- a/lib/src/models/log_list.dart +++ b/lib/src/models/log_list.dart @@ -2,29 +2,29 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "logs": logs.map((p) => p.toMap()).toList(), - }; - } + @override + 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 4baffb71..4d8a2f9b 100644 --- a/lib/src/models/membership.dart +++ b/lib/src/models/membership.dart @@ -2,107 +2,107 @@ 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; - - /// User phone number. Hide this attribute by toggling membership privacy in the Console. - final String userPhone; - - /// 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; - - /// Most recent access date in ISO 8601 format. Show this attribute by toggling membership privacy in the Console. - final String userAccessedAt; - - /// 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.userPhone, - required this.teamId, - required this.teamName, - required this.invited, - required this.joined, - required this.confirm, - required this.mfa, - required this.userAccessedAt, - 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(), - userPhone: map['userPhone'].toString(), - teamId: map['teamId'].toString(), - teamName: map['teamName'].toString(), - invited: map['invited'].toString(), - joined: map['joined'].toString(), - confirm: map['confirm'], - mfa: map['mfa'], - userAccessedAt: map['userAccessedAt'].toString(), - roles: List.from(map['roles'] ?? []), - ); - } - - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "userId": userId, - "userName": userName, - "userEmail": userEmail, - "userPhone": userPhone, - "teamId": teamId, - "teamName": teamName, - "invited": invited, - "joined": joined, - "confirm": confirm, - "mfa": mfa, - "userAccessedAt": userAccessedAt, - "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; + + /// User phone number. Hide this attribute by toggling membership privacy in the Console. + final String userPhone; + + /// 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; + + /// Most recent access date in ISO 8601 format. Show this attribute by toggling membership privacy in the Console. + final String userAccessedAt; + + /// 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.userPhone, + required this.teamId, + required this.teamName, + required this.invited, + required this.joined, + required this.confirm, + required this.mfa, + required this.userAccessedAt, + 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(), + userPhone: map['userPhone'].toString(), + teamId: map['teamId'].toString(), + teamName: map['teamName'].toString(), + invited: map['invited'].toString(), + joined: map['joined'].toString(), + confirm: map['confirm'], + mfa: map['mfa'], + userAccessedAt: map['userAccessedAt'].toString(), + roles: List.from(map['roles'] ?? []), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "userId": userId, + "userName": userName, + "userEmail": userEmail, + "userPhone": userPhone, + "teamId": teamId, + "teamName": teamName, + "invited": invited, + "joined": joined, + "confirm": confirm, + "mfa": mfa, + "userAccessedAt": userAccessedAt, + "roles": roles, + }; + } } diff --git a/lib/src/models/membership_list.dart b/lib/src/models/membership_list.dart index a0641a28..cc664c9f 100644 --- a/lib/src/models/membership_list.dart +++ b/lib/src/models/membership_list.dart @@ -2,29 +2,30 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "memberships": memberships.map((p) => p.toMap()).toList(), - }; - } + @override + 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 3d2e2335..fa385541 100644 --- a/lib/src/models/mfa_challenge.dart +++ b/lib/src/models/mfa_challenge.dart @@ -2,41 +2,41 @@ 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(), + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "userId": userId, - "expire": expire, - }; - } + @override + 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 a7e5fefc..2777de7f 100644 --- a/lib/src/models/mfa_factors.dart +++ b/lib/src/models/mfa_factors.dart @@ -2,41 +2,41 @@ 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'], + ); + } - @override - Map toMap() { - return { - "totp": totp, - "phone": phone, - "email": email, - "recoveryCode": recoveryCode, - }; - } + @override + 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 33036476..864a5db8 100644 --- a/lib/src/models/mfa_recovery_codes.dart +++ b/lib/src/models/mfa_recovery_codes.dart @@ -2,23 +2,23 @@ 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'] ?? []), + ); + } - @override - Map toMap() { - return { - "recoveryCodes": recoveryCodes, - }; - } + @override + Map toMap() { + return { + "recoveryCodes": recoveryCodes, + }; + } } diff --git a/lib/src/models/mfa_type.dart b/lib/src/models/mfa_type.dart index 05cab363..fe5327fc 100644 --- a/lib/src/models/mfa_type.dart +++ b/lib/src/models/mfa_type.dart @@ -2,29 +2,29 @@ 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(), + ); + } - @override - Map toMap() { - return { - "secret": secret, - "uri": uri, - }; - } + @override + 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 7ac578e2..60e2abd9 100644 --- a/lib/src/models/phone.dart +++ b/lib/src/models/phone.dart @@ -2,35 +2,35 @@ 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(), + ); + } - @override - Map toMap() { - return { - "code": code, - "countryCode": countryCode, - "countryName": countryName, - }; - } + @override + 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 9791d590..1a197fc7 100644 --- a/lib/src/models/phone_list.dart +++ b/lib/src/models/phone_list.dart @@ -2,29 +2,29 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "phones": phones.map((p) => p.toMap()).toList(), - }; - } + @override + 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 b107afe5..3ca04118 100644 --- a/lib/src/models/preferences.dart +++ b/lib/src/models/preferences.dart @@ -2,24 +2,24 @@ 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["data"] ?? map, - ); - } + factory Preferences.fromMap(Map map) { + return Preferences( + data: map["data"] ?? map, + ); + } - @override - Map toMap() { - return { - "data": data, - }; - } + @override + 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/presence.dart b/lib/src/models/presence.dart index 133fe66d..d31911de 100644 --- a/lib/src/models/presence.dart +++ b/lib/src/models/presence.dart @@ -2,71 +2,71 @@ part of '../../models.dart'; /// Presence class Presence implements Model { - /// Presence ID. - final String $id; + /// Presence ID. + final String $id; - /// Presence creation date in ISO 8601 format. - final String $createdAt; + /// Presence creation date in ISO 8601 format. + final String $createdAt; - /// Presence update date in ISO 8601 format. - final String $updatedAt; + /// Presence update date in ISO 8601 format. + final String $updatedAt; - /// Presence permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - final List $permissions; + /// Presence permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + final List $permissions; - /// User ID. - final String userId; + /// User ID. + final String userId; - /// Presence status. - final String? status; + /// Presence status. + final String? status; - /// Presence source. - final String source; + /// Presence source. + final String source; - /// Presence expiry date in ISO 8601 format. - final String? expiresAt; + /// Presence expiry date in ISO 8601 format. + final String? expiresAt; - /// Presence metadata. - final Map? metadata; + /// Presence metadata. + final Map? metadata; - Presence({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.$permissions, - required this.userId, - this.status, - required this.source, - this.expiresAt, - this.metadata, - }); + Presence({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.$permissions, + required this.userId, + this.status, + required this.source, + this.expiresAt, + this.metadata, + }); - factory Presence.fromMap(Map map) { - return Presence( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - userId: map['userId'].toString(), - status: map['status']?.toString(), - source: map['source'].toString(), - expiresAt: map['expiresAt']?.toString(), - metadata: map['metadata'], - ); - } + factory Presence.fromMap(Map map) { + return Presence( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + userId: map['userId'].toString(), + status: map['status']?.toString(), + source: map['source'].toString(), + expiresAt: map['expiresAt']?.toString(), + metadata: map['metadata'], + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "userId": userId, - "status": status, - "source": source, - "expiresAt": expiresAt, - "metadata": metadata, - }; - } + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "\$permissions": $permissions, + "userId": userId, + "status": status, + "source": source, + "expiresAt": expiresAt, + "metadata": metadata, + }; + } } diff --git a/lib/src/models/presence_list.dart b/lib/src/models/presence_list.dart index aebbe880..3d010b1c 100644 --- a/lib/src/models/presence_list.dart +++ b/lib/src/models/presence_list.dart @@ -2,29 +2,30 @@ part of '../../models.dart'; /// Presences List class PresenceList implements Model { - /// Total number of presences that matched your query. - final int total; + /// Total number of presences that matched your query. + final int total; - /// List of presences. - final List presences; + /// List of presences. + final List presences; - PresenceList({ - required this.total, - required this.presences, - }); + PresenceList({ + required this.total, + required this.presences, + }); - factory PresenceList.fromMap(Map map) { - return PresenceList( - total: map['total'], - presences: List.from(map['presences'].map((p) => Presence.fromMap(p))), - ); - } + factory PresenceList.fromMap(Map map) { + return PresenceList( + total: map['total'], + presences: + List.from(map['presences'].map((p) => Presence.fromMap(p))), + ); + } - @override - Map toMap() { - return { - "total": total, - "presences": presences.map((p) => p.toMap()).toList(), - }; - } + @override + Map toMap() { + return { + "total": total, + "presences": presences.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/row.dart b/lib/src/models/row.dart index c5f233b4..a825eab0 100644 --- a/lib/src/models/row.dart +++ b/lib/src/models/row.dart @@ -2,66 +2,66 @@ part of '../../models.dart'; /// Row class Row implements Model { - /// Row ID. - final String $id; + /// Row ID. + final String $id; - /// Row sequence ID. - final String $sequence; + /// Row sequence ID. + final String $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'].toString(), - $tableId: map['\$tableId'].toString(), - $databaseId: map['\$databaseId'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - $permissions: List.from(map['\$permissions'] ?? []), - data: map["data"] ?? map, - ); - } + factory Row.fromMap(Map map) { + return Row( + $id: map['\$id'].toString(), + $sequence: map['\$sequence'].toString(), + $tableId: map['\$tableId'].toString(), + $databaseId: map['\$databaseId'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: List.from(map['\$permissions'] ?? []), + data: map["data"] ?? map, + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$sequence": $sequence, - "\$tableId": $tableId, - "\$databaseId": $databaseId, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "\$permissions": $permissions, - "data": data, - }; - } + @override + 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 90efa95f..5023c633 100644 --- a/lib/src/models/row_list.dart +++ b/lib/src/models/row_list.dart @@ -2,32 +2,32 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "rows": rows.map((p) => p.toMap()).toList(), - }; - } + @override + 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 c37de95a..92e4034e 100644 --- a/lib/src/models/session.dart +++ b/lib/src/models/session.dart @@ -2,191 +2,191 @@ 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(), - ); - } - - @override - 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(), + ); + } + + @override + 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 d823d0e6..4ea12394 100644 --- a/lib/src/models/session_list.dart +++ b/lib/src/models/session_list.dart @@ -2,29 +2,30 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "sessions": sessions.map((p) => p.toMap()).toList(), - }; - } + @override + 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 850ab8d2..450aafd1 100644 --- a/lib/src/models/subscriber.dart +++ b/lib/src/models/subscriber.dart @@ -2,71 +2,71 @@ 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(), + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "targetId": targetId, - "target": target.toMap(), - "userId": userId, - "userName": userName, - "topicId": topicId, - "providerType": providerType, - }; - } + @override + 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 742e7590..c2e8c4dc 100644 --- a/lib/src/models/target.dart +++ b/lib/src/models/target.dart @@ -2,71 +2,71 @@ 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'], + ); + } - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "name": name, - "userId": userId, - "providerId": providerId, - "providerType": providerType, - "identifier": identifier, - "expired": expired, - }; - } + @override + 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 21e65e95..91b888b9 100644 --- a/lib/src/models/team.dart +++ b/lib/src/models/team.dart @@ -2,53 +2,53 @@ 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']), - ); - } - - @override - 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']), + ); + } + + @override + 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 ffca5e98..e8f1c621 100644 --- a/lib/src/models/team_list.dart +++ b/lib/src/models/team_list.dart @@ -2,29 +2,29 @@ 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))), + ); + } - @override - Map toMap() { - return { - "total": total, - "teams": teams.map((p) => p.toMap()).toList(), - }; - } + @override + 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 b05320da..b5ea87c8 100644 --- a/lib/src/models/token.dart +++ b/lib/src/models/token.dart @@ -2,53 +2,53 @@ 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(), - ); - } - - @override - 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(), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "userId": userId, + "secret": secret, + "expire": expire, + "phrase": phrase, + }; + } } diff --git a/lib/src/models/transaction.dart b/lib/src/models/transaction.dart index e3f3e43d..b0606dd8 100644 --- a/lib/src/models/transaction.dart +++ b/lib/src/models/transaction.dart @@ -2,53 +2,53 @@ part of '../../models.dart'; /// Transaction class Transaction implements Model { - /// Transaction ID. - final String $id; - - /// Transaction creation time in ISO 8601 format. - final String $createdAt; - - /// Transaction update date in ISO 8601 format. - final String $updatedAt; - - /// Current status of the transaction. One of: pending, committing, committed, rolled_back, failed. - final String status; - - /// Number of operations in the transaction. - final int operations; - - /// Expiration time in ISO 8601 format. - final String expiresAt; - - Transaction({ - required this.$id, - required this.$createdAt, - required this.$updatedAt, - required this.status, - required this.operations, - required this.expiresAt, - }); - - factory Transaction.fromMap(Map map) { - return Transaction( - $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'].toString(), - $updatedAt: map['\$updatedAt'].toString(), - status: map['status'].toString(), - operations: map['operations'], - expiresAt: map['expiresAt'].toString(), - ); - } - - @override - Map toMap() { - return { - "\$id": $id, - "\$createdAt": $createdAt, - "\$updatedAt": $updatedAt, - "status": status, - "operations": operations, - "expiresAt": expiresAt, - }; - } + /// Transaction ID. + final String $id; + + /// Transaction creation time in ISO 8601 format. + final String $createdAt; + + /// Transaction update date in ISO 8601 format. + final String $updatedAt; + + /// Current status of the transaction. One of: pending, committing, committed, rolled_back, failed. + final String status; + + /// Number of operations in the transaction. + final int operations; + + /// Expiration time in ISO 8601 format. + final String expiresAt; + + Transaction({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.status, + required this.operations, + required this.expiresAt, + }); + + factory Transaction.fromMap(Map map) { + return Transaction( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + status: map['status'].toString(), + operations: map['operations'], + expiresAt: map['expiresAt'].toString(), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "status": status, + "operations": operations, + "expiresAt": expiresAt, + }; + } } diff --git a/lib/src/models/transaction_list.dart b/lib/src/models/transaction_list.dart index 19ea651d..7f321175 100644 --- a/lib/src/models/transaction_list.dart +++ b/lib/src/models/transaction_list.dart @@ -2,29 +2,30 @@ part of '../../models.dart'; /// Transaction List class TransactionList implements Model { - /// Total number of transactions that matched your query. - final int total; + /// Total number of transactions that matched your query. + final int total; - /// List of transactions. - final List transactions; + /// List of transactions. + final List transactions; - TransactionList({ - required this.total, - required this.transactions, - }); + TransactionList({ + required this.total, + required this.transactions, + }); - factory TransactionList.fromMap(Map map) { - return TransactionList( - total: map['total'], - transactions: List.from(map['transactions'].map((p) => Transaction.fromMap(p))), - ); - } + factory TransactionList.fromMap(Map map) { + return TransactionList( + total: map['total'], + transactions: List.from( + map['transactions'].map((p) => Transaction.fromMap(p))), + ); + } - @override - Map toMap() { - return { - "total": total, - "transactions": transactions.map((p) => p.toMap()).toList(), - }; - } + @override + Map toMap() { + return { + "total": total, + "transactions": transactions.map((p) => p.toMap()).toList(), + }; + } } diff --git a/lib/src/models/user.dart b/lib/src/models/user.dart index e3b9536b..5a6cad30 100644 --- a/lib/src/models/user.dart +++ b/lib/src/models/user.dart @@ -2,173 +2,173 @@ part of '../../models.dart'; /// User class User implements Model { - /// User ID. - final String $id; + /// User ID. + final String $id; - /// User creation date in ISO 8601 format. - final String $createdAt; + /// User creation date in ISO 8601 format. + final String $createdAt; - /// User update date in ISO 8601 format. - final String $updatedAt; + /// 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; - - /// Canonical form of the user email address. - final String? emailCanonical; - - /// Whether the user email is from a free email provider. - final bool? emailIsFree; - - /// Whether the user email is from a disposable email provider. - final bool? emailIsDisposable; - - /// Whether the user email is from a corporate domain. - final bool? emailIsCorporate; - - /// Whether the user email is in its canonical form. - final bool? emailIsCanonical; - - /// 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; - - /// Whether the user can impersonate other users. - final bool? impersonator; - - /// ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data. - final String? impersonatorUserId; - - 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, - this.emailCanonical, - this.emailIsFree, - this.emailIsDisposable, - this.emailIsCorporate, - this.emailIsCanonical, - required this.phoneVerification, - required this.mfa, - required this.prefs, - required this.targets, - required this.accessedAt, - this.impersonator, - this.impersonatorUserId, - }); - - 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'], - emailCanonical: map['emailCanonical']?.toString(), - emailIsFree: map['emailIsFree'], - emailIsDisposable: map['emailIsDisposable'], - emailIsCorporate: map['emailIsCorporate'], - emailIsCanonical: map['emailIsCanonical'], - 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(), - impersonator: map['impersonator'], - impersonatorUserId: map['impersonatorUserId']?.toString(), - ); - } - - @override - 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, - "emailCanonical": emailCanonical, - "emailIsFree": emailIsFree, - "emailIsDisposable": emailIsDisposable, - "emailIsCorporate": emailIsCorporate, - "emailIsCanonical": emailIsCanonical, - "phoneVerification": phoneVerification, - "mfa": mfa, - "prefs": prefs.toMap(), - "targets": targets.map((p) => p.toMap()).toList(), - "accessedAt": accessedAt, - "impersonator": impersonator, - "impersonatorUserId": impersonatorUserId, - }; - } + /// 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; + + /// Canonical form of the user email address. + final String? emailCanonical; + + /// Whether the user email is from a free email provider. + final bool? emailIsFree; + + /// Whether the user email is from a disposable email provider. + final bool? emailIsDisposable; + + /// Whether the user email is from a corporate domain. + final bool? emailIsCorporate; + + /// Whether the user email is in its canonical form. + final bool? emailIsCanonical; + + /// 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; + + /// Whether the user can impersonate other users. + final bool? impersonator; + + /// ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data. + final String? impersonatorUserId; + + 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, + this.emailCanonical, + this.emailIsFree, + this.emailIsDisposable, + this.emailIsCorporate, + this.emailIsCanonical, + required this.phoneVerification, + required this.mfa, + required this.prefs, + required this.targets, + required this.accessedAt, + this.impersonator, + this.impersonatorUserId, + }); + + 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'], + emailCanonical: map['emailCanonical']?.toString(), + emailIsFree: map['emailIsFree'], + emailIsDisposable: map['emailIsDisposable'], + emailIsCorporate: map['emailIsCorporate'], + emailIsCanonical: map['emailIsCanonical'], + 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(), + impersonator: map['impersonator'], + impersonatorUserId: map['impersonatorUserId']?.toString(), + ); + } + + @override + 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, + "emailCanonical": emailCanonical, + "emailIsFree": emailIsFree, + "emailIsDisposable": emailIsDisposable, + "emailIsCorporate": emailIsCorporate, + "emailIsCanonical": emailIsCanonical, + "phoneVerification": phoneVerification, + "mfa": mfa, + "prefs": prefs.toMap(), + "targets": targets.map((p) => p.toMap()).toList(), + "accessedAt": accessedAt, + "impersonator": impersonator, + "impersonatorUserId": impersonatorUserId, + }; + } } diff --git a/lib/src/realtime.dart b/lib/src/realtime.dart index 7a5e6303..28e4c43d 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(); /// ``` - /// + /// /// You can also use Channel builders: /// ```dart /// final subscription = realtime.subscribe([ diff --git a/lib/src/realtime_io.dart b/lib/src/realtime_io.dart index 83f01b4c..0ed367a6 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 6cebb5b1..72edf5ee 100644 --- a/lib/src/realtime_mixin.dart +++ b/lib/src/realtime_mixin.dart @@ -58,9 +58,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"})); } }); } @@ -140,9 +138,11 @@ mixin RealtimeMixin { case 'event': final messageData = data.data as Map; final message = RealtimeMessage.fromMap(messageData); - final subscriptions = (messageData['subscriptions'] as List?) - ?.map((x) => x.toString()) - .toList() ?? []; + final subscriptions = + (messageData['subscriptions'] as List?) + ?.map((x) => x.toString()) + .toList() ?? + []; if (subscriptions.isEmpty) { break; @@ -209,13 +209,15 @@ mixin RealtimeMixin { "Please set endPointRealtime to connect to realtime server"); } var uri = Uri.parse(client.endPointRealtime!); - - var queryParams = "project=${Uri.encodeComponent(client.config['project']!)}"; + + var queryParams = + "project=${Uri.encodeComponent(client.config['project']!)}"; final portPart = (uri.hasPort && uri.port != 80 && uri.port != 443) ? ':${uri.port}' : ''; - return Uri.parse("${uri.scheme}://${uri.host}$portPart${uri.path}/realtime?$queryParams"); + return Uri.parse( + "${uri.scheme}://${uri.host}$portPart${uri.path}/realtime?$queryParams"); } void _sendUnsubscribeMessage(List subscriptionIds) { @@ -310,9 +312,11 @@ mixin RealtimeMixin { return channel is String ? channel : channel.toString(); } - RealtimeSubscription subscribeTo(List channels, [List queries = const []]) { + RealtimeSubscription subscribeTo(List channels, + [List queries = const []]) { StreamController controller = StreamController.broadcast(); - final channelStrings = channels.map((ch) => _channelToString(ch)).toList().cast(); + final channelStrings = + channels.map((ch) => _channelToString(ch)).toList().cast(); final queryStrings = List.from(queries); final subscriptionId = _generateUniqueSubscriptionId(); @@ -329,8 +333,7 @@ mixin RealtimeMixin { _sendUnsubscribeMessage([subscriptionId]); } - Future update( - {List? channels, List? queries}) async { + Future update({List? channels, List? queries}) async { final current = _subscriptions[subscriptionId]; if (current == null) { return; @@ -417,4 +420,4 @@ mixin RealtimeMixin { // until the application-level handshake completes. _flushPendingPresence(); } -} \ 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 diff --git a/lib/src/realtime_stub.dart b/lib/src/realtime_stub.dart index ce0b7e95..3aab4e03 100644 --- a/lib/src/realtime_stub.dart +++ b/lib/src/realtime_stub.dart @@ -3,5 +3,5 @@ import 'client.dart'; /// Implemented in `realtime_browser.dart` and `realtime_io.dart`. RealtimeBase createRealtime(Client client) => throw UnsupportedError( - 'Cannot create a client without dart:html or dart:io.', -); + 'Cannot create a client without dart:html or dart:io.', + ); diff --git a/test/channel_test.dart b/test/channel_test.dart index 62031aec..9e0e11d3 100644 --- a/test/channel_test.dart +++ b/test/channel_test.dart @@ -13,12 +13,22 @@ void main() { }); test('returns database channel with action', () { - expect(Channel.database('db1').collection('col1').document('doc1').create().toString(), + expect( + Channel.database('db1') + .collection('col1') + .document('doc1') + .create() + .toString(), 'databases.db1.collections.col1.documents.doc1.create'); }); test('returns database channel with upsert action', () { - expect(Channel.database('db1').collection('col1').document('doc1').upsert().toString(), + expect( + Channel.database('db1') + .collection('col1') + .document('doc1') + .upsert() + .toString(), 'databases.db1.collections.col1.documents.doc1.upsert'); }); }); @@ -34,7 +44,12 @@ void main() { }); test('returns tablesdb channel with action', () { - expect(Channel.tablesdb('db1').table('table1').row('row1').update().toString(), + expect( + Channel.tablesdb('db1') + .table('table1') + .row('row1') + .update() + .toString(), 'tablesdb.db1.tables.table1.rows.row1.update'); }); }); @@ -47,16 +62,16 @@ void main() { group('bucket()', () { test('throws when bucket id is missing', () { - expect(() => Channel.bucket(''), throwsArgumentError); + expect(() => Channel.bucket(''), throwsArgumentError); }); test('returns buckets channel with specific IDs', () { - expect(Channel.bucket('bucket1').file().toString(), - 'buckets.bucket1.files'); + expect( + Channel.bucket('bucket1').file().toString(), 'buckets.bucket1.files'); }); test('returns buckets channel with action', () { - expect(Channel.bucket('bucket1').file('file1').delete().toString(), + expect(Channel.bucket('bucket1').file('file1').delete().toString(), 'buckets.bucket1.files.file1.delete'); }); }); @@ -83,29 +98,30 @@ void main() { group('teams()', () { test('throws when team id is missing', () { - expect(() => Channel.team(''), throwsArgumentError); + expect(() => Channel.team(''), throwsArgumentError); }); test('returns teams channel with specific team ID', () { - expect(Channel.team('team1').toString(), 'teams.team1'); + expect(Channel.team('team1').toString(), 'teams.team1'); }); test('returns teams channel with action', () { - expect(Channel.team('team1').create().toString(), 'teams.team1.create'); + expect(Channel.team('team1').create().toString(), 'teams.team1.create'); }); }); group('memberships()', () { test('throws when membership id is missing', () { - expect(() => Channel.membership(''), throwsArgumentError); + expect(() => Channel.membership(''), throwsArgumentError); }); test('returns memberships channel with specific membership ID', () { - expect(Channel.membership('membership1').toString(), 'memberships.membership1'); + expect(Channel.membership('membership1').toString(), + 'memberships.membership1'); }); test('returns memberships channel with action', () { - expect(Channel.membership('membership1').update().toString(), + expect(Channel.membership('membership1').update().toString(), 'memberships.membership1.update'); }); }); diff --git a/test/query_test.dart b/test/query_test.dart index 25388fad..db7b9214 100644 --- a/test/query_test.dart +++ b/test/query_test.dart @@ -354,4 +354,3 @@ void main() { expect(query['method'], 'between'); }); } - diff --git a/test/services/account_test.dart b/test/services/account_test.dart index bd65aa32..d5d61fe7 100644 --- a/test/services/account_test.dart +++ b/test/services/account_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,1540 +40,1356 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Account test', () { - late MockClient client; - late Account account; - - setUp(() { - client = MockClient(); - account = Account(client); - }); - - test('test method get()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.get( - ); - expect(response, isA()); - - }); - - test('test method create()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.create( - userId: '', - email: 'email@example.com', - password: 'password', - ); - expect(response, isA()); - - }); - - test('test method updateEmail()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateEmail( - email: 'email@example.com', - password: 'password', - ); - expect(response, isA()); - - }); - - test('test method listIdentities()', () async { - - final Map data = { - 'total': 5, - 'identities': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.listIdentities( - ); - expect(response, isA()); - - }); - - test('test method deleteIdentity()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.deleteIdentity( - identityId: '', - ); - }); - - test('test method createJWT()', () async { - - final Map data = { - 'jwt': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createJWT( - ); - expect(response, isA()); - - }); - - test('test method listLogs()', () async { - - final Map data = { - 'total': 5, - 'logs': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.listLogs( - ); - expect(response, isA()); - - }); - - test('test method updateMFA()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateMFA( - mfa: true, - ); - expect(response, isA()); - - }); - - test('test method createMfaAuthenticator()', () async { - - final Map data = { - 'secret': '[SHARED_SECRET]', - 'uri': 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createMfaAuthenticator( - type: enums.AuthenticatorType.totp, - ); - expect(response, isA()); - - }); - - test('test method createMFAAuthenticator()', () async { - - final Map data = { - 'secret': '[SHARED_SECRET]', - 'uri': 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createMFAAuthenticator( - type: enums.AuthenticatorType.totp, - ); - expect(response, isA()); - - }); - - test('test method updateMfaAuthenticator()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateMfaAuthenticator( - type: enums.AuthenticatorType.totp, - otp: '', - ); - expect(response, isA()); - - }); - - test('test method updateMFAAuthenticator()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateMFAAuthenticator( - type: enums.AuthenticatorType.totp, - otp: '', - ); - expect(response, isA()); - - }); - - test('test method deleteMfaAuthenticator()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.deleteMfaAuthenticator( - type: enums.AuthenticatorType.totp, - ); - }); - - test('test method deleteMFAAuthenticator()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.deleteMFAAuthenticator( - type: enums.AuthenticatorType.totp, - ); - }); - - test('test method createMfaChallenge()', () async { - - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'expire': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createMfaChallenge( - factor: enums.AuthenticationFactor.email, - ); - expect(response, isA()); - - }); - - test('test method createMFAChallenge()', () async { - - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'expire': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createMFAChallenge( - factor: enums.AuthenticationFactor.email, - ); - expect(response, isA()); - - }); - - test('test method updateMfaChallenge()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateMfaChallenge( - challengeId: '', - otp: '', - ); - expect(response, isA()); - - }); - - test('test method updateMFAChallenge()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateMFAChallenge( - challengeId: '', - otp: '', - ); - expect(response, isA()); - - }); - - test('test method listMfaFactors()', () async { - - final Map data = { - 'totp': true, - 'phone': true, - 'email': true, - 'recoveryCode': true,}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.listMfaFactors( - ); - expect(response, isA()); - - }); - - test('test method listMFAFactors()', () async { - - final Map data = { - 'totp': true, - 'phone': true, - 'email': true, - 'recoveryCode': true,}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.listMFAFactors( - ); - expect(response, isA()); - - }); - - test('test method getMfaRecoveryCodes()', () async { - - final Map data = { - 'recoveryCodes': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.getMfaRecoveryCodes( - ); - expect(response, isA()); - - }); - - test('test method getMFARecoveryCodes()', () async { - - final Map data = { - 'recoveryCodes': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.getMFARecoveryCodes( - ); - expect(response, isA()); - - }); - - test('test method createMfaRecoveryCodes()', () async { - - final Map data = { - 'recoveryCodes': [],}; - + group('Account test', () { + late MockClient client; + late Account account; - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createMfaRecoveryCodes( - ); - expect(response, isA()); - - }); - - test('test method createMFARecoveryCodes()', () async { - - final Map data = { - 'recoveryCodes': [],}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createMFARecoveryCodes( - ); - expect(response, isA()); - - }); - - test('test method updateMfaRecoveryCodes()', () async { - - final Map data = { - 'recoveryCodes': [],}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateMfaRecoveryCodes( - ); - expect(response, isA()); - - }); - - test('test method updateMFARecoveryCodes()', () async { - - final Map data = { - 'recoveryCodes': [],}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateMFARecoveryCodes( - ); - expect(response, isA()); - - }); - - test('test method updateName()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateName( - name: '', - ); - expect(response, isA()); - - }); - - test('test method updatePassword()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updatePassword( - password: 'password', - ); - expect(response, isA()); - - }); - - test('test method updatePhone()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updatePhone( - phone: '+12065550100', - password: 'password', - ); - expect(response, isA()); - - }); - - test('test method getPrefs()', () async { - - final Map data = {}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.getPrefs( - ); - expect(response, isA()); - - }); - - test('test method updatePrefs()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updatePrefs( - prefs: {}, - ); - expect(response, isA()); - - }); - - test('test method createRecovery()', () async { - - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createRecovery( - email: 'email@example.com', - url: 'https://example.com', - ); - expect(response, isA()); - - }); - - test('test method updateRecovery()', () async { - - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + setUp(() { + client = MockClient(); + account = Account(client); + }); + test('test method get()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.get(); + expect(response, isA()); + }); - final response = await account.updateRecovery( - userId: '', - secret: '', - password: 'password', - ); - expect(response, isA()); + test('test method create()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.create( + userId: '', + email: 'email@example.com', + password: 'password', + ); + expect(response, isA()); + }); - }); + test('test method updateEmail()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateEmail( + email: 'email@example.com', + password: 'password', + ); + expect(response, isA()); + }); - test('test method listSessions()', () async { - - final Map data = { - 'total': 5, - 'sessions': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.listSessions( - ); - expect(response, isA()); - - }); - - test('test method deleteSessions()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.deleteSessions( - ); - }); - - test('test method createAnonymousSession()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createAnonymousSession( - ); - expect(response, isA()); - - }); - - test('test method createEmailPasswordSession()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createEmailPasswordSession( - email: 'email@example.com', - password: 'password', - ); - expect(response, isA()); - - }); - - test('test method updateMagicURLSession()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateMagicURLSession( - userId: '', - secret: '', - ); - expect(response, isA()); - - }); - - test('test method createOAuth2Session()', () async { - - - when(client.webAuth( - argThat(isNotNull), - )).thenAnswer((_) async => 'done'); - - - final response = await account.createOAuth2Session( - provider: enums.OAuthProvider.amazon, - ); - expect(response, equals('done')); - - }); - - test('test method updatePhoneSession()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updatePhoneSession( - userId: '', - secret: '', - ); - expect(response, isA()); - - }); - - test('test method createSession()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.createSession( - userId: '', - secret: '', - ); - expect(response, isA()); - - }); - - test('test method getSession()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.getSession( - sessionId: '', - ); - expect(response, isA()); - - }); - - test('test method updateSession()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', - 'current': true, - 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.updateSession( - sessionId: '', - ); - expect(response, isA()); - - }); - - test('test method deleteSession()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await account.deleteSession( - sessionId: '', - ); - }); - - test('test method updateStatus()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', - 'status': true, - 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', - 'emailVerification': true, - 'phoneVerification': true, - 'mfa': true, - 'prefs': {}, - 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + test('test method listIdentities()', () async { + final Map data = { + 'total': 5, + 'identities': [], + }; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + final response = await account.listIdentities(); + expect(response, isA()); + }); + test('test method deleteIdentity()', () async { + final data = ''; - final response = await account.updateStatus( - ); - expect(response, isA()); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await account.deleteIdentity( + identityId: '', + ); + }); - test('test method createPushTarget()', () async { + test('test method createJWT()', () async { + final Map data = { + 'jwt': + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', + }; - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'Apple iPhone 12', - 'userId': '259125845563242502', - 'providerType': 'email', - 'identifier': 'token', - 'expired': true,}; + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + final response = await account.createJWT(); + expect(response, isA()); + }); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + test('test method listLogs()', () async { + final Map data = { + 'total': 5, + 'logs': [], + }; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await account.createPushTarget( - targetId: '', - identifier: '', - ); - expect(response, isA()); + final response = await account.listLogs(); + expect(response, isA()); + }); - }); + test('test method updateMFA()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateMFA( + mfa: true, + ); + expect(response, isA()); + }); - test('test method updatePushTarget()', () async { + test('test method createMfaAuthenticator()', () async { + final Map data = { + 'secret': '[SHARED_SECRET]', + 'uri': + 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createMfaAuthenticator( + type: enums.AuthenticatorType.totp, + ); + expect(response, isA()); + }); - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'Apple iPhone 12', - 'userId': '259125845563242502', - 'providerType': 'email', - 'identifier': 'token', - 'expired': true,}; + test('test method createMFAAuthenticator()', () async { + final Map data = { + 'secret': '[SHARED_SECRET]', + 'uri': + 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createMFAAuthenticator( + type: enums.AuthenticatorType.totp, + ); + expect(response, isA()); + }); + test('test method updateMfaAuthenticator()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateMfaAuthenticator( + type: enums.AuthenticatorType.totp, + otp: '', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + test('test method updateMFAAuthenticator()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateMFAAuthenticator( + type: enums.AuthenticatorType.totp, + otp: '', + ); + expect(response, isA()); + }); + test('test method deleteMfaAuthenticator()', () async { + final data = ''; - final response = await account.updatePushTarget( - targetId: '', - identifier: '', - ); - expect(response, isA()); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await account.deleteMfaAuthenticator( + type: enums.AuthenticatorType.totp, + ); + }); - test('test method deletePushTarget()', () async { + test('test method deleteMFAAuthenticator()', () async { + final data = ''; - final data = ''; + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + final response = await account.deleteMFAAuthenticator( + type: enums.AuthenticatorType.totp, + ); + }); + test('test method createMfaChallenge()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'expire': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createMfaChallenge( + factor: enums.AuthenticationFactor.email, + ); + expect(response, isA()); + }); - final response = await account.deletePushTarget( - targetId: '', - ); - }); + test('test method createMFAChallenge()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'expire': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createMFAChallenge( + factor: enums.AuthenticationFactor.email, + ); + expect(response, isA()); + }); - test('test method createEmailToken()', () async { + test('test method updateMfaChallenge()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateMfaChallenge( + challengeId: '', + otp: '', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + test('test method updateMFAChallenge()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateMFAChallenge( + challengeId: '', + otp: '', + ); + expect(response, isA()); + }); + test('test method listMfaFactors()', () async { + final Map data = { + 'totp': true, + 'phone': true, + 'email': true, + 'recoveryCode': true, + }; - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await account.listMfaFactors(); + expect(response, isA()); + }); - final response = await account.createEmailToken( - userId: '', - email: 'email@example.com', - ); - expect(response, isA()); + test('test method listMFAFactors()', () async { + final Map data = { + 'totp': true, + 'phone': true, + 'email': true, + 'recoveryCode': true, + }; - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method createMagicURLToken()', () async { + final response = await account.listMFAFactors(); + expect(response, isA()); + }); - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + test('test method getMfaRecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [], + }; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + final response = await account.getMfaRecoveryCodes(); + expect(response, isA()); + }); + test('test method getMFARecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [], + }; - final response = await account.createMagicURLToken( - userId: '', - email: 'email@example.com', - ); - expect(response, isA()); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await account.getMFARecoveryCodes(); + expect(response, isA()); + }); - test('test method createOAuth2Token()', () async { + test('test method createMfaRecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [], + }; + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - when(client.webAuth( - argThat(isNotNull), - )).thenAnswer((_) async => 'done'); + final response = await account.createMfaRecoveryCodes(); + expect(response, isA()); + }); + test('test method createMFARecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [], + }; - final response = await account.createOAuth2Token( - provider: enums.OAuthProvider.amazon, - ); - expect(response, equals('done')); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await account.createMFARecoveryCodes(); + expect(response, isA()); + }); - test('test method createPhoneToken()', () async { + test('test method updateMfaRecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [], + }; - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + final response = await account.updateMfaRecoveryCodes(); + expect(response, isA()); + }); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + test('test method updateMFARecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [], + }; + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); - final response = await account.createPhoneToken( - userId: '', - phone: '+12065550100', - ); - expect(response, isA()); + final response = await account.updateMFARecoveryCodes(); + expect(response, isA()); + }); - }); + test('test method updateName()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateName( + name: '', + ); + expect(response, isA()); + }); - test('test method createEmailVerification()', () async { + test('test method updatePassword()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updatePassword( + password: 'password', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + test('test method updatePhone()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updatePhone( + phone: '+12065550100', + password: 'password', + ); + expect(response, isA()); + }); + test('test method getPrefs()', () async { + final Map data = {}; - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await account.getPrefs(); + expect(response, isA()); + }); - final response = await account.createEmailVerification( - url: 'https://example.com', - ); - expect(response, isA()); + test('test method updatePrefs()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updatePrefs( + prefs: {}, + ); + expect(response, isA()); + }); - }); + test('test method createRecovery()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createRecovery( + email: 'email@example.com', + url: 'https://example.com', + ); + expect(response, isA()); + }); - test('test method createVerification()', () async { + test('test method updateRecovery()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateRecovery( + userId: '', + secret: '', + password: 'password', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + test('test method listSessions()', () async { + final Map data = { + 'total': 5, + 'sessions': [], + }; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + final response = await account.listSessions(); + expect(response, isA()); + }); + test('test method deleteSessions()', () async { + final data = ''; - final response = await account.createVerification( - url: 'https://example.com', - ); - expect(response, isA()); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await account.deleteSessions(); + }); - test('test method updateEmailVerification()', () async { + test('test method createAnonymousSession()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createAnonymousSession(); + expect(response, isA()); + }); - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + test('test method createEmailPasswordSession()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createEmailPasswordSession( + email: 'email@example.com', + password: 'password', + ); + expect(response, isA()); + }); + test('test method updateMagicURLSession()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateMagicURLSession( + userId: '', + secret: '', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + test('test method createOAuth2Session()', () async { + when(client.webAuth( + argThat(isNotNull), + )).thenAnswer((_) async => 'done'); + final response = await account.createOAuth2Session( + provider: enums.OAuthProvider.amazon, + ); + expect(response, equals('done')); + }); - final response = await account.updateEmailVerification( - userId: '', - secret: '', - ); - expect(response, isA()); + test('test method updatePhoneSession()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updatePhoneSession( + userId: '', + secret: '', + ); + expect(response, isA()); + }); - }); + test('test method createSession()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createSession( + userId: '', + secret: '', + ); + expect(response, isA()); + }); - test('test method updateVerification()', () async { + test('test method getSession()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.getSession( + sessionId: '', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + test('test method updateSession()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateSession( + sessionId: '', + ); + expect(response, isA()); + }); + test('test method deleteSession()', () async { + final data = ''; - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + final response = await account.deleteSession( + sessionId: '', + ); + }); - final response = await account.updateVerification( - userId: '', - secret: '', - ); - expect(response, isA()); + test('test method updateStatus()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateStatus(); + expect(response, isA()); + }); - }); + test('test method createPushTarget()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Apple iPhone 12', + 'userId': '259125845563242502', + 'providerType': 'email', + 'identifier': 'token', + 'expired': true, + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createPushTarget( + targetId: '', + identifier: '', + ); + expect(response, isA()); + }); - test('test method createPhoneVerification()', () async { + test('test method updatePushTarget()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Apple iPhone 12', + 'userId': '259125845563242502', + 'providerType': 'email', + 'identifier': 'token', + 'expired': true, + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updatePushTarget( + targetId: '', + identifier: '', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + test('test method deletePushTarget()', () async { + final data = ''; + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + final response = await account.deletePushTarget( + targetId: '', + ); + }); + test('test method createEmailToken()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createEmailToken( + userId: '', + email: 'email@example.com', + ); + expect(response, isA()); + }); - final response = await account.createPhoneVerification( - ); - expect(response, isA()); + test('test method createMagicURLToken()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createMagicURLToken( + userId: '', + email: 'email@example.com', + ); + expect(response, isA()); + }); - }); + test('test method createOAuth2Token()', () async { + when(client.webAuth( + argThat(isNotNull), + )).thenAnswer((_) async => 'done'); - test('test method updatePhoneVerification()', () async { + final response = await account.createOAuth2Token( + provider: enums.OAuthProvider.amazon, + ); + expect(response, equals('done')); + }); - final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox',}; + test('test method createPhoneToken()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createPhoneToken( + userId: '', + phone: '+12065550100', + ); + expect(response, isA()); + }); + test('test method createEmailVerification()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createEmailVerification( + url: 'https://example.com', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + test('test method createVerification()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createVerification( + url: 'https://example.com', + ); + expect(response, isA()); + }); + test('test method updateEmailVerification()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateEmailVerification( + userId: '', + secret: '', + ); + expect(response, isA()); + }); - final response = await account.updatePhoneVerification( - userId: '', - secret: '', - ); - expect(response, isA()); + test('test method updateVerification()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateVerification( + userId: '', + secret: '', + ); + expect(response, isA()); + }); - }); + test('test method createPhoneVerification()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.createPhoneVerification(); + expect(response, isA()); + }); + test('test method updatePhoneVerification()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await account.updatePhoneVerification( + userId: '', + secret: '', + ); + expect(response, isA()); }); + }); } diff --git a/test/services/avatars_test.dart b/test/services/avatars_test.dart index 4bdb434d..8d2c48fb 100644 --- a/test/services/avatars_test.dart +++ b/test/services/avatars_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,138 +40,123 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Avatars test', () { - late MockClient client; - late Avatars avatars; - - setUp(() { - client = MockClient(); - avatars = Avatars(client); - }); - - test('test method getBrowser()', () async { -final Uint8List data = Uint8List.fromList([]); - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await avatars.getBrowser( - code: enums.Browser.avantBrowser, - ); - expect(response, isA()); - - }); - - test('test method getCreditCard()', () async { -final Uint8List data = Uint8List.fromList([]); - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await avatars.getCreditCard( - code: enums.CreditCard.americanExpress, - ); - expect(response, isA()); - - }); - - test('test method getFavicon()', () async { -final Uint8List data = Uint8List.fromList([]); + group('Avatars test', () { + late MockClient client; + late Avatars avatars; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await avatars.getFavicon( - url: 'https://example.com', - ); - expect(response, isA()); - - }); - - test('test method getFlag()', () async { -final Uint8List data = Uint8List.fromList([]); - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + setUp(() { + client = MockClient(); + avatars = Avatars(client); + }); + test('test method getBrowser()', () async { + final Uint8List data = Uint8List.fromList([]); - final response = await avatars.getFlag( - code: enums.Flag.afghanistan, - ); - expect(response, isA()); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await avatars.getBrowser( + code: enums.Browser.avantBrowser, + ); + expect(response, isA()); + }); - test('test method getImage()', () async { -final Uint8List data = Uint8List.fromList([]); + test('test method getCreditCard()', () async { + final Uint8List data = Uint8List.fromList([]); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await avatars.getCreditCard( + code: enums.CreditCard.americanExpress, + ); + expect(response, isA()); + }); - final response = await avatars.getImage( - url: 'https://example.com', - ); - expect(response, isA()); + test('test method getFavicon()', () async { + final Uint8List data = Uint8List.fromList([]); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method getInitials()', () async { -final Uint8List data = Uint8List.fromList([]); + final response = await avatars.getFavicon( + url: 'https://example.com', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + test('test method getFlag()', () async { + final Uint8List data = Uint8List.fromList([]); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await avatars.getInitials( - ); - expect(response, isA()); + final response = await avatars.getFlag( + code: enums.Flag.afghanistan, + ); + expect(response, isA()); + }); - }); + test('test method getImage()', () async { + final Uint8List data = Uint8List.fromList([]); - test('test method getQR()', () async { -final Uint8List data = Uint8List.fromList([]); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final response = await avatars.getImage( + url: 'https://example.com', + ); + expect(response, isA()); + }); + test('test method getInitials()', () async { + final Uint8List data = Uint8List.fromList([]); - final response = await avatars.getQR( - text: '', - ); - expect(response, isA()); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await avatars.getInitials(); + expect(response, isA()); + }); - test('test method getScreenshot()', () async { -final Uint8List data = Uint8List.fromList([]); + test('test method getQR()', () async { + final Uint8List data = Uint8List.fromList([]); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await avatars.getQR( + text: '', + ); + expect(response, isA()); + }); - final response = await avatars.getScreenshot( - url: 'https://example.com', - ); - expect(response, isA()); + test('test method getScreenshot()', () async { + final Uint8List data = Uint8List.fromList([]); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await avatars.getScreenshot( + url: 'https://example.com', + ); + expect(response, isA()); }); + }); } diff --git a/test/services/databases_test.dart b/test/services/databases_test.dart index a4b0a6cc..a3807093 100644 --- a/test/services/databases_test.dart +++ b/test/services/databases_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,337 +40,297 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Databases test', () { - late MockClient client; - late Databases databases; - - setUp(() { - client = MockClient(); - databases = Databases(client); - }); - - test('test method listTransactions()', () async { - - final Map data = { - 'total': 5, - 'transactions': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.listTransactions( - ); - expect(response, isA()); - - }); - - test('test method createTransaction()', () async { - - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.createTransaction( - ); - expect(response, isA()); - - }); - - test('test method getTransaction()', () async { - - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.getTransaction( - transactionId: '', - ); - expect(response, isA()); - - }); - - test('test method updateTransaction()', () async { - - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.updateTransaction( - transactionId: '', - ); - expect(response, isA()); - - }); - - test('test method deleteTransaction()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.deleteTransaction( - transactionId: '', - ); - }); - - test('test method createOperations()', () async { - - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.createOperations( - transactionId: '', - ); - expect(response, isA()); - - }); - - test('test method listDocuments()', () async { - - final Map data = { - 'total': 5, - 'documents': [],}; - + group('Databases test', () { + late MockClient client; + late Databases databases; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.listDocuments( - databaseId: '', - collectionId: '', - ); - expect(response, isA()); - - }); - - test('test method createDocument()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.createDocument( - databaseId: '', - collectionId: '', - documentId: '', - data: {}, - ); - expect(response, isA()); - - }); - - test('test method getDocument()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.getDocument( - databaseId: '', - collectionId: '', - documentId: '', - ); - expect(response, isA()); - - }); - - test('test method upsertDocument()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.upsertDocument( - databaseId: '', - collectionId: '', - documentId: '', - ); - expect(response, isA()); - - }); - - test('test method updateDocument()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await databases.updateDocument( - databaseId: '', - collectionId: '', - documentId: '', - ); - expect(response, isA()); - - }); + setUp(() { + client = MockClient(); + databases = Databases(client); + }); - test('test method deleteDocument()', () async { + test('test method listTransactions()', () async { + final Map data = { + 'total': 5, + 'transactions': [], + }; - final data = ''; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + final response = await databases.listTransactions(); + expect(response, isA()); + }); + test('test method createTransaction()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.createTransaction(); + expect(response, isA()); + }); - final response = await databases.deleteDocument( - databaseId: '', - collectionId: '', - documentId: '', - ); - }); + test('test method getTransaction()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.getTransaction( + transactionId: '', + ); + expect(response, isA()); + }); - test('test method decrementDocumentAttribute()', () async { + test('test method updateTransaction()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.updateTransaction( + transactionId: '', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; + test('test method deleteTransaction()', () async { + final data = ''; + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + final response = await databases.deleteTransaction( + transactionId: '', + ); + }); + test('test method createOperations()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.createOperations( + transactionId: '', + ); + expect(response, isA()); + }); - final response = await databases.decrementDocumentAttribute( - databaseId: '', - collectionId: '', - documentId: '', - attribute: '', - ); - expect(response, isA()); + test('test method listDocuments()', () async { + final Map data = { + 'total': 5, + 'documents': [], + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.listDocuments( + databaseId: '', + collectionId: '', + ); + expect(response, isA()); + }); - }); + test('test method createDocument()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.createDocument( + databaseId: '', + collectionId: '', + documentId: '', + data: {}, + ); + expect(response, isA()); + }); - test('test method incrementDocumentAttribute()', () async { + test('test method getDocument()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.getDocument( + databaseId: '', + collectionId: '', + documentId: '', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; + test('test method upsertDocument()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.upsertDocument( + databaseId: '', + collectionId: '', + documentId: '', + ); + expect(response, isA()); + }); + test('test method updateDocument()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.updateDocument( + databaseId: '', + collectionId: '', + documentId: '', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + test('test method deleteDocument()', () async { + final data = ''; + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - final response = await databases.incrementDocumentAttribute( - databaseId: '', - collectionId: '', - documentId: '', - attribute: '', - ); - expect(response, isA()); + final response = await databases.deleteDocument( + databaseId: '', + collectionId: '', + documentId: '', + ); + }); - }); + test('test method decrementDocumentAttribute()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.decrementDocumentAttribute( + databaseId: '', + collectionId: '', + documentId: '', + attribute: '', + ); + expect(response, isA()); + }); + test('test method incrementDocumentAttribute()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await databases.incrementDocumentAttribute( + databaseId: '', + collectionId: '', + documentId: '', + attribute: '', + ); + expect(response, isA()); }); + }); } diff --git a/test/services/functions_test.dart b/test/services/functions_test.dart index 9b0d046f..c6e50a50 100644 --- a/test/services/functions_test.dart +++ b/test/services/functions_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,107 +40,100 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Functions test', () { - late MockClient client; - late Functions functions; - - setUp(() { - client = MockClient(); - functions = Functions(client); - }); - - test('test method listExecutions()', () async { - - final Map data = { - 'total': 5, - 'executions': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await functions.listExecutions( - functionId: '', - ); - expect(response, isA()); - - }); - - test('test method createExecution()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'functionId': '5e5ea6g16897e', - 'deploymentId': '5e5ea5c16897e', - 'trigger': 'http', - 'status': 'processing', - 'requestMethod': 'GET', - 'requestPath': '/articles?id=5', - 'requestHeaders': [], - 'responseStatusCode': 200, - 'responseBody': '', - 'responseHeaders': [], - 'logs': '', - 'errors': '', - 'duration': 0.4,}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await functions.createExecution( - functionId: '', - ); - expect(response, isA()); - - }); - - test('test method getExecution()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'functionId': '5e5ea6g16897e', - 'deploymentId': '5e5ea5c16897e', - 'trigger': 'http', - 'status': 'processing', - 'requestMethod': 'GET', - 'requestPath': '/articles?id=5', - 'requestHeaders': [], - 'responseStatusCode': 200, - 'responseBody': '', - 'responseHeaders': [], - 'logs': '', - 'errors': '', - 'duration': 0.4,}; + group('Functions test', () { + late MockClient client; + late Functions functions; + setUp(() { + client = MockClient(); + functions = Functions(client); + }); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + test('test method listExecutions()', () async { + final Map data = { + 'total': 5, + 'executions': [], + }; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await functions.getExecution( - functionId: '', - executionId: '', - ); - expect(response, isA()); + final response = await functions.listExecutions( + functionId: '', + ); + expect(response, isA()); + }); - }); + test('test method createExecution()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'functionId': '5e5ea6g16897e', + 'deploymentId': '5e5ea5c16897e', + 'trigger': 'http', + 'status': 'processing', + 'requestMethod': 'GET', + 'requestPath': '/articles?id=5', + 'requestHeaders': [], + 'responseStatusCode': 200, + 'responseBody': '', + 'responseHeaders': [], + 'logs': '', + 'errors': '', + 'duration': 0.4, + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await functions.createExecution( + functionId: '', + ); + expect(response, isA()); + }); + test('test method getExecution()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'functionId': '5e5ea6g16897e', + 'deploymentId': '5e5ea5c16897e', + 'trigger': 'http', + 'status': 'processing', + 'requestMethod': 'GET', + 'requestPath': '/articles?id=5', + 'requestHeaders': [], + 'responseStatusCode': 200, + 'responseBody': '', + 'responseHeaders': [], + 'logs': '', + 'errors': '', + 'duration': 0.4, + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await functions.getExecution( + functionId: '', + executionId: '', + ); + expect(response, isA()); }); + }); } diff --git a/test/services/graphql_test.dart b/test/services/graphql_test.dart index c548e414..84b7de1c 100644 --- a/test/services/graphql_test.dart +++ b/test/services/graphql_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,47 +40,45 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Graphql test', () { - late MockClient client; - late Graphql graphql; - - setUp(() { - client = MockClient(); - graphql = Graphql(client); - }); - - test('test method query()', () async { - - final data = ''; + group('Graphql test', () { + late MockClient client; + late Graphql graphql; - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await graphql.query( - query: {}, - ); - }); + setUp(() { + client = MockClient(); + graphql = Graphql(client); + }); - test('test method mutation()', () async { + test('test method query()', () async { + final data = ''; - final data = ''; + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + final response = await graphql.query( + query: {}, + ); + }); + test('test method mutation()', () async { + final data = ''; - final response = await graphql.mutation( - query: {}, - ); - }); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + final response = await graphql.mutation( + query: {}, + ); }); + }); } diff --git a/test/services/locale_test.dart b/test/services/locale_test.dart index 42faaf72..f9f6489d 100644 --- a/test/services/locale_test.dart +++ b/test/services/locale_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,168 +40,138 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Locale test', () { - late MockClient client; - late Locale locale; - - setUp(() { - client = MockClient(); - locale = Locale(client); - }); - - test('test method get()', () async { - - final Map data = { - 'ip': '127.0.0.1', - 'countryCode': 'US', - 'country': 'United States', - 'continentCode': 'NA', - 'continent': 'North America', - 'eu': true, - 'currency': 'USD',}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await locale.get( - ); - expect(response, isA()); - - }); - - test('test method listCodes()', () async { - - final Map data = { - 'total': 5, - 'localeCodes': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await locale.listCodes( - ); - expect(response, isA()); - - }); - - test('test method listContinents()', () async { - - final Map data = { - 'total': 5, - 'continents': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await locale.listContinents( - ); - expect(response, isA()); + group('Locale test', () { + late MockClient client; + late Locale locale; - }); - - test('test method listCountries()', () async { - - final Map data = { - 'total': 5, - 'countries': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await locale.listCountries( - ); - expect(response, isA()); - - }); - - test('test method listCountriesEU()', () async { - - final Map data = { - 'total': 5, - 'countries': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await locale.listCountriesEU( - ); - expect(response, isA()); - - }); + setUp(() { + client = MockClient(); + locale = Locale(client); + }); - test('test method listCountriesPhones()', () async { + test('test method get()', () async { + final Map data = { + 'ip': '127.0.0.1', + 'countryCode': 'US', + 'country': 'United States', + 'continentCode': 'NA', + 'continent': 'North America', + 'eu': true, + 'currency': 'USD', + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await locale.get(); + expect(response, isA()); + }); - final Map data = { - 'total': 5, - 'phones': [],}; + test('test method listCodes()', () async { + final Map data = { + 'total': 5, + 'localeCodes': [], + }; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final response = await locale.listCodes(); + expect(response, isA()); + }); + test('test method listContinents()', () async { + final Map data = { + 'total': 5, + 'continents': [], + }; - final response = await locale.listCountriesPhones( - ); - expect(response, isA()); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await locale.listContinents(); + expect(response, isA()); + }); - test('test method listCurrencies()', () async { + test('test method listCountries()', () async { + final Map data = { + 'total': 5, + 'countries': [], + }; - final Map data = { - 'total': 5, - 'currencies': [],}; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await locale.listCountries(); + expect(response, isA()); + }); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + test('test method listCountriesEU()', () async { + final Map data = { + 'total': 5, + 'countries': [], + }; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await locale.listCurrencies( - ); - expect(response, isA()); + final response = await locale.listCountriesEU(); + expect(response, isA()); + }); - }); + test('test method listCountriesPhones()', () async { + final Map data = { + 'total': 5, + 'phones': [], + }; - test('test method listLanguages()', () async { + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final Map data = { - 'total': 5, - 'languages': [],}; + final response = await locale.listCountriesPhones(); + expect(response, isA()); + }); + test('test method listCurrencies()', () async { + final Map data = { + 'total': 5, + 'currencies': [], + }; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await locale.listCurrencies(); + expect(response, isA()); + }); - final response = await locale.listLanguages( - ); - expect(response, isA()); + test('test method listLanguages()', () async { + final Map data = { + 'total': 5, + 'languages': [], + }; - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await locale.listLanguages(); + expect(response, isA()); }); + }); } diff --git a/test/services/messaging_test.dart b/test/services/messaging_test.dart index 5899ace3..0c938eff 100644 --- a/test/services/messaging_test.dart +++ b/test/services/messaging_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,71 +40,68 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Messaging test', () { - late MockClient client; - late Messaging messaging; - - setUp(() { - client = MockClient(); - messaging = Messaging(client); - }); - - test('test method createSubscriber()', () async { - - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'targetId': '259125845563242502', - 'target': { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'Apple iPhone 12', - 'userId': '259125845563242502', - 'providerType': 'email', - 'identifier': 'token', - 'expired': true, - }, - 'userId': '5e5ea5c16897e', - 'userName': 'Aegon Targaryen', - 'topicId': '259125845563242502', - 'providerType': 'email',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + group('Messaging test', () { + late MockClient client; + late Messaging messaging; + setUp(() { + client = MockClient(); + messaging = Messaging(client); + }); - final response = await messaging.createSubscriber( - topicId: '', - subscriberId: '', - targetId: '', - ); - expect(response, isA()); - - }); - - test('test method deleteSubscriber()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + test('test method createSubscriber()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'targetId': '259125845563242502', + 'target': { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Apple iPhone 12', + 'userId': '259125845563242502', + 'providerType': 'email', + 'identifier': 'token', + 'expired': true, + }, + 'userId': '5e5ea5c16897e', + 'userName': 'Aegon Targaryen', + 'topicId': '259125845563242502', + 'providerType': 'email', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await messaging.createSubscriber( + topicId: '', + subscriberId: '', + targetId: '', + ); + expect(response, isA()); + }); + test('test method deleteSubscriber()', () async { + final data = ''; - final response = await messaging.deleteSubscriber( - topicId: '', - subscriberId: '', - ); - }); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + final response = await messaging.deleteSubscriber( + topicId: '', + subscriberId: '', + ); }); + }); } diff --git a/test/services/presences_test.dart b/test/services/presences_test.dart index 7b99675f..7fed0439 100644 --- a/test/services/presences_test.dart +++ b/test/services/presences_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,121 +40,108 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Presences test', () { - late MockClient client; - late Presences presences; - - setUp(() { - client = MockClient(); - presences = Presences(client); - }); - - test('test method list()', () async { - - final Map data = { - 'total': 5, - 'presences': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await presences.list( - ); - expect(response, isA()); - - }); - - test('test method get()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'userId': '674af8f3e12a5f9ac0be', - 'source': 'HTTP',}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await presences.get( - presenceId: '', - ); - expect(response, isA()); - - }); + group('Presences test', () { + late MockClient client; + late Presences presences; - test('test method upsert()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'userId': '674af8f3e12a5f9ac0be', - 'source': 'HTTP',}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await presences.upsert( - presenceId: '', - status: '', - ); - expect(response, isA()); - - }); - - test('test method update()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'userId': '674af8f3e12a5f9ac0be', - 'source': 'HTTP',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + setUp(() { + client = MockClient(); + presences = Presences(client); + }); + test('test method list()', () async { + final Map data = { + 'total': 5, + 'presences': [], + }; - final response = await presences.update( - presenceId: '', - ); - expect(response, isA()); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await presences.list(); + expect(response, isA()); + }); - test('test method delete()', () async { + test('test method get()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'userId': '674af8f3e12a5f9ac0be', + 'source': 'HTTP', + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await presences.get( + presenceId: '', + ); + expect(response, isA()); + }); - final data = ''; + test('test method upsert()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'userId': '674af8f3e12a5f9ac0be', + 'source': 'HTTP', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await presences.upsert( + presenceId: '', + status: '', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + test('test method update()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'userId': '674af8f3e12a5f9ac0be', + 'source': 'HTTP', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await presences.update( + presenceId: '', + ); + expect(response, isA()); + }); + test('test method delete()', () async { + final data = ''; - final response = await presences.delete( - presenceId: '', - ); - }); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + final response = await presences.delete( + presenceId: '', + ); }); + }); } diff --git a/test/services/storage_test.dart b/test/services/storage_test.dart index 2390bfdd..55a42f94 100644 --- a/test/services/storage_test.dart +++ b/test/services/storage_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,202 +40,184 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Storage test', () { - late MockClient client; - late Storage storage; - - setUp(() { - client = MockClient(); - storage = Storage(client); - }); - - test('test method listFiles()', () async { - - final Map data = { - 'total': 5, - 'files': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await storage.listFiles( - bucketId: '', - ); - expect(response, isA()); - - }); - - test('test method createFile()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - 'bucketId': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'name': 'Pink.png', - 'signature': '5d529fd02b544198ae075bd57c1762bb', - 'mimeType': 'image/png', - 'sizeOriginal': 17890, - 'sizeActual': 12345, - 'chunksTotal': 17890, - 'chunksUploaded': 17890, - 'encryption': true, - 'compression': 'gzip',}; - - - when(client.chunkedUpload( - path: argThat(isNotNull), - params: argThat(isNotNull), - paramName: argThat(isNotNull), - idParamName: argThat(isNotNull), - headers: argThat(isNotNull), - )).thenAnswer((_) async => Response(data: data)); - - - final response = await storage.createFile( - bucketId: '', - fileId: '', - file: InputFile.fromPath(path: './image.png'), - ); - expect(response, isA()); - - }); - - test('test method getFile()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - 'bucketId': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'name': 'Pink.png', - 'signature': '5d529fd02b544198ae075bd57c1762bb', - 'mimeType': 'image/png', - 'sizeOriginal': 17890, - 'sizeActual': 12345, - 'chunksTotal': 17890, - 'chunksUploaded': 17890, - 'encryption': true, - 'compression': 'gzip',}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await storage.getFile( - bucketId: '', - fileId: '', - ); - expect(response, isA()); - - }); - - test('test method updateFile()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - 'bucketId': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [], - 'name': 'Pink.png', - 'signature': '5d529fd02b544198ae075bd57c1762bb', - 'mimeType': 'image/png', - 'sizeOriginal': 17890, - 'sizeActual': 12345, - 'chunksTotal': 17890, - 'chunksUploaded': 17890, - 'encryption': true, - 'compression': 'gzip',}; - + group('Storage test', () { + late MockClient client; + late Storage storage; - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await storage.updateFile( - bucketId: '', - fileId: '', - ); - expect(response, isA()); - - }); - - test('test method deleteFile()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + setUp(() { + client = MockClient(); + storage = Storage(client); + }); + test('test method listFiles()', () async { + final Map data = { + 'total': 5, + 'files': [], + }; - final response = await storage.deleteFile( - bucketId: '', - fileId: '', - ); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method getFileDownload()', () async { -final Uint8List data = Uint8List.fromList([]); + final response = await storage.listFiles( + bucketId: '', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + test('test method createFile()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + 'bucketId': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'name': 'Pink.png', + 'signature': '5d529fd02b544198ae075bd57c1762bb', + 'mimeType': 'image/png', + 'sizeOriginal': 17890, + 'sizeActual': 12345, + 'chunksTotal': 17890, + 'chunksUploaded': 17890, + 'encryption': true, + 'compression': 'gzip', + }; + + when(client.chunkedUpload( + path: argThat(isNotNull), + params: argThat(isNotNull), + paramName: argThat(isNotNull), + idParamName: argThat(isNotNull), + headers: argThat(isNotNull), + )).thenAnswer((_) async => Response(data: data)); + + final response = await storage.createFile( + bucketId: '', + fileId: '', + file: InputFile.fromPath(path: './image.png'), + ); + expect(response, isA()); + }); + test('test method getFile()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + 'bucketId': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'name': 'Pink.png', + 'signature': '5d529fd02b544198ae075bd57c1762bb', + 'mimeType': 'image/png', + 'sizeOriginal': 17890, + 'sizeActual': 12345, + 'chunksTotal': 17890, + 'chunksUploaded': 17890, + 'encryption': true, + 'compression': 'gzip', + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await storage.getFile( + bucketId: '', + fileId: '', + ); + expect(response, isA()); + }); - final response = await storage.getFileDownload( - bucketId: '', - fileId: '', - ); - expect(response, isA()); + test('test method updateFile()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + 'bucketId': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'name': 'Pink.png', + 'signature': '5d529fd02b544198ae075bd57c1762bb', + 'mimeType': 'image/png', + 'sizeOriginal': 17890, + 'sizeActual': 12345, + 'chunksTotal': 17890, + 'chunksUploaded': 17890, + 'encryption': true, + 'compression': 'gzip', + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await storage.updateFile( + bucketId: '', + fileId: '', + ); + expect(response, isA()); + }); - }); + test('test method deleteFile()', () async { + final data = ''; - test('test method getFilePreview()', () async { -final Uint8List data = Uint8List.fromList([]); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + final response = await storage.deleteFile( + bucketId: '', + fileId: '', + ); + }); + test('test method getFileDownload()', () async { + final Uint8List data = Uint8List.fromList([]); - final response = await storage.getFilePreview( - bucketId: '', - fileId: '', - ); - expect(response, isA()); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await storage.getFileDownload( + bucketId: '', + fileId: '', + ); + expect(response, isA()); + }); - test('test method getFileView()', () async { -final Uint8List data = Uint8List.fromList([]); + test('test method getFilePreview()', () async { + final Uint8List data = Uint8List.fromList([]); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await storage.getFilePreview( + bucketId: '', + fileId: '', + ); + expect(response, isA()); + }); - final response = await storage.getFileView( - bucketId: '', - fileId: '', - ); - expect(response, isA()); + test('test method getFileView()', () async { + final Uint8List data = Uint8List.fromList([]); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await storage.getFileView( + bucketId: '', + fileId: '', + ); + expect(response, isA()); }); + }); } diff --git a/test/services/tables_db_test.dart b/test/services/tables_db_test.dart index 5219d2bf..f318cad2 100644 --- a/test/services/tables_db_test.dart +++ b/test/services/tables_db_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,337 +40,297 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('TablesDB test', () { - late MockClient client; - late TablesDB tablesDB; - - setUp(() { - client = MockClient(); - tablesDB = TablesDB(client); - }); - - test('test method listTransactions()', () async { - - final Map data = { - 'total': 5, - 'transactions': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.listTransactions( - ); - expect(response, isA()); - - }); - - test('test method createTransaction()', () async { - - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.createTransaction( - ); - expect(response, isA()); - - }); - - test('test method getTransaction()', () async { - - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.getTransaction( - transactionId: '', - ); - expect(response, isA()); - - }); - - test('test method updateTransaction()', () async { - - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.updateTransaction( - transactionId: '', - ); - expect(response, isA()); - - }); - - test('test method deleteTransaction()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.deleteTransaction( - transactionId: '', - ); - }); - - test('test method createOperations()', () async { - - final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', - 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00',}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.createOperations( - transactionId: '', - ); - expect(response, isA()); - - }); - - test('test method listRows()', () async { - - final Map data = { - 'total': 5, - 'rows': [],}; - + group('TablesDB test', () { + late MockClient client; + late TablesDB tablesDB; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.listRows( - databaseId: '', - tableId: '', - ); - expect(response, isA()); - - }); - - test('test method createRow()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.createRow( - databaseId: '', - tableId: '', - rowId: '', - data: {}, - ); - expect(response, isA()); - - }); - - test('test method getRow()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.getRow( - databaseId: '', - tableId: '', - rowId: '', - ); - expect(response, isA()); - - }); - - test('test method upsertRow()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.upsertRow( - databaseId: '', - tableId: '', - rowId: '', - ); - expect(response, isA()); - - }); - - test('test method updateRow()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await tablesDB.updateRow( - databaseId: '', - tableId: '', - rowId: '', - ); - expect(response, isA()); - - }); + setUp(() { + client = MockClient(); + tablesDB = TablesDB(client); + }); - test('test method deleteRow()', () async { + test('test method listTransactions()', () async { + final Map data = { + 'total': 5, + 'transactions': [], + }; - final data = ''; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + final response = await tablesDB.listTransactions(); + expect(response, isA()); + }); + test('test method createTransaction()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.createTransaction(); + expect(response, isA()); + }); - final response = await tablesDB.deleteRow( - databaseId: '', - tableId: '', - rowId: '', - ); - }); + test('test method getTransaction()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.getTransaction( + transactionId: '', + ); + expect(response, isA()); + }); - test('test method decrementRowColumn()', () async { + test('test method updateTransaction()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.updateTransaction( + transactionId: '', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; + test('test method deleteTransaction()', () async { + final data = ''; + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + final response = await tablesDB.deleteTransaction( + transactionId: '', + ); + }); + test('test method createOperations()', () async { + final Map data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'status': 'pending', + 'operations': 5, + 'expiresAt': '2020-10-15T06:38:00.000+00:00', + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.createOperations( + transactionId: '', + ); + expect(response, isA()); + }); - final response = await tablesDB.decrementRowColumn( - databaseId: '', - tableId: '', - rowId: '', - column: '', - ); - expect(response, isA()); + test('test method listRows()', () async { + final Map data = { + 'total': 5, + 'rows': [], + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.listRows( + databaseId: '', + tableId: '', + ); + expect(response, isA()); + }); - }); + test('test method createRow()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.createRow( + databaseId: '', + tableId: '', + rowId: '', + data: {}, + ); + expect(response, isA()); + }); - test('test method incrementRowColumn()', () async { + test('test method getRow()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.getRow( + databaseId: '', + tableId: '', + rowId: '', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - '\$permissions': [],}; + test('test method upsertRow()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.upsertRow( + databaseId: '', + tableId: '', + rowId: '', + ); + expect(response, isA()); + }); + test('test method updateRow()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.updateRow( + databaseId: '', + tableId: '', + rowId: '', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + test('test method deleteRow()', () async { + final data = ''; + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - final response = await tablesDB.incrementRowColumn( - databaseId: '', - tableId: '', - rowId: '', - column: '', - ); - expect(response, isA()); + final response = await tablesDB.deleteRow( + databaseId: '', + tableId: '', + rowId: '', + ); + }); - }); + test('test method decrementRowColumn()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.decrementRowColumn( + databaseId: '', + tableId: '', + rowId: '', + column: '', + ); + expect(response, isA()); + }); + test('test method incrementRowColumn()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$sequence': '1', + '\$tableId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await tablesDB.incrementRowColumn( + databaseId: '', + tableId: '', + rowId: '', + column: '', + ); + expect(response, isA()); }); + }); } diff --git a/test/services/teams_test.dart b/test/services/teams_test.dart index ea72a432..83f2667b 100644 --- a/test/services/teams_test.dart +++ b/test/services/teams_test.dart @@ -24,12 +24,11 @@ class MockClient extends Mock implements Client { @override Future webAuth( - Uri? url, - { - String? callbackUrlScheme, - } - ) async { - return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -41,326 +40,288 @@ class MockClient extends Mock implements Client { Map? headers, Function(UploadProgress)? onProgress, }) async { - return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + return super.noSuchMethod( + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } void main() { - group('Teams test', () { - late MockClient client; - late Teams teams; - - setUp(() { - client = MockClient(); - teams = Teams(client); - }); - - test('test method list()', () async { - - final Map data = { - 'total': 5, - 'teams': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.list( - ); - expect(response, isA()); - - }); - - test('test method create()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'VIP', - 'total': 7, - 'prefs': {},}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.create( - teamId: '', - name: '', - ); - expect(response, isA()); - - }); - - test('test method get()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'VIP', - 'total': 7, - 'prefs': {},}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.get( - teamId: '', - ); - expect(response, isA()); - - }); - - test('test method updateName()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'VIP', - 'total': 7, - 'prefs': {},}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.updateName( - teamId: '', - name: '', - ); - expect(response, isA()); - - }); - - test('test method delete()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.delete( - teamId: '', - ); - }); - - test('test method listMemberships()', () async { - - final Map data = { - 'total': 5, - 'memberships': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + group('Teams test', () { + late MockClient client; + late Teams teams; + setUp(() { + client = MockClient(); + teams = Teams(client); + }); - final response = await teams.listMemberships( - teamId: '', - ); - expect(response, isA()); - - }); - - test('test method createMembership()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [],}; - - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.createMembership( - teamId: '', - roles: [], - ); - expect(response, isA()); - - }); - - test('test method getMembership()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.getMembership( - teamId: '', - membershipId: '', - ); - expect(response, isA()); - - }); - - test('test method updateMembership()', () async { - - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [],}; - - - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.updateMembership( - teamId: '', - membershipId: '', - roles: [], - ); - expect(response, isA()); - - }); - - test('test method deleteMembership()', () async { - - final data = ''; - - when(client.call( - HttpMethod.delete, - )).thenAnswer((_) async => Response(data: data)); + test('test method list()', () async { + final Map data = { + 'total': 5, + 'teams': [], + }; + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await teams.deleteMembership( - teamId: '', - membershipId: '', - ); - }); + final response = await teams.list(); + expect(response, isA()); + }); - test('test method updateMembershipStatus()', () async { + test('test method create()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'VIP', + 'total': 7, + 'prefs': {}, + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await teams.create( + teamId: '', + name: '', + ); + expect(response, isA()); + }); - final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', - 'confirm': true, - 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', - 'roles': [],}; + test('test method get()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'VIP', + 'total': 7, + 'prefs': {}, + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await teams.get( + teamId: '', + ); + expect(response, isA()); + }); + test('test method updateName()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'VIP', + 'total': 7, + 'prefs': {}, + }; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + final response = await teams.updateName( + teamId: '', + name: '', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + test('test method delete()', () async { + final data = ''; + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - final response = await teams.updateMembershipStatus( - teamId: '', - membershipId: '', - userId: '', - secret: '', - ); - expect(response, isA()); + final response = await teams.delete( + teamId: '', + ); + }); - }); + test('test method listMemberships()', () async { + final Map data = { + 'total': 5, + 'memberships': [], + }; - test('test method getPrefs()', () async { + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final Map data = {}; + final response = await teams.listMemberships( + teamId: '', + ); + expect(response, isA()); + }); + test('test method createMembership()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'userPhone': '+1 555 555 5555', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'roles': [], + }; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + final response = await teams.createMembership( + teamId: '', + roles: [], + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + test('test method getMembership()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'userPhone': '+1 555 555 5555', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'roles': [], + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await teams.getMembership( + teamId: '', + membershipId: '', + ); + expect(response, isA()); + }); + test('test method updateMembership()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'userPhone': '+1 555 555 5555', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'roles': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await teams.updateMembership( + teamId: '', + membershipId: '', + roles: [], + ); + expect(response, isA()); + }); - final response = await teams.getPrefs( - teamId: '', - ); - expect(response, isA()); + test('test method deleteMembership()', () async { + final data = ''; - }); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - test('test method updatePrefs()', () async { + final response = await teams.deleteMembership( + teamId: '', + membershipId: '', + ); + }); - final Map data = {}; + test('test method updateMembershipStatus()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'userPhone': '+1 555 555 5555', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'mfa': true, + 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'roles': [], + }; + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + final response = await teams.updateMembershipStatus( + teamId: '', + membershipId: '', + userId: '', + secret: '', + ); + expect(response, isA()); + }); + test('test method getPrefs()', () async { + final Map data = {}; - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await teams.getPrefs( + teamId: '', + ); + expect(response, isA()); + }); - final response = await teams.updatePrefs( - teamId: '', - prefs: {}, - ); - expect(response, isA()); + test('test method updatePrefs()', () async { + final Map data = {}; - }); + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + final response = await teams.updatePrefs( + teamId: '', + prefs: {}, + ); + expect(response, isA()); }); + }); } diff --git a/test/src/models/algo_argon2_test.dart b/test/src/models/algo_argon2_test.dart index 15e85f5a..261daa46 100644 --- a/test/src/models/algo_argon2_test.dart +++ b/test/src/models/algo_argon2_test.dart @@ -14,10 +14,10 @@ void main() { final map = model.toMap(); final result = AlgoArgon2.fromMap(map); - expect(result.type, 'argon2'); - expect(result.memoryCost, 65536); - expect(result.timeCost, 4); - expect(result.threads, 3); - }); + expect(result.type, 'argon2'); + expect(result.memoryCost, 65536); + expect(result.timeCost, 4); + expect(result.threads, 3); + }); }); } diff --git a/test/src/models/algo_bcrypt_test.dart b/test/src/models/algo_bcrypt_test.dart index 87a3ca3c..3da36624 100644 --- a/test/src/models/algo_bcrypt_test.dart +++ b/test/src/models/algo_bcrypt_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = AlgoBcrypt.fromMap(map); - expect(result.type, 'bcrypt'); - }); + expect(result.type, 'bcrypt'); + }); }); } diff --git a/test/src/models/algo_md5_test.dart b/test/src/models/algo_md5_test.dart index 3b842e6c..e58fa5b5 100644 --- a/test/src/models/algo_md5_test.dart +++ b/test/src/models/algo_md5_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = AlgoMd5.fromMap(map); - expect(result.type, 'md5'); - }); + expect(result.type, 'md5'); + }); }); } diff --git a/test/src/models/algo_phpass_test.dart b/test/src/models/algo_phpass_test.dart index 49b1e22c..3bcbb488 100644 --- a/test/src/models/algo_phpass_test.dart +++ b/test/src/models/algo_phpass_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = AlgoPhpass.fromMap(map); - expect(result.type, 'phpass'); - }); + expect(result.type, 'phpass'); + }); }); } diff --git a/test/src/models/algo_scrypt_modified_test.dart b/test/src/models/algo_scrypt_modified_test.dart index dd7fa8c3..b2084927 100644 --- a/test/src/models/algo_scrypt_modified_test.dart +++ b/test/src/models/algo_scrypt_modified_test.dart @@ -8,16 +8,18 @@ void main() { type: 'scryptMod', salt: 'UxLMreBr6tYyjQ==', saltSeparator: 'Bw==', - signerKey: 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ==', + signerKey: + 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ==', ); final map = model.toMap(); final result = AlgoScryptModified.fromMap(map); - expect(result.type, 'scryptMod'); - expect(result.salt, 'UxLMreBr6tYyjQ=='); - expect(result.saltSeparator, 'Bw=='); - expect(result.signerKey, 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ=='); - }); + expect(result.type, 'scryptMod'); + expect(result.salt, 'UxLMreBr6tYyjQ=='); + expect(result.saltSeparator, 'Bw=='); + expect(result.signerKey, + 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ=='); + }); }); } diff --git a/test/src/models/algo_scrypt_test.dart b/test/src/models/algo_scrypt_test.dart index c7d9cdbf..8c131568 100644 --- a/test/src/models/algo_scrypt_test.dart +++ b/test/src/models/algo_scrypt_test.dart @@ -15,11 +15,11 @@ void main() { final map = model.toMap(); final result = AlgoScrypt.fromMap(map); - expect(result.type, 'scrypt'); - expect(result.costCpu, 8); - expect(result.costMemory, 14); - expect(result.costParallel, 1); - expect(result.length, 64); - }); + expect(result.type, 'scrypt'); + expect(result.costCpu, 8); + expect(result.costMemory, 14); + expect(result.costParallel, 1); + expect(result.length, 64); + }); }); } diff --git a/test/src/models/algo_sha_test.dart b/test/src/models/algo_sha_test.dart index ae58b57e..d080569c 100644 --- a/test/src/models/algo_sha_test.dart +++ b/test/src/models/algo_sha_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = AlgoSha.fromMap(map); - expect(result.type, 'sha'); - }); + expect(result.type, 'sha'); + }); }); } diff --git a/test/src/models/continent_list_test.dart b/test/src/models/continent_list_test.dart index 8de695b0..e71dcae1 100644 --- a/test/src/models/continent_list_test.dart +++ b/test/src/models/continent_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = ContinentList.fromMap(map); - expect(result.total, 5); - expect(result.continents, []); - }); + expect(result.total, 5); + expect(result.continents, []); + }); }); } diff --git a/test/src/models/continent_test.dart b/test/src/models/continent_test.dart index d5242a4e..85e559f5 100644 --- a/test/src/models/continent_test.dart +++ b/test/src/models/continent_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = Continent.fromMap(map); - expect(result.name, 'Europe'); - expect(result.code, 'EU'); - }); + expect(result.name, 'Europe'); + expect(result.code, 'EU'); + }); }); } diff --git a/test/src/models/country_list_test.dart b/test/src/models/country_list_test.dart index 869f5db6..6df5c584 100644 --- a/test/src/models/country_list_test.dart +++ b/test/src/models/country_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = CountryList.fromMap(map); - expect(result.total, 5); - expect(result.countries, []); - }); + expect(result.total, 5); + expect(result.countries, []); + }); }); } diff --git a/test/src/models/country_test.dart b/test/src/models/country_test.dart index bc66ab7b..d5404a7f 100644 --- a/test/src/models/country_test.dart +++ b/test/src/models/country_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = Country.fromMap(map); - expect(result.name, 'United States'); - expect(result.code, 'US'); - }); + expect(result.name, 'United States'); + expect(result.code, 'US'); + }); }); } diff --git a/test/src/models/currency_list_test.dart b/test/src/models/currency_list_test.dart index 09da675c..d7410db8 100644 --- a/test/src/models/currency_list_test.dart +++ b/test/src/models/currency_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = CurrencyList.fromMap(map); - expect(result.total, 5); - expect(result.currencies, []); - }); + expect(result.total, 5); + expect(result.currencies, []); + }); }); } diff --git a/test/src/models/currency_test.dart b/test/src/models/currency_test.dart index 29890008..00e046c7 100644 --- a/test/src/models/currency_test.dart +++ b/test/src/models/currency_test.dart @@ -17,13 +17,13 @@ void main() { final map = model.toMap(); final result = Currency.fromMap(map); - expect(result.symbol, '\$'); - expect(result.name, 'US dollar'); - expect(result.symbolNative, '\$'); - expect(result.decimalDigits, 2); - expect(result.rounding, 0); - expect(result.code, 'USD'); - expect(result.namePlural, 'US dollars'); - }); + expect(result.symbol, '\$'); + expect(result.name, 'US dollar'); + expect(result.symbolNative, '\$'); + expect(result.decimalDigits, 2); + expect(result.rounding, 0); + expect(result.code, 'USD'); + expect(result.namePlural, 'US dollars'); + }); }); } diff --git a/test/src/models/document_list_test.dart b/test/src/models/document_list_test.dart index f1a5b3cc..217d37e8 100644 --- a/test/src/models/document_list_test.dart +++ b/test/src/models/document_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = DocumentList.fromMap(map); - expect(result.total, 5); - expect(result.documents, []); - }); + expect(result.total, 5); + expect(result.documents, []); + }); }); } diff --git a/test/src/models/document_test.dart b/test/src/models/document_test.dart index 6c1fbb77..397b5fab 100644 --- a/test/src/models/document_test.dart +++ b/test/src/models/document_test.dart @@ -18,13 +18,13 @@ void main() { final map = model.toMap(); final result = Document.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$sequence, '1'); - expect(result.$collectionId, '5e5ea5c15117e'); - expect(result.$databaseId, '5e5ea5c15117e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$sequence, '1'); + expect(result.$collectionId, '5e5ea5c15117e'); + expect(result.$databaseId, '5e5ea5c15117e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + }); }); } diff --git a/test/src/models/execution_list_test.dart b/test/src/models/execution_list_test.dart index fe74af58..a3305e55 100644 --- a/test/src/models/execution_list_test.dart +++ b/test/src/models/execution_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = ExecutionList.fromMap(map); - expect(result.total, 5); - expect(result.executions, []); - }); + expect(result.total, 5); + expect(result.executions, []); + }); }); } diff --git a/test/src/models/execution_test.dart b/test/src/models/execution_test.dart index 6d9bf33c..80ef508a 100644 --- a/test/src/models/execution_test.dart +++ b/test/src/models/execution_test.dart @@ -28,23 +28,23 @@ void main() { final map = model.toMap(); final result = Execution.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - expect(result.functionId, '5e5ea6g16897e'); - expect(result.deploymentId, '5e5ea5c16897e'); - expect(result.trigger, ExecutionTrigger.http); - expect(result.status, ExecutionStatus.waiting); - expect(result.requestMethod, 'GET'); - expect(result.requestPath, '/articles?id=5'); - expect(result.requestHeaders, []); - expect(result.responseStatusCode, 200); - expect(result.responseBody, ''); - expect(result.responseHeaders, []); - expect(result.logs, ''); - expect(result.errors, ''); - expect(result.duration, 0.4); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + expect(result.functionId, '5e5ea6g16897e'); + expect(result.deploymentId, '5e5ea5c16897e'); + expect(result.trigger, ExecutionTrigger.http); + expect(result.status, ExecutionStatus.waiting); + expect(result.requestMethod, 'GET'); + expect(result.requestPath, '/articles?id=5'); + expect(result.requestHeaders, []); + expect(result.responseStatusCode, 200); + expect(result.responseBody, ''); + expect(result.responseHeaders, []); + expect(result.logs, ''); + expect(result.errors, ''); + expect(result.duration, 0.4); + }); }); } diff --git a/test/src/models/file_list_test.dart b/test/src/models/file_list_test.dart index d8e6c95c..8e02f65e 100644 --- a/test/src/models/file_list_test.dart +++ b/test/src/models/file_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = FileList.fromMap(map); - expect(result.total, 5); - expect(result.files, []); - }); + expect(result.total, 5); + expect(result.files, []); + }); }); } diff --git a/test/src/models/file_test.dart b/test/src/models/file_test.dart index 8a734a08..7f132646 100644 --- a/test/src/models/file_test.dart +++ b/test/src/models/file_test.dart @@ -24,20 +24,20 @@ void main() { final map = model.toMap(); final result = File.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.bucketId, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - expect(result.name, 'Pink.png'); - expect(result.signature, '5d529fd02b544198ae075bd57c1762bb'); - expect(result.mimeType, 'image/png'); - expect(result.sizeOriginal, 17890); - expect(result.sizeActual, 12345); - expect(result.chunksTotal, 17890); - expect(result.chunksUploaded, 17890); - expect(result.encryption, true); - expect(result.compression, 'gzip'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.bucketId, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + expect(result.name, 'Pink.png'); + expect(result.signature, '5d529fd02b544198ae075bd57c1762bb'); + expect(result.mimeType, 'image/png'); + expect(result.sizeOriginal, 17890); + expect(result.sizeActual, 12345); + expect(result.chunksTotal, 17890); + expect(result.chunksUploaded, 17890); + expect(result.encryption, true); + expect(result.compression, 'gzip'); + }); }); } diff --git a/test/src/models/headers_test.dart b/test/src/models/headers_test.dart index 489891d4..9252b469 100644 --- a/test/src/models/headers_test.dart +++ b/test/src/models/headers_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = Headers.fromMap(map); - expect(result.name, 'Content-Type'); - expect(result.value, 'application/json'); - }); + expect(result.name, 'Content-Type'); + expect(result.value, 'application/json'); + }); }); } diff --git a/test/src/models/identity_list_test.dart b/test/src/models/identity_list_test.dart index 65f562a7..8c35afec 100644 --- a/test/src/models/identity_list_test.dart +++ b/test/src/models/identity_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = IdentityList.fromMap(map); - expect(result.total, 5); - expect(result.identities, []); - }); + expect(result.total, 5); + expect(result.identities, []); + }); }); } diff --git a/test/src/models/identity_test.dart b/test/src/models/identity_test.dart index 708c8c60..525af4ea 100644 --- a/test/src/models/identity_test.dart +++ b/test/src/models/identity_test.dart @@ -20,16 +20,16 @@ void main() { final map = model.toMap(); final result = Identity.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5bb8c16897e'); - expect(result.provider, 'email'); - expect(result.providerUid, '5e5bb8c16897e'); - expect(result.providerEmail, 'user@example.com'); - expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); - expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5bb8c16897e'); + expect(result.provider, 'email'); + expect(result.providerUid, '5e5bb8c16897e'); + expect(result.providerEmail, 'user@example.com'); + expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); + expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + }); }); } diff --git a/test/src/models/jwt_test.dart b/test/src/models/jwt_test.dart index e616a956..93376af1 100644 --- a/test/src/models/jwt_test.dart +++ b/test/src/models/jwt_test.dart @@ -5,13 +5,15 @@ void main() { group('Jwt', () { test('model', () { final model = Jwt( - jwt: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', + jwt: + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', ); final map = model.toMap(); final result = Jwt.fromMap(map); - expect(result.jwt, 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'); - }); + expect(result.jwt, + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'); + }); }); } diff --git a/test/src/models/language_list_test.dart b/test/src/models/language_list_test.dart index 94c1e33f..a07c0b5f 100644 --- a/test/src/models/language_list_test.dart +++ b/test/src/models/language_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = LanguageList.fromMap(map); - expect(result.total, 5); - expect(result.languages, []); - }); + expect(result.total, 5); + expect(result.languages, []); + }); }); } diff --git a/test/src/models/language_test.dart b/test/src/models/language_test.dart index d4087d5e..4a6c96c1 100644 --- a/test/src/models/language_test.dart +++ b/test/src/models/language_test.dart @@ -13,9 +13,9 @@ void main() { final map = model.toMap(); final result = Language.fromMap(map); - expect(result.name, 'Italian'); - expect(result.code, 'it'); - expect(result.nativeName, 'Italiano'); - }); + expect(result.name, 'Italian'); + expect(result.code, 'it'); + expect(result.nativeName, 'Italiano'); + }); }); } diff --git a/test/src/models/locale_code_list_test.dart b/test/src/models/locale_code_list_test.dart index b6de5137..65b44ad1 100644 --- a/test/src/models/locale_code_list_test.dart +++ b/test/src/models/locale_code_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = LocaleCodeList.fromMap(map); - expect(result.total, 5); - expect(result.localeCodes, []); - }); + expect(result.total, 5); + expect(result.localeCodes, []); + }); }); } diff --git a/test/src/models/locale_code_test.dart b/test/src/models/locale_code_test.dart index f0fcdbce..88cf157b 100644 --- a/test/src/models/locale_code_test.dart +++ b/test/src/models/locale_code_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = LocaleCode.fromMap(map); - expect(result.code, 'en-us'); - expect(result.name, 'US'); - }); + expect(result.code, 'en-us'); + expect(result.name, 'US'); + }); }); } diff --git a/test/src/models/locale_test.dart b/test/src/models/locale_test.dart index 72102045..49cb1fc9 100644 --- a/test/src/models/locale_test.dart +++ b/test/src/models/locale_test.dart @@ -17,13 +17,13 @@ void main() { final map = model.toMap(); final result = Locale.fromMap(map); - expect(result.ip, '127.0.0.1'); - expect(result.countryCode, 'US'); - expect(result.country, 'United States'); - expect(result.continentCode, 'NA'); - expect(result.continent, 'North America'); - expect(result.eu, true); - expect(result.currency, 'USD'); - }); + expect(result.ip, '127.0.0.1'); + expect(result.countryCode, 'US'); + expect(result.country, 'United States'); + expect(result.continentCode, 'NA'); + expect(result.continent, 'North America'); + expect(result.eu, true); + expect(result.currency, 'USD'); + }); }); } diff --git a/test/src/models/log_list_test.dart b/test/src/models/log_list_test.dart index 84c560c8..b07ca8ee 100644 --- a/test/src/models/log_list_test.dart +++ b/test/src/models/log_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = LogList.fromMap(map); - expect(result.total, 5); - expect(result.logs, []); - }); + expect(result.total, 5); + expect(result.logs, []); + }); }); } diff --git a/test/src/models/log_test.dart b/test/src/models/log_test.dart index 1b463633..c8211d3b 100644 --- a/test/src/models/log_test.dart +++ b/test/src/models/log_test.dart @@ -32,28 +32,28 @@ void main() { final map = model.toMap(); final result = Log.fromMap(map); - expect(result.event, 'account.sessions.create'); - expect(result.userId, '610fc2f985ee0'); - expect(result.userEmail, 'john@appwrite.io'); - expect(result.userName, 'John Doe'); - expect(result.mode, 'admin'); - expect(result.userType, 'user'); - expect(result.ip, '127.0.0.1'); - expect(result.time, '2020-10-15T06:38:00.000+00:00'); - expect(result.osCode, 'Mac'); - expect(result.osName, 'Mac'); - expect(result.osVersion, 'Mac'); - expect(result.clientType, 'browser'); - expect(result.clientCode, 'CM'); - expect(result.clientName, 'Chrome Mobile iOS'); - expect(result.clientVersion, '84.0'); - expect(result.clientEngine, 'WebKit'); - expect(result.clientEngineVersion, '605.1.15'); - expect(result.deviceName, 'smartphone'); - expect(result.deviceBrand, 'Google'); - expect(result.deviceModel, 'Nexus 5'); - expect(result.countryCode, 'US'); - expect(result.countryName, 'United States'); - }); + expect(result.event, 'account.sessions.create'); + expect(result.userId, '610fc2f985ee0'); + expect(result.userEmail, 'john@appwrite.io'); + expect(result.userName, 'John Doe'); + expect(result.mode, 'admin'); + expect(result.userType, 'user'); + expect(result.ip, '127.0.0.1'); + expect(result.time, '2020-10-15T06:38:00.000+00:00'); + expect(result.osCode, 'Mac'); + expect(result.osName, 'Mac'); + expect(result.osVersion, 'Mac'); + expect(result.clientType, 'browser'); + expect(result.clientCode, 'CM'); + expect(result.clientName, 'Chrome Mobile iOS'); + expect(result.clientVersion, '84.0'); + expect(result.clientEngine, 'WebKit'); + expect(result.clientEngineVersion, '605.1.15'); + expect(result.deviceName, 'smartphone'); + expect(result.deviceBrand, 'Google'); + expect(result.deviceModel, 'Nexus 5'); + expect(result.countryCode, 'US'); + expect(result.countryName, 'United States'); + }); }); } diff --git a/test/src/models/membership_list_test.dart b/test/src/models/membership_list_test.dart index bb1f0946..4f30c48e 100644 --- a/test/src/models/membership_list_test.dart +++ b/test/src/models/membership_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = MembershipList.fromMap(map); - expect(result.total, 5); - expect(result.memberships, []); - }); + expect(result.total, 5); + expect(result.memberships, []); + }); }); } diff --git a/test/src/models/membership_test.dart b/test/src/models/membership_test.dart index ab136c24..b2b8bd3d 100644 --- a/test/src/models/membership_test.dart +++ b/test/src/models/membership_test.dart @@ -25,21 +25,21 @@ void main() { final map = model.toMap(); final result = Membership.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5ea5c16897e'); - expect(result.userName, 'John Doe'); - expect(result.userEmail, 'john@appwrite.io'); - expect(result.userPhone, '+1 555 555 5555'); - expect(result.teamId, '5e5ea5c16897e'); - expect(result.teamName, 'VIP'); - expect(result.invited, '2020-10-15T06:38:00.000+00:00'); - expect(result.joined, '2020-10-15T06:38:00.000+00:00'); - expect(result.confirm, true); - expect(result.mfa, true); - expect(result.userAccessedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.roles, []); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5ea5c16897e'); + expect(result.userName, 'John Doe'); + expect(result.userEmail, 'john@appwrite.io'); + expect(result.userPhone, '+1 555 555 5555'); + expect(result.teamId, '5e5ea5c16897e'); + expect(result.teamName, 'VIP'); + expect(result.invited, '2020-10-15T06:38:00.000+00:00'); + expect(result.joined, '2020-10-15T06:38:00.000+00:00'); + expect(result.confirm, true); + expect(result.mfa, true); + expect(result.userAccessedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.roles, []); + }); }); } diff --git a/test/src/models/mfa_challenge_test.dart b/test/src/models/mfa_challenge_test.dart index 9410baa3..5d3febca 100644 --- a/test/src/models/mfa_challenge_test.dart +++ b/test/src/models/mfa_challenge_test.dart @@ -14,10 +14,10 @@ void main() { final map = model.toMap(); final result = MfaChallenge.fromMap(map); - expect(result.$id, 'bb8ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5ea5c168bb8'); - expect(result.expire, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, 'bb8ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5ea5c168bb8'); + expect(result.expire, '2020-10-15T06:38:00.000+00:00'); + }); }); } diff --git a/test/src/models/mfa_factors_test.dart b/test/src/models/mfa_factors_test.dart index ed6467d3..64cc55e4 100644 --- a/test/src/models/mfa_factors_test.dart +++ b/test/src/models/mfa_factors_test.dart @@ -14,10 +14,10 @@ void main() { final map = model.toMap(); final result = MfaFactors.fromMap(map); - expect(result.totp, true); - expect(result.phone, true); - expect(result.email, true); - expect(result.recoveryCode, true); - }); + expect(result.totp, true); + expect(result.phone, true); + expect(result.email, true); + expect(result.recoveryCode, true); + }); }); } diff --git a/test/src/models/mfa_recovery_codes_test.dart b/test/src/models/mfa_recovery_codes_test.dart index fa097a49..500913c8 100644 --- a/test/src/models/mfa_recovery_codes_test.dart +++ b/test/src/models/mfa_recovery_codes_test.dart @@ -11,7 +11,7 @@ void main() { final map = model.toMap(); final result = MfaRecoveryCodes.fromMap(map); - expect(result.recoveryCodes, []); - }); + expect(result.recoveryCodes, []); + }); }); } diff --git a/test/src/models/mfa_type_test.dart b/test/src/models/mfa_type_test.dart index 3f45d288..81657394 100644 --- a/test/src/models/mfa_type_test.dart +++ b/test/src/models/mfa_type_test.dart @@ -6,14 +6,16 @@ void main() { test('model', () { final model = MfaType( secret: '[SHARED_SECRET]', - uri: 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', + uri: + 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', ); final map = model.toMap(); final result = MfaType.fromMap(map); - expect(result.secret, '[SHARED_SECRET]'); - expect(result.uri, 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite'); - }); + expect(result.secret, '[SHARED_SECRET]'); + expect(result.uri, + 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite'); + }); }); } diff --git a/test/src/models/phone_list_test.dart b/test/src/models/phone_list_test.dart index 6ca46a63..bf22a5c7 100644 --- a/test/src/models/phone_list_test.dart +++ b/test/src/models/phone_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = PhoneList.fromMap(map); - expect(result.total, 5); - expect(result.phones, []); - }); + expect(result.total, 5); + expect(result.phones, []); + }); }); } diff --git a/test/src/models/phone_test.dart b/test/src/models/phone_test.dart index d0e5333b..f70db0e3 100644 --- a/test/src/models/phone_test.dart +++ b/test/src/models/phone_test.dart @@ -13,9 +13,9 @@ void main() { final map = model.toMap(); final result = Phone.fromMap(map); - expect(result.code, '+1'); - expect(result.countryCode, 'US'); - expect(result.countryName, 'United States'); - }); + expect(result.code, '+1'); + expect(result.countryCode, 'US'); + expect(result.countryName, 'United States'); + }); }); } diff --git a/test/src/models/preferences_test.dart b/test/src/models/preferences_test.dart index acde349c..9db30b03 100644 --- a/test/src/models/preferences_test.dart +++ b/test/src/models/preferences_test.dart @@ -10,7 +10,6 @@ void main() { final map = model.toMap(); final result = Preferences.fromMap(map); - }); }); } diff --git a/test/src/models/presence_list_test.dart b/test/src/models/presence_list_test.dart index 57a86348..46f69af6 100644 --- a/test/src/models/presence_list_test.dart +++ b/test/src/models/presence_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = PresenceList.fromMap(map); - expect(result.total, 5); - expect(result.presences, []); - }); + expect(result.total, 5); + expect(result.presences, []); + }); }); } diff --git a/test/src/models/presence_test.dart b/test/src/models/presence_test.dart index edcfe5f5..ef2ebe31 100644 --- a/test/src/models/presence_test.dart +++ b/test/src/models/presence_test.dart @@ -16,12 +16,12 @@ void main() { final map = model.toMap(); final result = Presence.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - expect(result.userId, '674af8f3e12a5f9ac0be'); - expect(result.source, 'HTTP'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + expect(result.userId, '674af8f3e12a5f9ac0be'); + expect(result.source, 'HTTP'); + }); }); } diff --git a/test/src/models/row_list_test.dart b/test/src/models/row_list_test.dart index d4900dd4..12693926 100644 --- a/test/src/models/row_list_test.dart +++ b/test/src/models/row_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = RowList.fromMap(map); - expect(result.total, 5); - expect(result.rows, []); - }); + expect(result.total, 5); + expect(result.rows, []); + }); }); } diff --git a/test/src/models/row_test.dart b/test/src/models/row_test.dart index 4e72a449..564bf303 100644 --- a/test/src/models/row_test.dart +++ b/test/src/models/row_test.dart @@ -18,13 +18,13 @@ void main() { final map = model.toMap(); final result = Row.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$sequence, '1'); - expect(result.$tableId, '5e5ea5c15117e'); - expect(result.$databaseId, '5e5ea5c15117e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$permissions, []); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$sequence, '1'); + expect(result.$tableId, '5e5ea5c15117e'); + expect(result.$databaseId, '5e5ea5c15117e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + }); }); } diff --git a/test/src/models/session_list_test.dart b/test/src/models/session_list_test.dart index eaab249e..708e0583 100644 --- a/test/src/models/session_list_test.dart +++ b/test/src/models/session_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = SessionList.fromMap(map); - expect(result.total, 5); - expect(result.sessions, []); - }); + expect(result.total, 5); + expect(result.sessions, []); + }); }); } diff --git a/test/src/models/session_test.dart b/test/src/models/session_test.dart index 0177e477..689e6048 100644 --- a/test/src/models/session_test.dart +++ b/test/src/models/session_test.dart @@ -39,35 +39,35 @@ void main() { final map = model.toMap(); final result = Session.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5bb8c16897e'); - expect(result.expire, '2020-10-15T06:38:00.000+00:00'); - expect(result.provider, 'email'); - expect(result.providerUid, 'user@example.com'); - expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); - expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - expect(result.ip, '127.0.0.1'); - expect(result.osCode, 'Mac'); - expect(result.osName, 'Mac'); - expect(result.osVersion, 'Mac'); - expect(result.clientType, 'browser'); - expect(result.clientCode, 'CM'); - expect(result.clientName, 'Chrome Mobile iOS'); - expect(result.clientVersion, '84.0'); - expect(result.clientEngine, 'WebKit'); - expect(result.clientEngineVersion, '605.1.15'); - expect(result.deviceName, 'smartphone'); - expect(result.deviceBrand, 'Google'); - expect(result.deviceModel, 'Nexus 5'); - expect(result.countryCode, 'US'); - expect(result.countryName, 'United States'); - expect(result.current, true); - expect(result.factors, []); - expect(result.secret, '5e5bb8c16897e'); - expect(result.mfaUpdatedAt, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5bb8c16897e'); + expect(result.expire, '2020-10-15T06:38:00.000+00:00'); + expect(result.provider, 'email'); + expect(result.providerUid, 'user@example.com'); + expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); + expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + expect(result.ip, '127.0.0.1'); + expect(result.osCode, 'Mac'); + expect(result.osName, 'Mac'); + expect(result.osVersion, 'Mac'); + expect(result.clientType, 'browser'); + expect(result.clientCode, 'CM'); + expect(result.clientName, 'Chrome Mobile iOS'); + expect(result.clientVersion, '84.0'); + expect(result.clientEngine, 'WebKit'); + expect(result.clientEngineVersion, '605.1.15'); + expect(result.deviceName, 'smartphone'); + expect(result.deviceBrand, 'Google'); + expect(result.deviceModel, 'Nexus 5'); + expect(result.countryCode, 'US'); + expect(result.countryName, 'United States'); + expect(result.current, true); + expect(result.factors, []); + expect(result.secret, '5e5bb8c16897e'); + expect(result.mfaUpdatedAt, '2020-10-15T06:38:00.000+00:00'); + }); }); } diff --git a/test/src/models/subscriber_test.dart b/test/src/models/subscriber_test.dart index 94c6a502..7445514c 100644 --- a/test/src/models/subscriber_test.dart +++ b/test/src/models/subscriber_test.dart @@ -10,15 +10,15 @@ void main() { $updatedAt: '2020-10-15T06:38:00.000+00:00', targetId: '259125845563242502', target: Target( - $id: '259125845563242502', - $createdAt: '2020-10-15T06:38:00.000+00:00', - $updatedAt: '2020-10-15T06:38:00.000+00:00', - name: 'Apple iPhone 12', - userId: '259125845563242502', - providerType: 'email', - identifier: 'token', - expired: true, - ), + $id: '259125845563242502', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Apple iPhone 12', + userId: '259125845563242502', + providerType: 'email', + identifier: 'token', + expired: true, + ), userId: '5e5ea5c16897e', userName: 'Aegon Targaryen', topicId: '259125845563242502', @@ -28,14 +28,14 @@ void main() { final map = model.toMap(); final result = Subscriber.fromMap(map); - expect(result.$id, '259125845563242502'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.targetId, '259125845563242502'); - expect(result.userId, '5e5ea5c16897e'); - expect(result.userName, 'Aegon Targaryen'); - expect(result.topicId, '259125845563242502'); - expect(result.providerType, 'email'); - }); + expect(result.$id, '259125845563242502'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.targetId, '259125845563242502'); + expect(result.userId, '5e5ea5c16897e'); + expect(result.userName, 'Aegon Targaryen'); + expect(result.topicId, '259125845563242502'); + expect(result.providerType, 'email'); + }); }); } diff --git a/test/src/models/target_test.dart b/test/src/models/target_test.dart index a49f3def..49f1e75e 100644 --- a/test/src/models/target_test.dart +++ b/test/src/models/target_test.dart @@ -18,14 +18,14 @@ void main() { final map = model.toMap(); final result = Target.fromMap(map); - expect(result.$id, '259125845563242502'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.name, 'Apple iPhone 12'); - expect(result.userId, '259125845563242502'); - expect(result.providerType, 'email'); - expect(result.identifier, 'token'); - expect(result.expired, true); - }); + expect(result.$id, '259125845563242502'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.name, 'Apple iPhone 12'); + expect(result.userId, '259125845563242502'); + expect(result.providerType, 'email'); + expect(result.identifier, 'token'); + expect(result.expired, true); + }); }); } diff --git a/test/src/models/team_list_test.dart b/test/src/models/team_list_test.dart index a19b667d..fe2f4a85 100644 --- a/test/src/models/team_list_test.dart +++ b/test/src/models/team_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = TeamList.fromMap(map); - expect(result.total, 5); - expect(result.teams, []); - }); + expect(result.total, 5); + expect(result.teams, []); + }); }); } diff --git a/test/src/models/team_test.dart b/test/src/models/team_test.dart index 43b2e45c..f652f2c1 100644 --- a/test/src/models/team_test.dart +++ b/test/src/models/team_test.dart @@ -16,11 +16,11 @@ void main() { final map = model.toMap(); final result = Team.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.name, 'VIP'); - expect(result.total, 7); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.name, 'VIP'); + expect(result.total, 7); + }); }); } diff --git a/test/src/models/token_test.dart b/test/src/models/token_test.dart index 7ee4b268..8f0957c9 100644 --- a/test/src/models/token_test.dart +++ b/test/src/models/token_test.dart @@ -16,12 +16,12 @@ void main() { final map = model.toMap(); final result = Token.fromMap(map); - expect(result.$id, 'bb8ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5ea5c168bb8'); - expect(result.secret, ''); - expect(result.expire, '2020-10-15T06:38:00.000+00:00'); - expect(result.phrase, 'Golden Fox'); - }); + expect(result.$id, 'bb8ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5ea5c168bb8'); + expect(result.secret, ''); + expect(result.expire, '2020-10-15T06:38:00.000+00:00'); + expect(result.phrase, 'Golden Fox'); + }); }); } diff --git a/test/src/models/transaction_list_test.dart b/test/src/models/transaction_list_test.dart index 68023e18..a524ef71 100644 --- a/test/src/models/transaction_list_test.dart +++ b/test/src/models/transaction_list_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = TransactionList.fromMap(map); - expect(result.total, 5); - expect(result.transactions, []); - }); + expect(result.total, 5); + expect(result.transactions, []); + }); }); } diff --git a/test/src/models/transaction_test.dart b/test/src/models/transaction_test.dart index 723ebac2..0169427f 100644 --- a/test/src/models/transaction_test.dart +++ b/test/src/models/transaction_test.dart @@ -16,12 +16,12 @@ void main() { final map = model.toMap(); final result = Transaction.fromMap(map); - expect(result.$id, '259125845563242502'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.status, 'pending'); - expect(result.operations, 5); - expect(result.expiresAt, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, '259125845563242502'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.status, 'pending'); + expect(result.operations, 5); + expect(result.expiresAt, '2020-10-15T06:38:00.000+00:00'); + }); }); } diff --git a/test/src/models/user_test.dart b/test/src/models/user_test.dart index c058ea26..77c7dd97 100644 --- a/test/src/models/user_test.dart +++ b/test/src/models/user_test.dart @@ -26,21 +26,21 @@ void main() { final map = model.toMap(); final result = User.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.name, 'John Doe'); - expect(result.registration, '2020-10-15T06:38:00.000+00:00'); - expect(result.status, true); - expect(result.labels, []); - expect(result.passwordUpdate, '2020-10-15T06:38:00.000+00:00'); - expect(result.email, 'john@appwrite.io'); - expect(result.phone, '+4930901820'); - expect(result.emailVerification, true); - expect(result.phoneVerification, true); - expect(result.mfa, true); - expect(result.targets, []); - expect(result.accessedAt, '2020-10-15T06:38:00.000+00:00'); - }); + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.name, 'John Doe'); + expect(result.registration, '2020-10-15T06:38:00.000+00:00'); + expect(result.status, true); + expect(result.labels, []); + expect(result.passwordUpdate, '2020-10-15T06:38:00.000+00:00'); + expect(result.email, 'john@appwrite.io'); + expect(result.phone, '+4930901820'); + expect(result.emailVerification, true); + expect(result.phoneVerification, true); + expect(result.mfa, true); + expect(result.targets, []); + expect(result.accessedAt, '2020-10-15T06:38:00.000+00:00'); + }); }); }