diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 33ff0a38..d963df0b 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -10,8 +10,6 @@ on: jobs: format: runs-on: ubuntu-latest - container: - image: dart:stable steps: - name: Checkout repository @@ -20,6 +18,14 @@ jobs: persist-credentials: true ref: ${{ github.event.pull_request.head.ref }} + - name: Install Flutter + uses: subosito/flutter-action@v2 + with: + channel: stable + + - name: Install dependencies + run: flutter pub get + - name: Format Dart code run: dart format . @@ -29,5 +35,5 @@ jobs: - name: Add & Commit uses: EndBug/add-and-commit@v9.1.4 with: - add: lib + add: '["lib", "test"]' diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ac74d0c..4c723b80 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## 20.2.2 + +* Widen `device_info_plus` and `package_info_plus` dependencies to allow for newer versions for Android 15+ support +* Fix `CHUNK_SIZE` constant to `chunkSize` +* Fix missing `@override` annotation to `toMap` method in all model classes + ## 20.2.1 * Add transaction support for Databases and TablesDB diff --git a/README.md b/README.md index 4b273ec3..34641a20 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Add this to your package's `pubspec.yaml` file: ```yml dependencies: - appwrite: ^20.2.1 + appwrite: ^20.2.2 ``` You can install packages from the command line: diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index 0acbe689..20a1c3c3 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -1,4 +1,6 @@ import 'package:appwrite/appwrite.dart'; +import 'package:appwrite/permission.dart'; +import 'package:appwrite/role.dart'; Client client = Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -17,6 +19,6 @@ Document result = await databases.createDocument( "age": 30, "isAdmin": false }, - permissions: ["read("any")"], // optional + permissions: [Permission.read(Role.any())], // optional transactionId: '', // optional ); diff --git a/docs/examples/databases/update-document.md b/docs/examples/databases/update-document.md index 44ade30c..9a5b3ee7 100644 --- a/docs/examples/databases/update-document.md +++ b/docs/examples/databases/update-document.md @@ -1,4 +1,6 @@ import 'package:appwrite/appwrite.dart'; +import 'package:appwrite/permission.dart'; +import 'package:appwrite/role.dart'; Client client = Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,6 +13,6 @@ Document result = await databases.updateDocument( collectionId: '', documentId: '', data: {}, // optional - permissions: ["read("any")"], // optional + permissions: [Permission.read(Role.any())], // optional transactionId: '', // optional ); diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md index 10117ac7..7e6eb1ae 100644 --- a/docs/examples/databases/upsert-document.md +++ b/docs/examples/databases/upsert-document.md @@ -1,4 +1,6 @@ import 'package:appwrite/appwrite.dart'; +import 'package:appwrite/permission.dart'; +import 'package:appwrite/role.dart'; Client client = Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,6 +13,6 @@ Document result = await databases.upsertDocument( collectionId: '', documentId: '', data: {}, - permissions: ["read("any")"], // optional + permissions: [Permission.read(Role.any())], // optional transactionId: '', // optional ); diff --git a/docs/examples/storage/create-file.md b/docs/examples/storage/create-file.md index 661f6b8b..ed1021c9 100644 --- a/docs/examples/storage/create-file.md +++ b/docs/examples/storage/create-file.md @@ -1,5 +1,7 @@ import 'dart:io'; import 'package:appwrite/appwrite.dart'; +import 'package:appwrite/permission.dart'; +import 'package:appwrite/role.dart'; Client client = Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,5 +13,5 @@ File result = await storage.createFile( bucketId: '', fileId: '', file: InputFile(path: './path-to-files/image.jpg', filename: 'image.jpg'), - permissions: ["read("any")"], // optional + permissions: [Permission.read(Role.any())], // optional ); diff --git a/docs/examples/storage/update-file.md b/docs/examples/storage/update-file.md index 8e598121..8aa29234 100644 --- a/docs/examples/storage/update-file.md +++ b/docs/examples/storage/update-file.md @@ -1,4 +1,6 @@ import 'package:appwrite/appwrite.dart'; +import 'package:appwrite/permission.dart'; +import 'package:appwrite/role.dart'; Client client = Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -10,5 +12,5 @@ File result = await storage.updateFile( bucketId: '', fileId: '', name: '', // optional - permissions: ["read("any")"], // optional + permissions: [Permission.read(Role.any())], // optional ); diff --git a/docs/examples/tablesdb/create-row.md b/docs/examples/tablesdb/create-row.md index 345f0c23..ede8c404 100644 --- a/docs/examples/tablesdb/create-row.md +++ b/docs/examples/tablesdb/create-row.md @@ -1,4 +1,6 @@ import 'package:appwrite/appwrite.dart'; +import 'package:appwrite/permission.dart'; +import 'package:appwrite/role.dart'; Client client = Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -17,6 +19,6 @@ Row result = await tablesDB.createRow( "age": 30, "isAdmin": false }, - permissions: ["read("any")"], // optional + permissions: [Permission.read(Role.any())], // optional transactionId: '', // optional ); diff --git a/docs/examples/tablesdb/update-row.md b/docs/examples/tablesdb/update-row.md index 08ab3093..91f2dd3c 100644 --- a/docs/examples/tablesdb/update-row.md +++ b/docs/examples/tablesdb/update-row.md @@ -1,4 +1,6 @@ import 'package:appwrite/appwrite.dart'; +import 'package:appwrite/permission.dart'; +import 'package:appwrite/role.dart'; Client client = Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,6 +13,6 @@ Row result = await tablesDB.updateRow( tableId: '', rowId: '', data: {}, // optional - permissions: ["read("any")"], // optional + permissions: [Permission.read(Role.any())], // optional transactionId: '', // optional ); diff --git a/docs/examples/tablesdb/upsert-row.md b/docs/examples/tablesdb/upsert-row.md index 061bb0b8..4fb785d7 100644 --- a/docs/examples/tablesdb/upsert-row.md +++ b/docs/examples/tablesdb/upsert-row.md @@ -1,4 +1,6 @@ import 'package:appwrite/appwrite.dart'; +import 'package:appwrite/permission.dart'; +import 'package:appwrite/role.dart'; Client client = Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -11,6 +13,6 @@ Row result = await tablesDB.upsertRow( tableId: '', rowId: '', data: {}, // optional - permissions: ["read("any")"], // optional + permissions: [Permission.read(Role.any())], // optional transactionId: '', // optional ); diff --git a/lib/query.dart b/lib/query.dart index 77caee35..d0b97b2d 100644 --- a/lib/query.dart +++ b/lib/query.dart @@ -6,7 +6,7 @@ class Query { final String? attribute; final dynamic values; - Query._(this.method, [this.attribute = null, this.values = null]); + Query._(this.method, [this.attribute, this.values]); Map toJson() { final result = {}; @@ -130,16 +130,16 @@ class Query { Query._('updatedBetween', null, [start, end]).toString(); 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(); /// Specify which attributes should be returned by the API call. static String select(List attributes) => @@ -182,43 +182,35 @@ class Query { /// 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(); + 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(); + 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(); + 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(); + 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) => diff --git a/lib/services/account.dart b/lib/services/account.dart index 08d25f6f..e24382f5 100644 --- a/lib/services/account.dart +++ b/lib/services/account.dart @@ -13,12 +13,8 @@ class Account extends Service { final Map apiHeaders = {}; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); } @@ -30,12 +26,11 @@ class Account extends Service { /// route to start verifying the user email address. To allow the new user to /// login to their new account, you need to create a new [account /// session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession). - Future create({ - required String userId, - required String email, - required String password, - String? name, - }) async { + Future create( + {required String userId, + required String email, + required String password, + String? name}) async { const String apiPath = '/account'; final Map apiParams = { @@ -45,14 +40,12 @@ class Account extends Service { 'name': name, }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); } @@ -65,10 +58,8 @@ class Account extends Service { /// This endpoint can also be used to convert an anonymous account to a normal /// one, by passing an email address and a new password. /// - Future updateEmail({ - required String email, - required String password, - }) async { + Future updateEmail( + {required String email, required String password}) async { const String apiPath = '/account/email'; final Map apiParams = { @@ -76,14 +67,12 @@ class Account extends Service { 'password': password, }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); } @@ -92,37 +81,31 @@ class Account extends Service { Future listIdentities({List? queries}) async { const String apiPath = '/account/identities'; - final Map apiParams = {'queries': queries}; + final Map apiParams = { + 'queries': queries, + }; final Map apiHeaders = {}; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.IdentityList.fromMap(res.data); } /// 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 apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.delete, + path: apiPath, params: apiParams, headers: apiHeaders); return res.data; } @@ -137,14 +120,12 @@ class Account extends Service { final Map apiParams = {}; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Jwt.fromMap(res.data); } @@ -154,16 +135,14 @@ class Account extends Service { Future listLogs({List? queries}) async { const String apiPath = '/account/logs'; - final Map apiParams = {'queries': queries}; + final Map apiParams = { + 'queries': queries, + }; final Map apiHeaders = {}; - final 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); } @@ -172,16 +151,16 @@ class Account extends Service { Future updateMFA({required bool mfa}) async { const String apiPath = '/account/mfa'; - final Map apiParams = {'mfa': mfa}; + final Map apiParams = { + 'mfa': mfa, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); } @@ -191,26 +170,20 @@ class Account extends Service { /// 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, - ); + 'This API has been deprecated since 1.8.0. Please use `Account.createMFAAuthenticator` instead.') + Future createMfaAuthenticator( + {required enums.AuthenticatorType type}) async { + final String apiPath = + '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); final Map apiParams = {}; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.MfaType.fromMap(res.data); } @@ -219,24 +192,19 @@ class Account extends Service { /// 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 apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.MfaType.fromMap(res.data); } @@ -245,27 +213,22 @@ class Account extends Service { /// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) /// method. @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead.', - ) - Future updateMfaAuthenticator({ - required enums.AuthenticatorType type, - required String otp, - }) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( - '{type}', - type.value, - ); - - final Map apiParams = {'otp': otp}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + 'This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead.') + Future updateMfaAuthenticator( + {required enums.AuthenticatorType type, required String otp}) async { + final String apiPath = + '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + + final Map apiParams = { + 'otp': otp, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); } @@ -273,70 +236,57 @@ class Account extends Service { /// Verify an authenticator app after adding it using the [add /// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) /// method. - Future updateMFAAuthenticator({ - required enums.AuthenticatorType type, - required String otp, - }) async { - final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( - '{type}', - type.value, - ); - - final Map apiParams = {'otp': otp}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + Future updateMFAAuthenticator( + {required enums.AuthenticatorType type, required String otp}) async { + final String apiPath = + '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + + final Map apiParams = { + 'otp': otp, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); } /// Delete an authenticator for a user by ID. @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.deleteMFAAuthenticator` instead.', - ) + '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 apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.delete, + path: apiPath, params: apiParams, headers: apiHeaders); return res.data; } /// 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 apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.delete, + path: apiPath, params: apiParams, headers: apiHeaders); return res.data; } @@ -345,23 +295,21 @@ class Account extends Service { /// [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 { + 'This API has been deprecated since 1.8.0. Please use `Account.createMFAChallenge` instead.') + Future createMfaChallenge( + {required enums.AuthenticationFactor factor}) async { const String apiPath = '/account/mfa/challenge'; - final Map apiParams = {'factor': factor.value}; + final Map apiParams = { + 'factor': factor.value, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.MfaChallenge.fromMap(res.data); } @@ -369,21 +317,20 @@ class Account extends Service { /// Begin the process of MFA verification after sign-in. Finish the flow with /// [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) /// method. - Future createMFAChallenge({ - required enums.AuthenticationFactor factor, - }) async { + Future createMFAChallenge( + {required enums.AuthenticationFactor factor}) async { const String apiPath = '/account/mfa/challenge'; - final Map apiParams = {'factor': factor.value}; + final Map apiParams = { + 'factor': factor.value, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.MfaChallenge.fromMap(res.data); } @@ -394,12 +341,9 @@ class Account extends Service { /// [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 { + 'This API has been deprecated since 1.8.0. Please use `Account.updateMFAChallenge` instead.') + Future updateMfaChallenge( + {required String challengeId, required String otp}) async { const String apiPath = '/account/mfa/challenge'; final Map apiParams = { @@ -407,14 +351,12 @@ class Account extends Service { 'otp': otp, }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Session.fromMap(res.data); } @@ -424,10 +366,8 @@ class Account extends Service { /// the flow, use /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) /// method. - Future updateMFAChallenge({ - required String challengeId, - required String otp, - }) async { + Future updateMFAChallenge( + {required String challengeId, required String otp}) async { const String apiPath = '/account/mfa/challenge'; final Map apiParams = { @@ -435,22 +375,19 @@ class Account extends Service { 'otp': otp, }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Session.fromMap(res.data); } /// 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.', - ) + 'This API has been deprecated since 1.8.0. Please use `Account.listMFAFactors` instead.') Future listMfaFactors() async { const String apiPath = '/account/mfa/factors'; @@ -458,12 +395,8 @@ class Account extends Service { final Map apiHeaders = {}; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.MfaFactors.fromMap(res.data); } @@ -476,12 +409,8 @@ class Account extends Service { final Map apiHeaders = {}; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.MfaFactors.fromMap(res.data); } @@ -491,8 +420,7 @@ class Account extends Service { /// [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.', - ) + 'This API has been deprecated since 1.8.0. Please use `Account.getMFARecoveryCodes` instead.') Future getMfaRecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; @@ -500,12 +428,8 @@ class Account extends Service { final Map apiHeaders = {}; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.MfaRecoveryCodes.fromMap(res.data); } @@ -521,12 +445,8 @@ class Account extends Service { final Map apiHeaders = {}; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.MfaRecoveryCodes.fromMap(res.data); } @@ -537,21 +457,18 @@ class Account extends Service { /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) /// method. @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.createMFARecoveryCodes` instead.', - ) + 'This API has been deprecated since 1.8.0. Please use `Account.createMFARecoveryCodes` instead.') Future createMfaRecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; final Map apiParams = {}; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.MfaRecoveryCodes.fromMap(res.data); } @@ -566,14 +483,12 @@ class Account extends Service { final Map apiParams = {}; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.MfaRecoveryCodes.fromMap(res.data); } @@ -583,21 +498,18 @@ class Account extends Service { /// [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.', - ) + 'This API has been deprecated since 1.8.0. Please use `Account.updateMFARecoveryCodes` instead.') Future updateMfaRecoveryCodes() async { const String apiPath = '/account/mfa/recovery-codes'; final Map apiParams = {}; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.MfaRecoveryCodes.fromMap(res.data); } @@ -611,14 +523,12 @@ class Account extends Service { final Map apiParams = {}; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.MfaRecoveryCodes.fromMap(res.data); } @@ -627,16 +537,16 @@ class Account extends Service { Future updateName({required String name}) async { const String apiPath = '/account/name'; - final Map apiParams = {'name': name}; + final Map apiParams = { + 'name': name, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); } @@ -644,10 +554,8 @@ class Account extends Service { /// Update currently logged in user password. For validation, user is required /// to pass in the new password, and the old password. For users created with /// OAuth, Team Invites and Magic URL, oldPassword is optional. - Future updatePassword({ - required String password, - String? oldPassword, - }) async { + Future updatePassword( + {required String password, String? oldPassword}) async { const String apiPath = '/account/password'; final Map apiParams = { @@ -655,14 +563,12 @@ class Account extends Service { 'oldPassword': oldPassword, }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); } @@ -672,10 +578,8 @@ class Account extends Service { /// SMS is not sent automatically, however you can use the [POST /// /account/verification/phone](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) /// endpoint to send a confirmation SMS. - Future updatePhone({ - required String phone, - required String password, - }) async { + Future updatePhone( + {required String phone, required String password}) async { const String apiPath = '/account/phone'; final Map apiParams = { @@ -683,14 +587,12 @@ class Account extends Service { 'password': password, }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); } @@ -703,12 +605,8 @@ class Account extends Service { final Map apiHeaders = {}; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Preferences.fromMap(res.data); } @@ -719,16 +617,16 @@ class Account extends Service { Future updatePrefs({required Map prefs}) async { const String apiPath = '/account/prefs'; - final Map apiParams = {'prefs': prefs}; + final Map apiParams = { + 'prefs': prefs, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); } @@ -741,22 +639,21 @@ class Account extends Service { /// /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#updateRecovery) /// endpoint to complete the process. The verification link sent to the user's /// email address is valid for 1 hour. - Future createRecovery({ - required String email, - required String url, - }) async { + Future createRecovery( + {required String email, required String url}) async { const String apiPath = '/account/recovery'; - final Map apiParams = {'email': email, 'url': url}; + final Map apiParams = { + 'email': email, + 'url': url, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Token.fromMap(res.data); } @@ -771,11 +668,10 @@ class Account extends Service { /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) /// the only valid redirect URLs are the ones from domains you have set when /// adding your platforms in the console interface. - Future updateRecovery({ - required String userId, - required String secret, - required String password, - }) async { + Future updateRecovery( + {required String userId, + required String secret, + required String password}) async { const String apiPath = '/account/recovery'; final Map apiParams = { @@ -784,14 +680,12 @@ class Account extends Service { 'password': password, }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Token.fromMap(res.data); } @@ -805,12 +699,8 @@ class Account extends Service { final Map apiHeaders = {}; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.SessionList.fromMap(res.data); } @@ -822,14 +712,12 @@ class Account extends Service { final Map apiParams = {}; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.delete, + path: apiPath, params: apiParams, headers: apiHeaders); return res.data; } @@ -846,14 +734,12 @@ class Account extends Service { final Map apiParams = {}; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Session.fromMap(res.data); } @@ -864,10 +750,8 @@ class Account extends Service { /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - Future createEmailPasswordSession({ - required String email, - required String password, - }) async { + Future createEmailPasswordSession( + {required String email, required String password}) async { const String apiPath = '/account/sessions/email'; final Map apiParams = { @@ -875,14 +759,12 @@ class Account extends Service { 'password': password, }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Session.fromMap(res.data); } @@ -891,24 +773,22 @@ class Account extends Service { /// 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 { + 'This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.') + Future updateMagicURLSession( + {required String userId, required String secret}) async { const String apiPath = '/account/sessions/magic-url'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Session.fromMap(res.data); } @@ -929,22 +809,18 @@ class Account extends Service { /// 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, - ); + Future createOAuth2Session( + {required enums.OAuthProvider provider, + String? success, + String? failure, + List? scopes}) async { + final String apiPath = '/account/sessions/oauth2/{provider}' + .replaceAll('{provider}', provider.value); final Map params = { 'success': success, 'failure': failure, 'scopes': scopes, - 'project': client.config['project'], }; @@ -954,22 +830,20 @@ class Account extends Service { if (value is List) { for (var item in value) { query.add( - Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item), - ); + '${Uri.encodeComponent('$key[]')}=${Uri.encodeComponent(item)}'); } } else if (value != null) { - query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); + 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('&'), - ); + scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + apiPath, + query: query.join('&')); return client.webAuth(url, callbackUrlScheme: success); } @@ -978,24 +852,22 @@ class Account extends Service { /// 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 { + 'This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.') + Future updatePhoneSession( + {required String userId, required String secret}) async { const String apiPath = '/account/sessions/phone'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Session.fromMap(res.data); } @@ -1003,22 +875,21 @@ class Account extends Service { /// Use this endpoint to create a session from token. Provide the **userId** /// and **secret** parameters from the successful response of authentication /// flows initiated by token creation. For example, magic URL and phone login. - Future createSession({ - required String userId, - required String secret, - }) async { + Future createSession( + {required String userId, required String secret}) async { const String apiPath = '/account/sessions/token'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Session.fromMap(res.data); } @@ -1026,21 +897,15 @@ class Account extends Service { /// Use this endpoint to get a logged in user's session using a Session ID. /// Inputting 'current' will return the current session being used. Future getSession({required String sessionId}) async { - final String apiPath = '/account/sessions/{sessionId}'.replaceAll( - '{sessionId}', - sessionId, - ); + final String apiPath = + '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); final Map apiParams = {}; final Map apiHeaders = {}; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Session.fromMap(res.data); } @@ -1049,21 +914,17 @@ class Account extends Service { /// 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 apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Session.fromMap(res.data); } @@ -1074,21 +935,17 @@ 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 apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.delete, + path: apiPath, params: apiParams, headers: apiHeaders); return res.data; } @@ -1101,14 +958,12 @@ class Account extends Service { final Map apiParams = {}; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); } @@ -1118,11 +973,10 @@ class Account extends Service { /// (usually a device token), and optionally specify which provider should send /// notifications to this target. The target is automatically linked to the /// current session and includes device information like brand and model. - Future createPushTarget({ - required String targetId, - required String identifier, - String? providerId, - }) async { + Future createPushTarget( + {required String targetId, + required String identifier, + String? providerId}) async { const String apiPath = '/account/targets/push'; final Map apiParams = { @@ -1131,14 +985,12 @@ class Account extends Service { 'providerId': providerId, }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Target.fromMap(res.data); } @@ -1148,25 +1000,21 @@ class Account extends Service { /// email, phone etc.). The target must exist and belong to the current user. /// If you change the provider ID, notifications will be sent through the new /// messaging provider instead. - Future updatePushTarget({ - required String targetId, - required String identifier, - }) async { - final String apiPath = '/account/targets/{targetId}/push'.replaceAll( - '{targetId}', - targetId, - ); - - final Map apiParams = {'identifier': identifier}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + Future updatePushTarget( + {required String targetId, required String identifier}) async { + final String apiPath = + '/account/targets/{targetId}/push'.replaceAll('{targetId}', targetId); + + final Map apiParams = { + 'identifier': identifier, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Target.fromMap(res.data); } @@ -1175,21 +1023,17 @@ class Account extends Service { /// 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 apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.delete, + path: apiPath, params: apiParams, headers: apiHeaders); return res.data; } @@ -1208,11 +1052,8 @@ class Account extends Service { /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). /// - Future createEmailToken({ - required String userId, - required String email, - bool? phrase, - }) async { + Future createEmailToken( + {required String userId, required String email, bool? phrase}) async { const String apiPath = '/account/tokens/email'; final Map apiParams = { @@ -1221,14 +1062,12 @@ class Account extends Service { 'phrase': phrase, }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Token.fromMap(res.data); } @@ -1247,12 +1086,11 @@ class Account extends Service { /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). /// - Future createMagicURLToken({ - required String userId, - required String email, - String? url, - bool? phrase, - }) async { + Future createMagicURLToken( + {required String userId, + required String email, + String? url, + bool? phrase}) async { const String apiPath = '/account/tokens/magic-url'; final Map apiParams = { @@ -1262,14 +1100,12 @@ class Account extends Service { 'phrase': phrase, }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Token.fromMap(res.data); } @@ -1288,22 +1124,18 @@ class Account extends Service { /// 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, - ); + Future createOAuth2Token( + {required enums.OAuthProvider provider, + String? success, + String? failure, + List? scopes}) async { + final String apiPath = '/account/tokens/oauth2/{provider}' + .replaceAll('{provider}', provider.value); final Map params = { 'success': success, 'failure': failure, 'scopes': scopes, - 'project': client.config['project'], }; @@ -1313,22 +1145,20 @@ class Account extends Service { if (value is List) { for (var item in value) { query.add( - Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item), - ); + '${Uri.encodeComponent('$key[]')}=${Uri.encodeComponent(item)}'); } } else if (value != null) { - query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); + 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('&'), - ); + scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + apiPath, + query: query.join('&')); return client.webAuth(url, callbackUrlScheme: success); } @@ -1343,22 +1173,21 @@ class Account extends Service { /// A user is limited to 10 active sessions at a time by default. [Learn more /// about session /// limits](https://appwrite.io/docs/authentication-security#limits). - Future createPhoneToken({ - required String userId, - required String phone, - }) async { + Future createPhoneToken( + {required String userId, required String phone}) async { const String apiPath = '/account/tokens/phone'; - final Map apiParams = {'userId': userId, 'phone': phone}; + final Map apiParams = { + 'userId': userId, + 'phone': phone, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Token.fromMap(res.data); } @@ -1381,16 +1210,16 @@ class Account extends Service { Future createEmailVerification({required String url}) async { const String apiPath = '/account/verifications/email'; - final Map apiParams = {'url': url}; + final Map apiParams = { + 'url': url, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Token.fromMap(res.data); } @@ -1411,21 +1240,20 @@ class Account extends Service { /// adding your platforms in the console interface. /// @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.createEmailVerification` instead.', - ) + 'This API has been deprecated since 1.8.0. Please use `Account.createEmailVerification` instead.') Future createVerification({required String url}) async { const String apiPath = '/account/verifications/email'; - final Map apiParams = {'url': url}; + final Map apiParams = { + 'url': url, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Token.fromMap(res.data); } @@ -1434,22 +1262,21 @@ class Account extends Service { /// 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 { const String apiPath = '/account/verifications/email'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Token.fromMap(res.data); } @@ -1459,24 +1286,22 @@ class Account extends Service { /// 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 { + 'This API has been deprecated since 1.8.0. Please use `Account.updateEmailVerification` instead.') + Future updateVerification( + {required String userId, required String secret}) async { const String apiPath = '/account/verifications/email'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Token.fromMap(res.data); } @@ -1494,14 +1319,12 @@ class Account extends Service { final Map apiParams = {}; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Token.fromMap(res.data); } @@ -1510,22 +1333,21 @@ class Account extends Service { /// **userId** and **secret** that were sent to your user's phone number to /// verify the user email ownership. If confirmed this route will return a 200 /// status code. - Future updatePhoneVerification({ - required String userId, - required String secret, - }) async { + Future updatePhoneVerification( + {required String userId, required String secret}) async { const String apiPath = '/account/verifications/phone'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Token.fromMap(res.data); } diff --git a/lib/services/avatars.dart b/lib/services/avatars.dart index a02b2db2..8876025d 100644 --- a/lib/services/avatars.dart +++ b/lib/services/avatars.dart @@ -16,31 +16,23 @@ class Avatars extends Service { /// 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, - ); + Future getBrowser( + {required enums.Browser code, + int? width, + int? height, + int? quality}) async { + final String apiPath = + '/avatars/browsers/{code}'.replaceAll('{code}', code.value); final Map params = { 'width': width, 'height': height, 'quality': quality, - 'project': client.config['project'], }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: params, responseType: ResponseType.bytes); return res.data; } @@ -53,31 +45,23 @@ class Avatars extends Service { /// 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, - ); + Future getCreditCard( + {required enums.CreditCard code, + int? width, + int? height, + int? quality}) async { + final String apiPath = + '/avatars/credit-cards/{code}'.replaceAll('{code}', code.value); final Map params = { 'width': width, 'height': height, 'quality': quality, - 'project': client.config['project'], }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: params, responseType: ResponseType.bytes); return res.data; } @@ -90,16 +74,11 @@ class Avatars extends Service { final Map params = { 'url': url, - 'project': client.config['project'], }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: params, responseType: ResponseType.bytes); return res.data; } @@ -113,31 +92,20 @@ class Avatars extends Service { /// 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, - ); + Future getFlag( + {required enums.Flag code, int? width, int? height, int? quality}) async { + final String apiPath = + '/avatars/flags/{code}'.replaceAll('{code}', code.value); final Map params = { 'width': width, 'height': height, 'quality': quality, - 'project': client.config['project'], }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: params, responseType: ResponseType.bytes); return res.data; } @@ -152,27 +120,19 @@ class Avatars extends Service { /// of image returned is 400x400px. /// /// This endpoint does not follow HTTP redirects. - Future getImage({ - required String url, - int? width, - int? height, - }) async { + Future getImage( + {required String url, int? width, int? height}) async { const String apiPath = '/avatars/image'; final Map params = { 'url': url, 'width': width, 'height': height, - 'project': client.config['project'], }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: params, responseType: ResponseType.bytes); return res.data; } @@ -192,12 +152,8 @@ class Avatars extends Service { /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. /// - Future getInitials({ - String? name, - int? width, - int? height, - String? background, - }) async { + Future getInitials( + {String? name, int? width, int? height, String? background}) async { const String apiPath = '/avatars/initials'; final Map params = { @@ -205,28 +161,19 @@ class Avatars extends Service { 'width': width, 'height': height, 'background': background, - 'project': client.config['project'], }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: params, responseType: ResponseType.bytes); return res.data; } /// Converts a given plain text to a QR code image. You can use the query /// parameters to change the size and style of the resulting image. /// - Future getQR({ - required String text, - int? size, - int? margin, - bool? download, - }) async { + Future getQR( + {required String text, int? size, int? margin, bool? download}) async { const String apiPath = '/avatars/qr'; final Map params = { @@ -234,16 +181,11 @@ class Avatars extends Service { 'size': size, 'margin': margin, 'download': download, - 'project': client.config['project'], }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); + 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 4c76d231..23bb0650 100644 --- a/lib/services/databases.dart +++ b/lib/services/databases.dart @@ -7,21 +7,18 @@ class Databases extends Service { Databases(super.client); /// List transactions across all databases. - Future listTransactions({ - List? queries, - }) async { + Future listTransactions( + {List? queries}) async { const String apiPath = '/databases/transactions'; - final Map apiParams = {'queries': queries}; + final Map apiParams = { + 'queries': queries, + }; final Map apiHeaders = {}; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.TransactionList.fromMap(res.data); } @@ -30,110 +27,90 @@ class Databases extends Service { Future createTransaction({int? ttl}) async { const String apiPath = '/databases/transactions'; - final Map apiParams = {'ttl': ttl}; + final Map apiParams = { + 'ttl': ttl, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.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, - ); + Future getTransaction( + {required String transactionId}) async { + final String apiPath = '/databases/transactions/{transactionId}' + .replaceAll('{transactionId}', transactionId); final Map apiParams = {}; final Map apiHeaders = {}; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.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, - ); + Future updateTransaction( + {required String transactionId, bool? commit, bool? rollback}) async { + final String apiPath = '/databases/transactions/{transactionId}' + .replaceAll('{transactionId}', transactionId); final Map apiParams = { 'commit': commit, 'rollback': rollback, }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Transaction.fromMap(res.data); } /// Delete a transaction by its unique ID. 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 apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.delete, + path: apiPath, params: apiParams, headers: apiHeaders); return res.data; } /// Create multiple operations in a single transaction. - Future createOperations({ - required String transactionId, - List? operations, - }) async { + Future createOperations( + {required String transactionId, List? operations}) async { final String apiPath = '/databases/transactions/{transactionId}/operations' .replaceAll('{transactionId}', transactionId); - final Map apiParams = {'operations': operations}; + final Map apiParams = { + 'operations': operations, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Transaction.fromMap(res.data); } @@ -141,14 +118,12 @@ class Databases extends Service { /// Get a list of all the user's documents in a given collection. You can use /// the query params to filter your results. @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, - }) async { + '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}) async { final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents' .replaceAll('{databaseId}', databaseId) @@ -161,12 +136,8 @@ class Databases extends Service { final Map apiHeaders = {}; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.DocumentList.fromMap(res.data); } @@ -176,16 +147,14 @@ class Databases extends Service { /// 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 { + '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) @@ -198,14 +167,12 @@ class Databases extends Service { 'transactionId': transactionId, }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Document.fromMap(res.data); } @@ -213,15 +180,13 @@ class Databases extends Service { /// 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 { + '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) @@ -235,12 +200,8 @@ class Databases extends Service { final Map apiHeaders = {}; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Document.fromMap(res.data); } @@ -250,16 +211,14 @@ class Databases extends Service { /// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) /// API or directly from your database console. @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead.', - ) - Future upsertDocument({ - required String databaseId, - required String collectionId, - required String documentId, - required Map data, - List? permissions, - String? transactionId, - }) async { + 'This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead.') + Future upsertDocument( + {required String databaseId, + required String collectionId, + required String documentId, + required Map data, + List? permissions, + String? transactionId}) async { final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' .replaceAll('{databaseId}', databaseId) @@ -272,14 +231,12 @@ class Databases extends Service { 'transactionId': transactionId, }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Document.fromMap(res.data); } @@ -287,16 +244,14 @@ class Databases extends Service { /// Update a document by its unique ID. Using the patch method you can pass /// only specific fields that will get updated. @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 { + '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) @@ -309,61 +264,55 @@ class Databases extends Service { 'transactionId': transactionId, }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.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 { + '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 apiParams = { + 'transactionId': transactionId, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.delete, + path: apiPath, params: apiParams, headers: apiHeaders); return res.data; } /// 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 { + '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) @@ -377,31 +326,27 @@ class Databases extends Service { 'transactionId': transactionId, }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.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 { + '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) @@ -415,14 +360,12 @@ class Databases extends Service { 'transactionId': transactionId, }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Document.fromMap(res.data); } diff --git a/lib/services/functions.dart b/lib/services/functions.dart index d8924273..8b8f9c1e 100644 --- a/lib/services/functions.dart +++ b/lib/services/functions.dart @@ -8,25 +8,19 @@ class Functions extends Service { /// Get a list of all the current user function execution logs. You can use the /// query params to filter your results. - Future listExecutions({ - required String functionId, - List? queries, - }) async { - final String apiPath = '/functions/{functionId}/executions'.replaceAll( - '{functionId}', - functionId, - ); + Future listExecutions( + {required String functionId, List? queries}) async { + final String apiPath = '/functions/{functionId}/executions' + .replaceAll('{functionId}', functionId); - final Map apiParams = {'queries': queries}; + final Map apiParams = { + 'queries': queries, + }; final Map apiHeaders = {}; - final 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.ExecutionList.fromMap(res.data); } @@ -35,19 +29,16 @@ class Functions extends Service { /// current execution status. You can ping the `Get Execution` endpoint to get /// updates on the current execution status. Once this endpoint is called, your /// function execution process will start asynchronously. - Future createExecution({ - required String functionId, - String? body, - bool? xasync, - String? path, - enums.ExecutionMethod? method, - Map? headers, - String? scheduledAt, - }) async { - final String apiPath = '/functions/{functionId}/executions'.replaceAll( - '{functionId}', - functionId, - ); + Future createExecution( + {required String functionId, + String? body, + bool? xasync, + String? path, + enums.ExecutionMethod? method, + Map? headers, + String? scheduledAt}) async { + final String apiPath = '/functions/{functionId}/executions' + .replaceAll('{functionId}', functionId); final Map apiParams = { 'body': body, @@ -58,23 +49,19 @@ class Functions extends Service { 'scheduledAt': scheduledAt, }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Execution.fromMap(res.data); } /// Get a function execution log by its unique ID. - Future getExecution({ - required String functionId, - required String executionId, - }) async { + Future getExecution( + {required String functionId, required String executionId}) async { final String apiPath = '/functions/{functionId}/executions/{executionId}' .replaceAll('{functionId}', functionId) .replaceAll('{executionId}', executionId); @@ -83,12 +70,8 @@ class Functions extends Service { final Map apiHeaders = {}; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Execution.fromMap(res.data); } diff --git a/lib/services/graphql.dart b/lib/services/graphql.dart index 32ea107f..ff4e17d4 100644 --- a/lib/services/graphql.dart +++ b/lib/services/graphql.dart @@ -10,19 +10,17 @@ class Graphql extends Service { Future query({required Map query}) async { const String apiPath = '/graphql'; - final Map apiParams = {'query': query}; + final Map apiParams = { + 'query': query, + }; final Map apiHeaders = { 'x-sdk-graphql': 'true', 'content-type': 'application/json', }; - final 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; } @@ -31,19 +29,17 @@ class Graphql extends Service { Future mutation({required Map query}) async { const String apiPath = '/graphql/mutation'; - final Map apiParams = {'query': query}; + final Map apiParams = { + 'query': query, + }; final Map apiHeaders = { 'x-sdk-graphql': 'true', 'content-type': 'application/json', }; - final 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; } diff --git a/lib/services/locale.dart b/lib/services/locale.dart index fbd04e4a..dd9a5fef 100644 --- a/lib/services/locale.dart +++ b/lib/services/locale.dart @@ -19,12 +19,8 @@ class Locale extends Service { final Map apiHeaders = {}; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Locale.fromMap(res.data); } @@ -38,12 +34,8 @@ class Locale extends Service { final Map apiHeaders = {}; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.LocaleCodeList.fromMap(res.data); } @@ -57,12 +49,8 @@ class Locale extends Service { final Map apiHeaders = {}; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.ContinentList.fromMap(res.data); } @@ -76,12 +64,8 @@ class Locale extends Service { final Map apiHeaders = {}; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.CountryList.fromMap(res.data); } @@ -95,12 +79,8 @@ class Locale extends Service { final Map apiHeaders = {}; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.CountryList.fromMap(res.data); } @@ -114,12 +94,8 @@ class Locale extends Service { final Map apiHeaders = {}; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.PhoneList.fromMap(res.data); } @@ -134,12 +110,8 @@ class Locale extends Service { final Map apiHeaders = {}; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.CurrencyList.fromMap(res.data); } @@ -153,12 +125,8 @@ class Locale extends Service { final Map apiHeaders = {}; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.LanguageList.fromMap(res.data); } diff --git a/lib/services/messaging.dart b/lib/services/messaging.dart index 236037fa..87760d50 100644 --- a/lib/services/messaging.dart +++ b/lib/services/messaging.dart @@ -7,38 +7,31 @@ class Messaging extends 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 apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Subscriber.fromMap(res.data); } /// Delete a subscriber by its unique ID. - Future deleteSubscriber({ - required String topicId, - required String subscriberId, - }) async { + Future deleteSubscriber( + {required String topicId, required String subscriberId}) async { final String apiPath = '/messaging/topics/{topicId}/subscribers/{subscriberId}' .replaceAll('{topicId}', topicId) @@ -46,14 +39,12 @@ class Messaging extends Service { final Map apiParams = {}; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.delete, + path: apiPath, params: apiParams, headers: apiHeaders); return res.data; } diff --git a/lib/services/storage.dart b/lib/services/storage.dart index 258776f2..e3f141dc 100644 --- a/lib/services/storage.dart +++ b/lib/services/storage.dart @@ -7,15 +7,10 @@ class Storage extends Service { /// Get a list of all the user files. You can use the query params to filter /// your results. - Future listFiles({ - required String bucketId, - List? queries, - String? search, - }) async { - final String apiPath = '/storage/buckets/{bucketId}/files'.replaceAll( - '{bucketId}', - bucketId, - ); + Future listFiles( + {required String bucketId, List? queries, String? search}) async { + final String apiPath = + '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); final Map apiParams = { 'queries': queries, @@ -24,12 +19,8 @@ class Storage extends Service { final Map apiHeaders = {}; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.FileList.fromMap(res.data); } @@ -52,17 +43,14 @@ class Storage extends Service { /// 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, - ); + 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, @@ -91,10 +79,8 @@ class Storage extends Service { /// Get a file by its unique ID. This endpoint response returns a JSON object /// with the file metadata. - Future getFile({ - required String bucketId, - required String fileId, - }) async { + Future getFile( + {required String bucketId, required String fileId}) async { final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}' .replaceAll('{bucketId}', bucketId) .replaceAll('{fileId}', fileId); @@ -103,24 +89,19 @@ class Storage extends Service { final Map apiHeaders = {}; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.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 { + 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); @@ -130,14 +111,12 @@ class Storage extends Service { 'permissions': permissions, }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); return models.File.fromMap(res.data); } @@ -151,14 +130,12 @@ class Storage extends Service { final Map apiParams = {}; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.delete, + path: apiPath, params: apiParams, headers: apiHeaders); return res.data; } @@ -166,27 +143,19 @@ class Storage extends Service { /// 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 { + Future getFileDownload( + {required String bucketId, required String fileId, String? token}) async { final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download' .replaceAll('{bucketId}', bucketId) .replaceAll('{fileId}', fileId); final Map params = { 'token': token, - 'project': client.config['project'], }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: params, responseType: ResponseType.bytes); return res.data; } @@ -195,22 +164,21 @@ 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 { + 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); @@ -228,43 +196,30 @@ class Storage extends Service { 'background': background, 'output': output?.value, 'token': token, - 'project': client.config['project'], }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); + 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 { + Future getFileView( + {required String bucketId, required String fileId, String? token}) async { final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view' .replaceAll('{bucketId}', bucketId) .replaceAll('{fileId}', fileId); final Map params = { 'token': token, - 'project': client.config['project'], }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); + 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 ad65808e..702fe0e8 100644 --- a/lib/services/tables_db.dart +++ b/lib/services/tables_db.dart @@ -5,21 +5,18 @@ class TablesDB extends Service { TablesDB(super.client); /// List transactions across all databases. - Future listTransactions({ - List? queries, - }) async { + Future listTransactions( + {List? queries}) async { const String apiPath = '/tablesdb/transactions'; - final Map apiParams = {'queries': queries}; + final Map apiParams = { + 'queries': queries, + }; final Map apiHeaders = {}; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.TransactionList.fromMap(res.data); } @@ -28,122 +25,101 @@ class TablesDB extends Service { Future createTransaction({int? ttl}) async { const String apiPath = '/tablesdb/transactions'; - final Map apiParams = {'ttl': ttl}; + final Map apiParams = { + 'ttl': ttl, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.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 apiHeaders = {}; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.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, - ); + Future updateTransaction( + {required String transactionId, bool? commit, bool? rollback}) async { + final String apiPath = '/tablesdb/transactions/{transactionId}' + .replaceAll('{transactionId}', transactionId); final Map apiParams = { 'commit': commit, 'rollback': rollback, }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.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 apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.delete, + path: apiPath, params: apiParams, headers: apiHeaders); return res.data; } /// Create multiple operations in a single transaction. - Future createOperations({ - required String transactionId, - List? operations, - }) async { + Future createOperations( + {required String transactionId, List? operations}) async { final String apiPath = '/tablesdb/transactions/{transactionId}/operations' .replaceAll('{transactionId}', transactionId); - final Map apiParams = {'operations': operations}; + final Map apiParams = { + 'operations': operations, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.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, - }) async { + Future listRows( + {required String databaseId, + required String tableId, + List? queries, + String? transactionId}) async { final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' .replaceAll('{databaseId}', databaseId) .replaceAll('{tableId}', tableId); @@ -155,12 +131,8 @@ class TablesDB extends Service { final Map apiHeaders = {}; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.RowList.fromMap(res.data); } @@ -169,14 +141,13 @@ class TablesDB extends Service { /// 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 { + 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); @@ -188,27 +159,24 @@ class TablesDB extends Service { 'transactionId': transactionId, }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.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 { + 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) @@ -222,12 +190,8 @@ class TablesDB extends Service { final Map apiHeaders = {}; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Row.fromMap(res.data); } @@ -236,14 +200,13 @@ class TablesDB extends Service { /// 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 { + 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) @@ -256,28 +219,25 @@ class TablesDB extends Service { 'transactionId': transactionId, }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); return models.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 { + 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) @@ -290,55 +250,51 @@ class TablesDB extends Service { 'transactionId': transactionId, }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.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 { + 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 apiParams = { + 'transactionId': transactionId, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.delete, + path: apiPath, params: apiParams, headers: apiHeaders); return res.data; } /// 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 { + 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) @@ -352,28 +308,25 @@ class TablesDB extends Service { 'transactionId': transactionId, }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.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 { + 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) @@ -387,14 +340,12 @@ class TablesDB extends Service { 'transactionId': transactionId, }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Row.fromMap(res.data); } diff --git a/lib/services/teams.dart b/lib/services/teams.dart index 24089628..4da8936a 100644 --- a/lib/services/teams.dart +++ b/lib/services/teams.dart @@ -18,12 +18,8 @@ class Teams extends Service { final Map apiHeaders = {}; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.TeamList.fromMap(res.data); } @@ -31,11 +27,10 @@ class Teams extends Service { /// Create a new team. The user who creates the team will automatically be /// assigned as the owner of the team. Only the users with the owner role can /// invite new members, add new owners and delete or update the team. - Future create({ - required String teamId, - required String name, - List? roles, - }) async { + Future create( + {required String teamId, + required String name, + List? roles}) async { const String apiPath = '/teams'; final Map apiParams = { @@ -44,14 +39,12 @@ class Teams extends Service { 'roles': roles, }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Team.fromMap(res.data); } @@ -64,33 +57,27 @@ class Teams extends Service { final Map apiHeaders = {}; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Team.fromMap(res.data); } /// Update the team's name by its unique ID. - Future updateName({ - required String teamId, - required String name, - }) async { + Future updateName( + {required String teamId, required String name}) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map apiParams = {'name': name}; + final Map apiParams = { + 'name': name, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Team.fromMap(res.data); } @@ -102,14 +89,12 @@ class Teams extends Service { final Map apiParams = {}; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.delete, + path: apiPath, params: apiParams, headers: apiHeaders); return res.data; } @@ -117,15 +102,10 @@ class Teams extends Service { /// Use this endpoint to list a team's members using the team's ID. All team /// members have read access to this endpoint. Hide sensitive attributes from /// the response by toggling membership privacy in the Console. - Future listMemberships({ - required String teamId, - List? queries, - String? search, - }) async { - final String apiPath = '/teams/{teamId}/memberships'.replaceAll( - '{teamId}', - teamId, - ); + Future listMemberships( + {required String teamId, List? queries, String? search}) async { + final String apiPath = + '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); final Map apiParams = { 'queries': queries, @@ -134,12 +114,8 @@ class Teams extends Service { final Map apiHeaders = {}; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.MembershipList.fromMap(res.data); } @@ -165,19 +141,16 @@ class Teams extends Service { /// 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, - ); + Future createMembership( + {required String teamId, + required List roles, + String? email, + String? userId, + String? phone, + String? url, + String? name}) async { + final String apiPath = + '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); final Map apiParams = { 'email': email, @@ -188,14 +161,12 @@ class Teams extends Service { 'name': name, }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Membership.fromMap(res.data); } @@ -203,10 +174,8 @@ class Teams extends Service { /// 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 { + Future getMembership( + {required String teamId, required String membershipId}) async { final String apiPath = '/teams/{teamId}/memberships/{membershipId}' .replaceAll('{teamId}', teamId) .replaceAll('{membershipId}', membershipId); @@ -215,12 +184,8 @@ class Teams extends Service { final Map apiHeaders = {}; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Membership.fromMap(res.data); } @@ -229,25 +194,24 @@ class Teams extends Service { /// 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 { + 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 apiParams = { + 'roles': roles, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Membership.fromMap(res.data); } @@ -255,24 +219,20 @@ class Teams extends Service { /// 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 { + Future deleteMembership( + {required String teamId, required String membershipId}) async { final String apiPath = '/teams/{teamId}/memberships/{membershipId}' .replaceAll('{teamId}', teamId) .replaceAll('{membershipId}', membershipId); final Map apiParams = {}; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.delete, + path: apiPath, params: apiParams, headers: apiHeaders); return res.data; } @@ -284,26 +244,26 @@ class Teams extends Service { /// 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 { + 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 apiParams = { + 'userId': userId, + 'secret': secret, + }; - final Map apiHeaders = {'content-type': 'application/json'}; + final Map apiHeaders = { + 'content-type': 'application/json', + }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Membership.fromMap(res.data); } @@ -312,21 +272,15 @@ class Teams extends Service { /// need to be shared by all team members, prefer storing them in [user /// preferences](https://appwrite.io/docs/references/cloud/client-web/account#getPrefs). Future getPrefs({required String teamId}) async { - final String apiPath = '/teams/{teamId}/prefs'.replaceAll( - '{teamId}', - teamId, - ); + final String apiPath = + '/teams/{teamId}/prefs'.replaceAll('{teamId}', teamId); final Map apiParams = {}; final Map apiHeaders = {}; - final 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); } @@ -334,25 +288,21 @@ class Teams extends Service { /// Update the team's preferences by its unique ID. The object you pass is /// stored as is and replaces any previous value. The maximum allowed prefs /// size is 64kB and throws an error if exceeded. - Future updatePrefs({ - required String teamId, - required Map prefs, - }) async { - final String apiPath = '/teams/{teamId}/prefs'.replaceAll( - '{teamId}', - teamId, - ); - - final Map apiParams = {'prefs': prefs}; - - final Map apiHeaders = {'content-type': 'application/json'}; - - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + Future updatePrefs( + {required String teamId, required Map prefs}) async { + final String apiPath = + '/teams/{teamId}/prefs'.replaceAll('{teamId}', teamId); + + final Map apiParams = { + 'prefs': prefs, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + }; + + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Preferences.fromMap(res.data); } diff --git a/lib/src/client.dart b/lib/src/client.dart index 05fff190..96c3b4ae 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -9,8 +9,8 @@ import 'upload_progress.dart'; /// /// The [Client] is also responsible for managing user's sessions. abstract class Client { - /// The size for cunked uploads in bytes. - static const int CHUNK_SIZE = 5 * 1024 * 1024; + /// The size for chunked uploads in bytes. + static const int chunkSize = 5 * 1024 * 1024; /// Holds configuration such as project. late Map config; @@ -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}); @@ -58,25 +59,25 @@ abstract class Client { /// Set Project. /// /// Your project ID. - Client setProject(value); + Client setProject(String value); /// Set JWT. /// /// Your secret JSON Web Token. - Client setJWT(value); + Client setJWT(String value); /// Set Locale. - Client setLocale(value); + Client setLocale(String value); /// Set Session. /// /// The user session to authenticate with. - Client setSession(value); + Client setSession(String value); /// Set DevKey. /// /// Your secret dev API key. - Client setDevKey(value); + Client setDevKey(String value); /// Add headers that should be sent with all API calls. Client addHeader(String key, String value); diff --git a/lib/src/client_browser.dart b/lib/src/client_browser.dart index 16aba109..cc1b02bd 100644 --- a/lib/src/client_browser.dart +++ b/lib/src/client_browser.dart @@ -16,7 +16,7 @@ ClientBase createClient({required String endPoint, required bool selfSigned}) => ClientBrowser(endPoint: endPoint, selfSigned: selfSigned); class ClientBrowser extends ClientBase with ClientMixin { - static const int CHUNK_SIZE = 5 * 1024 * 1024; + static const int chunkSize = 5 * 1024 * 1024; String _endPoint; Map? _headers; @override @@ -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': '20.2.1', + 'x-sdk-version': '20.2.2', 'X-Appwrite-Response-Format': '1.8.0', }; @@ -155,7 +155,7 @@ class ClientBrowser extends ClientBase with ClientMixin { int size = file.bytes!.length; late Response res; - if (size <= CHUNK_SIZE) { + if (size <= chunkSize) { params[paramName] = http.MultipartFile.fromBytes( paramName, file.bytes!, @@ -175,17 +175,17 @@ class ClientBrowser extends ClientBase with ClientMixin { try { res = await call( HttpMethod.get, - path: path + '/' + params[idParamName], + path: '$path/${params[idParamName]}', headers: headers, ); final int chunksUploaded = res.data['chunksUploaded'] as int; - offset = chunksUploaded * CHUNK_SIZE; + offset = chunksUploaded * chunkSize; } on AppwriteException catch (_) {} } while (offset < size) { List chunk = []; - final end = min(offset + CHUNK_SIZE, size); + final end = min(offset + chunkSize, size); chunk = file.bytes!.getRange(offset, end).toList(); params[paramName] = http.MultipartFile.fromBytes( paramName, @@ -193,14 +193,14 @@ class ClientBrowser extends ClientBase with ClientMixin { filename: file.filename, ); headers['content-range'] = - 'bytes $offset-${min((offset + CHUNK_SIZE - 1), size - 1)}/$size'; + 'bytes $offset-${min((offset + chunkSize - 1), size - 1)}/$size'; res = await call( HttpMethod.post, path: path, headers: headers, params: params, ); - offset += CHUNK_SIZE; + offset += chunkSize; if (offset < size) { headers['x-appwrite-id'] = res.data['\$id']; } @@ -268,7 +268,7 @@ class ClientBrowser extends ClientBase with ClientMixin { Future webAuth(Uri url, {String? callbackUrlScheme}) { return FlutterWebAuth2.authenticate( url: url.toString(), - callbackUrlScheme: "appwrite-callback-" + config['project']!, + callbackUrlScheme: "appwrite-callback-${config['project']!}", options: const FlutterWebAuth2Options(useWebview: false), ); } diff --git a/lib/src/client_io.dart b/lib/src/client_io.dart index cd77bb7d..f8e18055 100644 --- a/lib/src/client_io.dart +++ b/lib/src/client_io.dart @@ -22,7 +22,7 @@ ClientBase createClient({required String endPoint, required bool selfSigned}) => ClientIO(endPoint: endPoint, selfSigned: selfSigned); class ClientIO extends ClientBase with ClientMixin { - static const int CHUNK_SIZE = 5 * 1024 * 1024; + static const int chunkSize = 5 * 1024 * 1024; String _endPoint; Map? _headers; @override @@ -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': '20.2.1', + 'x-sdk-version': '20.2.2', 'X-Appwrite-Response-Format': '1.8.0', }; @@ -206,7 +206,7 @@ class ClientIO extends ClientBase with ClientMixin { } catch (e) { debugPrint('Error getting device info: $e'); device = Platform.operatingSystem; - addHeader('user-agent', '$device'); + addHeader('user-agent', device); } _initialized = true; @@ -269,7 +269,7 @@ class ClientIO extends ClientBase with ClientMixin { } late Response res; - if (size <= CHUNK_SIZE) { + if (size <= chunkSize) { if (file.path != null) { params[paramName] = await http.MultipartFile.fromPath( paramName, @@ -297,11 +297,11 @@ class ClientIO extends ClientBase with ClientMixin { try { res = await call( HttpMethod.get, - path: path + '/' + params[idParamName], + path: '$path/${params[idParamName]}', headers: headers, ); final int chunksUploaded = res.data['chunksUploaded'] as int; - offset = chunksUploaded * CHUNK_SIZE; + offset = chunksUploaded * chunkSize; } on AppwriteException catch (_) {} } @@ -314,11 +314,11 @@ class ClientIO extends ClientBase with ClientMixin { while (offset < size) { List chunk = []; if (file.bytes != null) { - final end = min(offset + CHUNK_SIZE, size); + final end = min(offset + chunkSize, size); chunk = file.bytes!.getRange(offset, end).toList(); } else { raf!.setPositionSync(offset); - chunk = raf.readSync(CHUNK_SIZE); + chunk = raf.readSync(chunkSize); } params[paramName] = http.MultipartFile.fromBytes( paramName, @@ -326,14 +326,14 @@ class ClientIO extends ClientBase with ClientMixin { filename: file.filename, ); headers['content-range'] = - 'bytes $offset-${min((offset + CHUNK_SIZE - 1), size - 1)}/$size'; + 'bytes $offset-${min((offset + chunkSize - 1), size - 1)}/$size'; res = await call( HttpMethod.post, path: path, headers: headers, params: params, ); - offset += CHUNK_SIZE; + offset += chunkSize; if (offset < size) { headers['x-appwrite-id'] = res.data['\$id']; } @@ -358,7 +358,7 @@ class ClientIO extends ClientBase with ClientMixin { url: url.toString(), callbackUrlScheme: callbackUrlScheme != null && _customSchemeAllowed ? callbackUrlScheme - : "appwrite-callback-" + config['project']!, + : "appwrite-callback-${config['project']!}", options: const FlutterWebAuth2Options( intentFlags: ephemeralIntentFlags, useWebview: false, diff --git a/lib/src/client_mixin.dart b/lib/src/client_mixin.dart index 06c9ebe3..e4f413a7 100644 --- a/lib/src/client_mixin.dart +++ b/lib/src/client_mixin.dart @@ -45,7 +45,7 @@ mixin ClientMixin { return MapEntry(key, value.toString()); } if (value is List) { - return MapEntry(key + "[]", value); + return MapEntry("$key[]", value); } return MapEntry(key, value); }); @@ -123,11 +123,10 @@ mixin ClientMixin { return http.Response( '', streamedResponse.statusCode, - headers: streamedResponse.headers.map( - (k, v) => k.toLowerCase() == 'content-type' - ? MapEntry(k, 'text/plain') - : MapEntry(k, v), - ), + headers: streamedResponse.headers.map((k, v) => + k.toLowerCase() == 'content-type' + ? MapEntry(k, 'text/plain') + : MapEntry(k, v)), request: streamedResponse.request, isRedirect: streamedResponse.isRedirect, persistentConnection: streamedResponse.persistentConnection, diff --git a/lib/src/cookie_manager.dart b/lib/src/cookie_manager.dart index 0fbc0dd1..6b1e67cd 100644 --- a/lib/src/cookie_manager.dart +++ b/lib/src/cookie_manager.dart @@ -11,19 +11,20 @@ class CookieManager extends Interceptor { CookieManager(this.cookieJar); @override - FutureOr onRequest(http.BaseRequest request) async { + FutureOr onRequest( + http.BaseRequest request, + ) async { await cookieJar .loadForRequest(Uri(scheme: request.url.scheme, host: request.url.host)) .then((cookies) { - var cookie = getCookies(cookies); - if (cookie.isNotEmpty) { - request.headers.addAll({HttpHeaders.cookieHeader: cookie}); - } - return request; - }) - .catchError((e, stackTrace) { - return request; - }); + var cookie = getCookies(cookies); + if (cookie.isNotEmpty) { + request.headers.addAll({HttpHeaders.cookieHeader: cookie}); + } + return request; + }).catchError((e, stackTrace) { + return request; + }); return request; } @@ -42,9 +43,8 @@ class CookieManager extends Interceptor { var cookies = cookie.split(exp); await cookieJar.saveFromResponse( Uri( - scheme: response.request!.url.scheme, - host: response.request!.url.host, - ), + scheme: response.request!.url.scheme, + host: response.request!.url.host), cookies.map((str) => Cookie.fromSetCookieValue(str)).toList(), ); } diff --git a/lib/src/enums.dart b/lib/src/enums.dart index 0f250ea3..595afdc2 100644 --- a/lib/src/enums.dart +++ b/lib/src/enums.dart @@ -17,5 +17,5 @@ enum ResponseType { plain, /// Get original bytes, the type of response will be `List` - bytes, + bytes } diff --git a/lib/src/enums/execution_status.dart b/lib/src/enums/execution_status.dart index 7e793cce..7ea9865e 100644 --- a/lib/src/enums/execution_status.dart +++ b/lib/src/enums/execution_status.dart @@ -4,7 +4,8 @@ enum ExecutionStatus { waiting(value: 'waiting'), processing(value: 'processing'), completed(value: 'completed'), - failed(value: 'failed'); + failed(value: 'failed'), + scheduled(value: 'scheduled'); const ExecutionStatus({required this.value}); diff --git a/lib/src/models/algo_argon2.dart b/lib/src/models/algo_argon2.dart index 4145f701..344a8770 100644 --- a/lib/src/models/algo_argon2.dart +++ b/lib/src/models/algo_argon2.dart @@ -30,6 +30,7 @@ class AlgoArgon2 implements Model { ); } + @override Map toMap() { return { "type": type, diff --git a/lib/src/models/algo_bcrypt.dart b/lib/src/models/algo_bcrypt.dart index 4e901476..9909265e 100644 --- a/lib/src/models/algo_bcrypt.dart +++ b/lib/src/models/algo_bcrypt.dart @@ -5,13 +5,20 @@ class AlgoBcrypt implements Model { /// Algo type. final String type; - AlgoBcrypt({required this.type}); + AlgoBcrypt({ + required this.type, + }); factory AlgoBcrypt.fromMap(Map map) { - return AlgoBcrypt(type: map['type'].toString()); + return AlgoBcrypt( + type: map['type'].toString(), + ); } + @override Map toMap() { - return {"type": type}; + return { + "type": type, + }; } } diff --git a/lib/src/models/algo_md5.dart b/lib/src/models/algo_md5.dart index 35c7b767..746fbd52 100644 --- a/lib/src/models/algo_md5.dart +++ b/lib/src/models/algo_md5.dart @@ -5,13 +5,20 @@ class AlgoMd5 implements Model { /// Algo type. final String type; - AlgoMd5({required this.type}); + AlgoMd5({ + required this.type, + }); factory AlgoMd5.fromMap(Map map) { - return AlgoMd5(type: map['type'].toString()); + return AlgoMd5( + type: map['type'].toString(), + ); } + @override Map toMap() { - return {"type": type}; + return { + "type": type, + }; } } diff --git a/lib/src/models/algo_phpass.dart b/lib/src/models/algo_phpass.dart index 7d27adba..cab45e49 100644 --- a/lib/src/models/algo_phpass.dart +++ b/lib/src/models/algo_phpass.dart @@ -5,13 +5,20 @@ class AlgoPhpass implements Model { /// Algo type. final String type; - AlgoPhpass({required this.type}); + AlgoPhpass({ + required this.type, + }); factory AlgoPhpass.fromMap(Map map) { - return AlgoPhpass(type: map['type'].toString()); + return AlgoPhpass( + type: map['type'].toString(), + ); } + @override Map toMap() { - return {"type": type}; + return { + "type": type, + }; } } diff --git a/lib/src/models/algo_scrypt.dart b/lib/src/models/algo_scrypt.dart index fec6f65a..a1648843 100644 --- a/lib/src/models/algo_scrypt.dart +++ b/lib/src/models/algo_scrypt.dart @@ -35,6 +35,7 @@ class AlgoScrypt implements Model { ); } + @override Map toMap() { return { "type": type, diff --git a/lib/src/models/algo_scrypt_modified.dart b/lib/src/models/algo_scrypt_modified.dart index 0e80700f..33ef4a6f 100644 --- a/lib/src/models/algo_scrypt_modified.dart +++ b/lib/src/models/algo_scrypt_modified.dart @@ -30,6 +30,7 @@ class AlgoScryptModified implements Model { ); } + @override Map toMap() { return { "type": type, diff --git a/lib/src/models/algo_sha.dart b/lib/src/models/algo_sha.dart index bae6618f..4984df75 100644 --- a/lib/src/models/algo_sha.dart +++ b/lib/src/models/algo_sha.dart @@ -5,13 +5,20 @@ class AlgoSha implements Model { /// Algo type. final String type; - AlgoSha({required this.type}); + AlgoSha({ + required this.type, + }); factory AlgoSha.fromMap(Map map) { - return AlgoSha(type: map['type'].toString()); + return AlgoSha( + type: map['type'].toString(), + ); } + @override Map toMap() { - return {"type": type}; + return { + "type": type, + }; } } diff --git a/lib/src/models/continent.dart b/lib/src/models/continent.dart index 7318b7ad..ec3c41be 100644 --- a/lib/src/models/continent.dart +++ b/lib/src/models/continent.dart @@ -8,7 +8,10 @@ class Continent implements Model { /// 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( @@ -17,7 +20,11 @@ class Continent implements Model { ); } + @override Map toMap() { - return {"name": name, "code": code}; + return { + "name": name, + "code": code, + }; } } diff --git a/lib/src/models/continent_list.dart b/lib/src/models/continent_list.dart index ec2c0755..df28f04b 100644 --- a/lib/src/models/continent_list.dart +++ b/lib/src/models/continent_list.dart @@ -8,17 +8,20 @@ class ContinentList implements Model { /// 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)), - ), + map['continents'].map((p) => Continent.fromMap(p))), ); } + @override Map toMap() { return { "total": total, diff --git a/lib/src/models/country.dart b/lib/src/models/country.dart index c52b50f2..3bcbb76d 100644 --- a/lib/src/models/country.dart +++ b/lib/src/models/country.dart @@ -8,13 +8,23 @@ class Country implements Model { /// 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()); + return Country( + name: map['name'].toString(), + code: map['code'].toString(), + ); } + @override Map toMap() { - return {"name": name, "code": code}; + return { + "name": name, + "code": code, + }; } } diff --git a/lib/src/models/country_list.dart b/lib/src/models/country_list.dart index 65e13be3..79cb1256 100644 --- a/lib/src/models/country_list.dart +++ b/lib/src/models/country_list.dart @@ -8,17 +8,20 @@ class CountryList implements Model { /// 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)), - ), + countries: + List.from(map['countries'].map((p) => Country.fromMap(p))), ); } + @override Map toMap() { return { "total": total, diff --git a/lib/src/models/currency.dart b/lib/src/models/currency.dart index 27eef0c1..f2b18093 100644 --- a/lib/src/models/currency.dart +++ b/lib/src/models/currency.dart @@ -45,6 +45,7 @@ class Currency implements Model { ); } + @override Map toMap() { return { "symbol": symbol, diff --git a/lib/src/models/currency_list.dart b/lib/src/models/currency_list.dart index 7a957f1a..6c39ae2e 100644 --- a/lib/src/models/currency_list.dart +++ b/lib/src/models/currency_list.dart @@ -8,17 +8,20 @@ class CurrencyList implements Model { /// 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)), - ), + map['currencies'].map((p) => Currency.fromMap(p))), ); } + @override Map toMap() { return { "total": total, diff --git a/lib/src/models/document.dart b/lib/src/models/document.dart index 06733467..84790f50 100644 --- a/lib/src/models/document.dart +++ b/lib/src/models/document.dart @@ -49,6 +49,7 @@ class Document implements Model { ); } + @override Map toMap() { return { "\$id": $id, diff --git a/lib/src/models/document_list.dart b/lib/src/models/document_list.dart index 4065e17b..76a07309 100644 --- a/lib/src/models/document_list.dart +++ b/lib/src/models/document_list.dart @@ -8,17 +8,20 @@ class DocumentList implements Model { /// 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)), - ), + documents: + List.from(map['documents'].map((p) => Document.fromMap(p))), ); } + @override Map toMap() { return { "total": total, diff --git a/lib/src/models/execution.dart b/lib/src/models/execution.dart index 4b4830eb..3629e1d6 100644 --- a/lib/src/models/execution.dart +++ b/lib/src/models/execution.dart @@ -23,7 +23,7 @@ class Execution implements Model { /// 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`, or `failed`. + /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, `failed`, or `scheduled`. final enums.ExecutionStatus status; /// HTTP request method type. @@ -85,22 +85,18 @@ class Execution implements Model { $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'], - ), + 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)), - ), + map['requestHeaders'].map((p) => Headers.fromMap(p))), responseStatusCode: map['responseStatusCode'], responseBody: map['responseBody'].toString(), responseHeaders: List.from( - map['responseHeaders'].map((p) => Headers.fromMap(p)), - ), + map['responseHeaders'].map((p) => Headers.fromMap(p))), logs: map['logs'].toString(), errors: map['errors'].toString(), duration: map['duration'].toDouble(), @@ -108,6 +104,7 @@ class Execution implements Model { ); } + @override Map toMap() { return { "\$id": $id, diff --git a/lib/src/models/execution_list.dart b/lib/src/models/execution_list.dart index 4ed73943..63c2ad7e 100644 --- a/lib/src/models/execution_list.dart +++ b/lib/src/models/execution_list.dart @@ -8,17 +8,20 @@ class ExecutionList implements Model { /// 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)), - ), + map['executions'].map((p) => Execution.fromMap(p))), ); } + @override Map toMap() { return { "total": total, diff --git a/lib/src/models/file.dart b/lib/src/models/file.dart index a6a9fa46..2df0de41 100644 --- a/lib/src/models/file.dart +++ b/lib/src/models/file.dart @@ -65,6 +65,7 @@ class File implements Model { ); } + @override Map toMap() { return { "\$id": $id, diff --git a/lib/src/models/file_list.dart b/lib/src/models/file_list.dart index 63f49abc..1157554a 100644 --- a/lib/src/models/file_list.dart +++ b/lib/src/models/file_list.dart @@ -8,7 +8,10 @@ class FileList implements Model { /// 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( @@ -17,7 +20,11 @@ class FileList implements Model { ); } + @override Map toMap() { - return {"total": total, "files": files.map((p) => p.toMap()).toList()}; + return { + "total": total, + "files": files.map((p) => p.toMap()).toList(), + }; } } diff --git a/lib/src/models/headers.dart b/lib/src/models/headers.dart index 463cf696..fa054420 100644 --- a/lib/src/models/headers.dart +++ b/lib/src/models/headers.dart @@ -8,7 +8,10 @@ class Headers implements Model { /// 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( @@ -17,7 +20,11 @@ class Headers implements Model { ); } + @override Map toMap() { - return {"name": name, "value": value}; + return { + "name": name, + "value": value, + }; } } diff --git a/lib/src/models/identity.dart b/lib/src/models/identity.dart index 807bdfd0..cc659043 100644 --- a/lib/src/models/identity.dart +++ b/lib/src/models/identity.dart @@ -60,6 +60,7 @@ class Identity implements Model { ); } + @override Map toMap() { return { "\$id": $id, diff --git a/lib/src/models/identity_list.dart b/lib/src/models/identity_list.dart index b4c63f7d..a5d39ea0 100644 --- a/lib/src/models/identity_list.dart +++ b/lib/src/models/identity_list.dart @@ -8,17 +8,20 @@ class IdentityList implements Model { /// 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)), - ), + map['identities'].map((p) => Identity.fromMap(p))), ); } + @override Map toMap() { return { "total": total, diff --git a/lib/src/models/jwt.dart b/lib/src/models/jwt.dart index 490a1824..cda66c70 100644 --- a/lib/src/models/jwt.dart +++ b/lib/src/models/jwt.dart @@ -5,13 +5,20 @@ class Jwt implements Model { /// 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()); + return Jwt( + jwt: map['jwt'].toString(), + ); } + @override Map toMap() { - return {"jwt": jwt}; + return { + "jwt": jwt, + }; } } diff --git a/lib/src/models/language.dart b/lib/src/models/language.dart index 9c45adb1..87dc3606 100644 --- a/lib/src/models/language.dart +++ b/lib/src/models/language.dart @@ -11,7 +11,11 @@ class Language implements Model { /// 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( @@ -21,7 +25,12 @@ class Language implements Model { ); } + @override Map toMap() { - return {"name": name, "code": code, "nativeName": nativeName}; + return { + "name": name, + "code": code, + "nativeName": nativeName, + }; } } diff --git a/lib/src/models/language_list.dart b/lib/src/models/language_list.dart index 2e65839e..6198d61e 100644 --- a/lib/src/models/language_list.dart +++ b/lib/src/models/language_list.dart @@ -8,17 +8,20 @@ class LanguageList implements Model { /// 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)), - ), + languages: + List.from(map['languages'].map((p) => Language.fromMap(p))), ); } + @override Map toMap() { return { "total": total, diff --git a/lib/src/models/locale.dart b/lib/src/models/locale.dart index 084475bf..54dd0c29 100644 --- a/lib/src/models/locale.dart +++ b/lib/src/models/locale.dart @@ -45,6 +45,7 @@ class Locale implements Model { ); } + @override Map toMap() { return { "ip": ip, diff --git a/lib/src/models/locale_code.dart b/lib/src/models/locale_code.dart index cd5a1155..21405aff 100644 --- a/lib/src/models/locale_code.dart +++ b/lib/src/models/locale_code.dart @@ -8,7 +8,10 @@ class LocaleCode implements Model { /// 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( @@ -17,7 +20,11 @@ class LocaleCode implements Model { ); } + @override Map toMap() { - return {"code": code, "name": name}; + return { + "code": code, + "name": name, + }; } } diff --git a/lib/src/models/locale_code_list.dart b/lib/src/models/locale_code_list.dart index be6ddb1f..202355a4 100644 --- a/lib/src/models/locale_code_list.dart +++ b/lib/src/models/locale_code_list.dart @@ -8,17 +8,20 @@ class LocaleCodeList implements Model { /// 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)), - ), + map['localeCodes'].map((p) => LocaleCode.fromMap(p))), ); } + @override Map toMap() { return { "total": total, diff --git a/lib/src/models/log.dart b/lib/src/models/log.dart index 7fb3f364..de0d83b3 100644 --- a/lib/src/models/log.dart +++ b/lib/src/models/log.dart @@ -115,6 +115,7 @@ class Log implements Model { ); } + @override Map toMap() { return { "event": event, diff --git a/lib/src/models/log_list.dart b/lib/src/models/log_list.dart index 22273a8c..3494b111 100644 --- a/lib/src/models/log_list.dart +++ b/lib/src/models/log_list.dart @@ -8,7 +8,10 @@ class LogList implements Model { /// 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( @@ -17,7 +20,11 @@ class LogList implements Model { ); } + @override Map toMap() { - return {"total": total, "logs": logs.map((p) => p.toMap()).toList()}; + return { + "total": total, + "logs": logs.map((p) => p.toMap()).toList(), + }; } } diff --git a/lib/src/models/membership.dart b/lib/src/models/membership.dart index 8ee142ad..87c1755b 100644 --- a/lib/src/models/membership.dart +++ b/lib/src/models/membership.dart @@ -75,6 +75,7 @@ class Membership implements Model { ); } + @override Map toMap() { return { "\$id": $id, diff --git a/lib/src/models/membership_list.dart b/lib/src/models/membership_list.dart index a4d39dca..cc664c9f 100644 --- a/lib/src/models/membership_list.dart +++ b/lib/src/models/membership_list.dart @@ -8,17 +8,20 @@ class MembershipList implements Model { /// 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)), - ), + map['memberships'].map((p) => Membership.fromMap(p))), ); } + @override Map toMap() { return { "total": total, diff --git a/lib/src/models/mfa_challenge.dart b/lib/src/models/mfa_challenge.dart index 96bf3c65..fa385541 100644 --- a/lib/src/models/mfa_challenge.dart +++ b/lib/src/models/mfa_challenge.dart @@ -30,6 +30,7 @@ class MfaChallenge implements Model { ); } + @override Map toMap() { return { "\$id": $id, diff --git a/lib/src/models/mfa_factors.dart b/lib/src/models/mfa_factors.dart index c930a23e..2777de7f 100644 --- a/lib/src/models/mfa_factors.dart +++ b/lib/src/models/mfa_factors.dart @@ -30,6 +30,7 @@ class MfaFactors implements Model { ); } + @override Map toMap() { return { "totp": totp, diff --git a/lib/src/models/mfa_recovery_codes.dart b/lib/src/models/mfa_recovery_codes.dart index 63411988..864a5db8 100644 --- a/lib/src/models/mfa_recovery_codes.dart +++ b/lib/src/models/mfa_recovery_codes.dart @@ -5,7 +5,9 @@ class MfaRecoveryCodes implements Model { /// Recovery codes. final List recoveryCodes; - MfaRecoveryCodes({required this.recoveryCodes}); + MfaRecoveryCodes({ + required this.recoveryCodes, + }); factory MfaRecoveryCodes.fromMap(Map map) { return MfaRecoveryCodes( @@ -13,7 +15,10 @@ class MfaRecoveryCodes implements Model { ); } + @override Map toMap() { - return {"recoveryCodes": recoveryCodes}; + return { + "recoveryCodes": recoveryCodes, + }; } } diff --git a/lib/src/models/mfa_type.dart b/lib/src/models/mfa_type.dart index fa57cb8b..fe5327fc 100644 --- a/lib/src/models/mfa_type.dart +++ b/lib/src/models/mfa_type.dart @@ -8,7 +8,10 @@ class MfaType implements Model { /// 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( @@ -17,7 +20,11 @@ class MfaType implements Model { ); } + @override Map toMap() { - return {"secret": secret, "uri": uri}; + return { + "secret": secret, + "uri": uri, + }; } } diff --git a/lib/src/models/phone.dart b/lib/src/models/phone.dart index 40f7bcd2..60e2abd9 100644 --- a/lib/src/models/phone.dart +++ b/lib/src/models/phone.dart @@ -25,6 +25,7 @@ class Phone implements Model { ); } + @override Map toMap() { return { "code": code, diff --git a/lib/src/models/phone_list.dart b/lib/src/models/phone_list.dart index 879edbc4..1a197fc7 100644 --- a/lib/src/models/phone_list.dart +++ b/lib/src/models/phone_list.dart @@ -8,7 +8,10 @@ class PhoneList implements Model { /// 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( @@ -17,7 +20,11 @@ class PhoneList implements Model { ); } + @override Map toMap() { - return {"total": total, "phones": phones.map((p) => p.toMap()).toList()}; + 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 777f5925..3ca04118 100644 --- a/lib/src/models/preferences.dart +++ b/lib/src/models/preferences.dart @@ -4,14 +4,21 @@ part of '../../models.dart'; class Preferences implements Model { final Map data; - Preferences({required this.data}); + Preferences({ + required this.data, + }); factory Preferences.fromMap(Map map) { - return Preferences(data: map["data"] ?? map); + return Preferences( + data: map["data"] ?? map, + ); } + @override Map toMap() { - return {"data": data}; + return { + "data": data, + }; } T convertTo(T Function(Map) fromJson) => fromJson(data); diff --git a/lib/src/models/row.dart b/lib/src/models/row.dart index 6dfddd27..28a88963 100644 --- a/lib/src/models/row.dart +++ b/lib/src/models/row.dart @@ -49,6 +49,7 @@ class Row implements Model { ); } + @override Map toMap() { return { "\$id": $id, diff --git a/lib/src/models/row_list.dart b/lib/src/models/row_list.dart index 01f046c6..5023c633 100644 --- a/lib/src/models/row_list.dart +++ b/lib/src/models/row_list.dart @@ -8,7 +8,10 @@ class RowList implements Model { /// 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( @@ -17,8 +20,12 @@ class RowList implements Model { ); } + @override Map toMap() { - return {"total": total, "rows": rows.map((p) => p.toMap()).toList()}; + return { + "total": total, + "rows": rows.map((p) => p.toMap()).toList(), + }; } List convertTo(T Function(Map) fromJson) => diff --git a/lib/src/models/session.dart b/lib/src/models/session.dart index d2fe4f64..92e4034e 100644 --- a/lib/src/models/session.dart +++ b/lib/src/models/session.dart @@ -155,6 +155,7 @@ class Session implements Model { ); } + @override Map toMap() { return { "\$id": $id, diff --git a/lib/src/models/session_list.dart b/lib/src/models/session_list.dart index e9c478af..4ea12394 100644 --- a/lib/src/models/session_list.dart +++ b/lib/src/models/session_list.dart @@ -8,17 +8,20 @@ class SessionList implements Model { /// 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)), - ), + sessions: + List.from(map['sessions'].map((p) => Session.fromMap(p))), ); } + @override Map toMap() { return { "total": total, diff --git a/lib/src/models/subscriber.dart b/lib/src/models/subscriber.dart index 0c926297..450aafd1 100644 --- a/lib/src/models/subscriber.dart +++ b/lib/src/models/subscriber.dart @@ -55,6 +55,7 @@ class Subscriber implements Model { ); } + @override Map toMap() { return { "\$id": $id, diff --git a/lib/src/models/target.dart b/lib/src/models/target.dart index 4be8b545..c2e8c4dc 100644 --- a/lib/src/models/target.dart +++ b/lib/src/models/target.dart @@ -55,6 +55,7 @@ class Target implements Model { ); } + @override Map toMap() { return { "\$id": $id, diff --git a/lib/src/models/team.dart b/lib/src/models/team.dart index 43df33a8..91b888b9 100644 --- a/lib/src/models/team.dart +++ b/lib/src/models/team.dart @@ -40,6 +40,7 @@ class Team implements Model { ); } + @override Map toMap() { return { "\$id": $id, diff --git a/lib/src/models/team_list.dart b/lib/src/models/team_list.dart index a3994c06..e8f1c621 100644 --- a/lib/src/models/team_list.dart +++ b/lib/src/models/team_list.dart @@ -8,7 +8,10 @@ class TeamList implements Model { /// 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( @@ -17,7 +20,11 @@ class TeamList implements Model { ); } + @override Map toMap() { - return {"total": total, "teams": teams.map((p) => p.toMap()).toList()}; + return { + "total": total, + "teams": teams.map((p) => p.toMap()).toList(), + }; } } diff --git a/lib/src/models/token.dart b/lib/src/models/token.dart index 35115467..b5ea87c8 100644 --- a/lib/src/models/token.dart +++ b/lib/src/models/token.dart @@ -40,6 +40,7 @@ class Token implements Model { ); } + @override Map toMap() { return { "\$id": $id, diff --git a/lib/src/models/transaction.dart b/lib/src/models/transaction.dart index fd71d50d..b0606dd8 100644 --- a/lib/src/models/transaction.dart +++ b/lib/src/models/transaction.dart @@ -40,6 +40,7 @@ class Transaction implements Model { ); } + @override Map toMap() { return { "\$id": $id, diff --git a/lib/src/models/transaction_list.dart b/lib/src/models/transaction_list.dart index 146e836e..7f321175 100644 --- a/lib/src/models/transaction_list.dart +++ b/lib/src/models/transaction_list.dart @@ -8,17 +8,20 @@ class TransactionList implements Model { /// 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)), - ), + map['transactions'].map((p) => Transaction.fromMap(p))), ); } + @override Map toMap() { return { "total": total, diff --git a/lib/src/models/user.dart b/lib/src/models/user.dart index 50bfb3ce..1c444e7c 100644 --- a/lib/src/models/user.dart +++ b/lib/src/models/user.dart @@ -105,6 +105,7 @@ class User implements Model { ); } + @override Map toMap() { return { "\$id": $id, diff --git a/lib/src/realtime_io.dart b/lib/src/realtime_io.dart index e54546b5..5b3454fa 100644 --- a/lib/src/realtime_io.dart +++ b/lib/src/realtime_io.dart @@ -32,12 +32,10 @@ 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), - ); - return _websok; + final websok = IOWebSocketChannel((client as ClientIO).selfSigned + ? await _connectForSelfSignedCert(uri, headers) + : await WebSocket.connect(uri.toString(), headers: headers)); + return websok; } /// Subscribe @@ -52,18 +50,16 @@ class RealtimeIO extends RealtimeBase with RealtimeMixin { // https://github.com/jonataslaw/getsocket/blob/f25b3a264d8cc6f82458c949b86d286cd0343792/lib/src/io.dart#L104 // and from official dart sdk websocket_impl.dart connect method Future _connectForSelfSignedCert( - Uri uri, - Map headers, - ) async { + Uri uri, Map headers) async { try { var r = Random(); var key = base64.encode(List.generate(16, (_) => r.nextInt(255))); var client = HttpClient(context: SecurityContext()); client.badCertificateCallback = (X509Certificate cert, String host, int port) { - debugPrint('AppwriteRealtime: Allow self-signed certificate'); - return true; - }; + debugPrint('AppwriteRealtime: Allow self-signed certificate'); + return true; + }; uri = Uri( scheme: uri.scheme == 'wss' ? 'https' : 'http', diff --git a/lib/src/realtime_mixin.dart b/lib/src/realtime_mixin.dart index fc8817c2..555bae22 100644 --- a/lib/src/realtime_mixin.dart +++ b/lib/src/realtime_mixin.dart @@ -21,7 +21,7 @@ mixin RealtimeMixin { late WebSocketFactory getWebSocket; GetFallbackCookie? getFallbackCookie; int? get closeCode => _websok?.closeCode; - Map _subscriptions = {}; + final Map _subscriptions = {}; bool _reconnect = true; int _retries = 0; StreamSubscription? _websocketSubscription; @@ -51,7 +51,7 @@ mixin RealtimeMixin { _heartbeatTimer = null; } - _createSocket() async { + Future _createSocket() async { if (_creatingSocket || _channels.isEmpty) return; _creatingSocket = true; final uri = _prepareUri(); @@ -70,57 +70,53 @@ mixin RealtimeMixin { } debugPrint('subscription: $_lastUrl'); _retries = 0; - _websocketSubscription = _websok?.stream.listen( - (response) { - final data = RealtimeResponse.fromJson(response); - switch (data.type) { - case 'error': - handleError(data); - break; - case 'connected': - // channels, user? - final message = RealtimeResponseConnected.fromMap(data.data); - if (message.user.isEmpty) { - // send fallback cookie if exists - final cookie = getFallbackCookie?.call(); - if (cookie != null) { - _websok?.sink.add( - jsonEncode({ - "type": "authentication", - "data": {"session": cookie}, - }), - ); - } + _websocketSubscription = _websok?.stream.listen((response) { + final data = RealtimeResponse.fromJson(response); + switch (data.type) { + case 'error': + handleError(data); + break; + case 'connected': + // channels, user? + final message = RealtimeResponseConnected.fromMap(data.data); + if (message.user.isEmpty) { + // send fallback cookie if exists + final cookie = getFallbackCookie?.call(); + if (cookie != null) { + _websok?.sink.add(jsonEncode({ + "type": "authentication", + "data": { + "session": cookie, + }, + })); } - _startHeartbeat(); // Start heartbeat after successful connection - break; - case 'pong': - debugPrint('Received heartbeat response from realtime server'); - break; - case 'event': - final message = RealtimeMessage.fromMap(data.data); - for (var subscription in _subscriptions.values) { - for (var channel in message.channels) { - if (subscription.channels.contains(channel)) { - subscription.controller.add(message); - } + } + _startHeartbeat(); // Start heartbeat after successful connection + break; + case 'pong': + debugPrint('Received heartbeat response from realtime server'); + break; + case 'event': + final message = RealtimeMessage.fromMap(data.data); + for (var subscription in _subscriptions.values) { + for (var channel in message.channels) { + if (subscription.channels.contains(channel)) { + subscription.controller.add(message); } } - break; - } - }, - onDone: () { - _stopHeartbeat(); - _retry(); - }, - onError: (err, stack) { - _stopHeartbeat(); - for (var subscription in _subscriptions.values) { - subscription.controller.addError(err, stack); - } - _retry(); - }, - ); + } + break; + } + }, onDone: () { + _stopHeartbeat(); + _retry(); + }, onError: (err, stack) { + _stopHeartbeat(); + for (var subscription in _subscriptions.values) { + subscription.controller.addError(err, stack); + } + _retry(); + }); } catch (e) { if (e is AppwriteException) { rethrow; @@ -146,17 +142,16 @@ mixin RealtimeMixin { return _retries < 5 ? 1 : _retries < 15 - ? 5 - : _retries < 100 - ? 10 - : 60; + ? 5 + : _retries < 100 + ? 10 + : 60; } Uri _prepareUri() { if (client.endPointRealtime == null) { throw AppwriteException( - "Please set endPointRealtime to connect to realtime server", - ); + "Please set endPointRealtime to connect to realtime server"); } var uri = Uri.parse(client.endPointRealtime!); return Uri( @@ -167,7 +162,7 @@ mixin RealtimeMixin { "project": client.config['project'], "channels[]": _channels.toList(), }, - path: uri.path + "/realtime", + path: "${uri.path}/realtime", ); } @@ -177,29 +172,27 @@ mixin RealtimeMixin { Future.delayed(Duration.zero, () => _createSocket()); int id = DateTime.now().microsecondsSinceEpoch; RealtimeSubscription subscription = RealtimeSubscription( - controller: controller, - channels: channels, - close: () async { - _subscriptions.remove(id); - controller.close(); - _cleanup(channels); + controller: controller, + channels: channels, + close: () async { + _subscriptions.remove(id); + controller.close(); + _cleanup(channels); - if (_channels.isNotEmpty) { - await Future.delayed(Duration.zero, () => _createSocket()); - } else { - await _closeConnection(); - } - }, - ); + if (_channels.isNotEmpty) { + await Future.delayed(Duration.zero, () => _createSocket()); + } else { + await _closeConnection(); + } + }); _subscriptions[id] = subscription; return subscription; } void _cleanup(List channels) { for (var channel in channels) { - bool found = _subscriptions.values.any( - (subscription) => subscription.channels.contains(channel), - ); + bool found = _subscriptions.values + .any((subscription) => subscription.channels.contains(channel)); if (!found) { _channels.remove(channel); } diff --git a/lib/src/realtime_response.dart b/lib/src/realtime_response.dart index e444cd0b..b0356111 100644 --- a/lib/src/realtime_response.dart +++ b/lib/src/realtime_response.dart @@ -4,14 +4,26 @@ 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) { 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 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/pubspec.yaml b/pubspec.yaml index 82e0253a..b50467bd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: appwrite -version: 20.2.1 +version: 20.2.2 description: Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API homepage: https://appwrite.io repository: https://github.com/appwrite/sdk-for-flutter @@ -19,10 +19,10 @@ dependencies: flutter: sdk: flutter cookie_jar: ^4.0.8 - device_info_plus: ^11.5.0 + device_info_plus: '>=11.5.0 <13.0.0' flutter_web_auth_2: ^4.1.0 http: '>=0.13.6 <2.0.0' - package_info_plus: ^8.0.2 + package_info_plus: '>=8.0.2 <10.0.0' path_provider: ^2.1.4 web_socket_channel: ^3.0.1 web: ^1.0.0 diff --git a/test/query_test.dart b/test/query_test.dart index f6302ab5..d7f2f5aa 100644 --- a/test/query_test.dart +++ b/test/query_test.dart @@ -314,4 +314,3 @@ void main() { expect(query['method'], 'updatedBetween'); }); } - diff --git a/test/services/account_test.dart b/test/services/account_test.dart index 3276e3e3..c91bab89 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,1478 +40,1352 @@ 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: '', - ); - 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': '1', - 'uri': '1',}; - - - 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': '1', - 'uri': '1',}; - - - 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)); + group('Account test', () { + late MockClient client; + late Account account; + setUp(() { + client = MockClient(); + account = Account(client); + }); - final response = await account.getMFARecoveryCodes( - ); - 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': '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: '', + ); + expect(response, isA()); + }); - test('test method createMfaRecoveryCodes()', () async { - final Map data = { - 'recoveryCodes': [],}; + 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.post, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await account.listIdentities(); + expect(response, isA()); + }); - final response = await account.createMfaRecoveryCodes( - ); - expect(response, isA()); + test('test method deleteIdentity()', () async { + final data = ''; - }); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - test('test method createMFARecoveryCodes()', () async { - final Map data = { - 'recoveryCodes': [],}; + 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)); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + final response = await account.createJWT(); + expect(response, isA()); + }); - final response = await account.createMFARecoveryCodes( - ); - 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 updateMfaRecoveryCodes()', () async { - final Map data = { - 'recoveryCodes': [],}; + 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()); + }); - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + test('test method createMfaAuthenticator()', () async { + final Map data = { + 'secret': '1', + 'uri': '1', + }; + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - final response = await account.updateMfaRecoveryCodes( - ); - expect(response, isA()); + final response = await account.createMfaAuthenticator( + type: enums.AuthenticatorType.totp, + ); + expect(response, isA()); + }); - }); + test('test method createMFAAuthenticator()', () async { + final Map data = { + 'secret': '1', + 'uri': '1', + }; - test('test method updateMFARecoveryCodes()', () async { - final Map data = { - 'recoveryCodes': [],}; + 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.patch, - )).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 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.updateMFARecoveryCodes( - ); - expect(response, isA()); + test('test method deleteMfaAuthenticator()', () async { + final data = ''; - }); + when(client.call( + HttpMethod.delete, + )).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': '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.deleteMfaAuthenticator( + type: enums.AuthenticatorType.totp, + ); + }); + test('test method deleteMFAAuthenticator()', () async { + final data = ''; - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + final response = await account.deleteMFAAuthenticator( + type: enums.AuthenticatorType.totp, + ); + }); - final response = await account.updateName( - name: '', - ); - 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 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 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)); + 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()); + }); - 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()); - - }); - - 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: '', - ); - 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( - Uri(), - )).thenAnswer((_) async => 'done'); - - - final response = await account.createOAuth2Session( - provider: enums.OAuthProvider.amazon, - ); - }); - - 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,}; - + test('test method listMfaFactors()', () async { + final Map data = { + 'totp': true, + 'phone': true, + 'email': true, + 'recoveryCode': true, + }; - when(client.call( - HttpMethod.put, - )).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.updatePushTarget( - targetId: '', - identifier: '', - ); - 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 deletePushTarget()', () async { - final data = ''; + final response = await account.listMFAFactors(); + expect(response, isA()); + }); - when(client.call( - HttpMethod.delete, - )).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.deletePushTarget( - targetId: '', - ); - }); + final response = await account.getMfaRecoveryCodes(); + expect(response, isA()); + }); - 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',}; + 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 createMfaRecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [], + }; - final response = await account.createEmailToken( - userId: '', - email: 'email@example.com', - ); - expect(response, isA()); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await account.createMfaRecoveryCodes(); + 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',}; + test('test method createMFARecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [], + }; + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - 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': [], + }; - final response = await account.createMagicURLToken( - userId: '', - email: 'email@example.com', - ); - expect(response, isA()); + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await account.updateMfaRecoveryCodes(); + expect(response, isA()); + }); - test('test method createOAuth2Token()', () async { + test('test method updateMFARecoveryCodes()', () async { + final Map data = { + 'recoveryCodes': [], + }; - when(client.webAuth( - Uri(), - )).thenAnswer((_) async => 'done'); + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + final response = await account.updateMFARecoveryCodes(); + expect(response, isA()); + }); - final response = await account.createOAuth2Token( - provider: enums.OAuthProvider.amazon, - ); - }); + 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 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',}; + 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.createPhoneToken( - userId: '', - phone: '+12065550100', - ); - 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 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',}; + 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: '', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + 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.createEmailVerification( - url: 'https://example.com', - ); - expect(response, isA()); + final response = await account.listSessions(); + expect(response, isA()); + }); - }); + test('test method deleteSessions()', () async { + final 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.delete, + )).thenAnswer((_) async => Response(data: data)); + final response = await account.deleteSessions(); + }); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + 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()); + }); - final response = await account.createVerification( - url: 'https://example.com', - ); - 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( + Uri(), + )).thenAnswer((_) async => 'done'); - 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',}; + final response = await account.createOAuth2Session( + provider: enums.OAuthProvider.amazon, + ); + }); + 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()); + }); - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + 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()); + }); - final response = await account.updateEmailVerification( - userId: '', - secret: '', - ); - 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 = ''; - 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.delete, + )).thenAnswer((_) async => Response(data: data)); + final response = await account.deleteSession( + sessionId: '', + ); + }); - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: 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()); + }); + 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()); + }); - final response = await account.updateVerification( - userId: '', - secret: '', - ); - 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 = ''; - 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.delete, + )).thenAnswer((_) async => Response(data: data)); + final response = await account.deletePushTarget( + targetId: '', + ); + }); - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + 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()); + }); - final response = await account.createPhoneVerification( - ); - expect(response, isA()); + test('test method createOAuth2Token()', () async { + when(client.webAuth( + Uri(), + )).thenAnswer((_) async => 'done'); - }); + final response = await account.createOAuth2Token( + provider: enums.OAuthProvider.amazon, + ); + }); - 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',}; + 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()); }); -} \ No newline at end of file + }); +} diff --git a/test/services/avatars_test.dart b/test/services/avatars_test.dart index 0cd4b70d..01abe69c 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,116 +40,110 @@ 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()); - - }); + group('Avatars test', () { + late MockClient client; + late Avatars avatars; - test('test method getFavicon()', () 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()); - - }); + setUp(() { + client = MockClient(); + avatars = Avatars(client); + }); - test('test method getFlag()', () 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()); + }); - final response = await avatars.getFlag( - code: enums.Flag.afghanistan, - ); - expect(response, isA()); + test('test method getCreditCard()', () async { + final Uint8List data = Uint8List.fromList([]); - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method getImage()', () async {final Uint8List data = Uint8List.fromList([]); + final response = await avatars.getCreditCard( + code: enums.CreditCard.americanExpress, + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + test('test method getFavicon()', () 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()); + final response = await avatars.getFavicon( + url: 'https://example.com', + ); + expect(response, isA()); + }); - }); + test('test method getFlag()', () async { + final Uint8List data = Uint8List.fromList([]); - test('test method getInitials()', () 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.getFlag( + code: enums.Flag.afghanistan, + ); + expect(response, isA()); + }); + test('test method getImage()', () async { + final Uint8List data = Uint8List.fromList([]); - final response = await avatars.getInitials( - ); - expect(response, isA()); + 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 getQR()', () async {final Uint8List data = Uint8List.fromList([]); + test('test method getInitials()', () 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()); + }); - final response = await avatars.getQR( - text: '', - ); - 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()); }); -} \ No newline at end of file + }); +} diff --git a/test/services/databases_test.dart b/test/services/databases_test.dart index c05a994f..681fc1f1 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,324 +40,298 @@ 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': [],}; - - - 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': [],}; + group('Databases test', () { + late MockClient client; + late Databases databases; + setUp(() { + client = MockClient(); + databases = Databases(client); + }); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + 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.getDocument( - databaseId: '', - collectionId: '', - documentId: '', - ); - expect(response, isA()); + final response = await databases.listTransactions(); + 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': [],}; + 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()); + }); - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + 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 = ''; - final response = await databases.upsertDocument( - databaseId: '', - collectionId: '', - documentId: '', - data: {}, - ); - expect(response, isA()); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await databases.deleteTransaction( + transactionId: '', + ); + }); - 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': [],}; + 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.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)); - + 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()); + }); - 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)); + 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: '', + data: {}, + ); + expect(response, isA()); + }); - final response = await databases.decrementDocumentAttribute( - databaseId: '', - collectionId: '', - documentId: '', - attribute: '', - ); - 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 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)); + 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()); }); -} \ No newline at end of file + }); +} diff --git a/test/services/functions_test.dart b/test/services/functions_test.dart index 69b86785..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,104 +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()); }); -} \ No newline at end of file + }); +} diff --git a/test/services/graphql_test.dart b/test/services/graphql_test.dart index 1c096784..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,45 +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 = ''; - - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + group('Graphql test', () { + late MockClient client; + late Graphql graphql; + setUp(() { + client = MockClient(); + graphql = Graphql(client); + }); - final response = await graphql.query( - query: {}, - ); - }); + test('test method query()', () async { + final data = ''; - test('test method mutation()', () async { - 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: {}, + ); }); -} \ No newline at end of file + }); +} diff --git a/test/services/locale_test.dart b/test/services/locale_test.dart index ccdcb5d3..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,160 +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)); + 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()); + }); - final response = await locale.listCountriesEU( - ); - expect(response, isA()); + test('test method listCodes()', () async { + final Map data = { + 'total': 5, + 'localeCodes': [], + }; - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method listCountriesPhones()', () async { - final Map data = { - 'total': 5, - 'phones': [],}; + 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)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await locale.listContinents(); + expect(response, isA()); + }); - final response = await locale.listCountriesPhones( - ); - expect(response, isA()); + test('test method listCountries()', () async { + final Map data = { + 'total': 5, + 'countries': [], + }; - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - test('test method listCurrencies()', () async { - final Map data = { - 'total': 5, - 'currencies': [],}; + 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.listCurrencies( - ); - 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 listLanguages()', () async { - 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()); }); -} \ No newline at end of file + }); +} diff --git a/test/services/messaging_test.dart b/test/services/messaging_test.dart index ddb93457..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,69 +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; - final response = await messaging.createSubscriber( - topicId: '', - subscriberId: '', - targetId: '', - ); - expect(response, isA()); - - }); - - test('test method deleteSubscriber()', () async { - final data = ''; + setUp(() { + client = MockClient(); + messaging = Messaging(client); + }); - 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: '', + ); }); -} \ No newline at end of file + }); +} diff --git a/test/services/storage_test.dart b/test/services/storage_test.dart index 9d250109..19b0d334 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,185 +40,175 @@ 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, - 'chunksTotal': 17890, - 'chunksUploaded': 17890,}; - - - 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, - 'chunksTotal': 17890, - 'chunksUploaded': 17890,}; - - - 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, - 'chunksTotal': 17890, - 'chunksUploaded': 17890,}; - - - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); - + group('Storage test', () { + late MockClient client; + late Storage storage; - 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, + 'chunksTotal': 17890, + 'chunksUploaded': 17890, + }; + + 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, + 'chunksTotal': 17890, + 'chunksUploaded': 17890, + }; + + 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, + 'chunksTotal': 17890, + 'chunksUploaded': 17890, + }; + + 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()); }); -} \ No newline at end of file + }); +} diff --git a/test/services/tables_db_test.dart b/test/services/tables_db_test.dart index 61964d4c..822d85d5 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,323 +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)); - + group('TablesDB test', () { + late MockClient client; + late TablesDB tablesDB; - 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': [],}; + setUp(() { + client = MockClient(); + tablesDB = TablesDB(client); + }); + test('test method listTransactions()', () async { + final Map data = { + 'total': 5, + 'transactions': [], + }; - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + final response = await tablesDB.listTransactions(); + expect(response, isA()); + }); - final response = await tablesDB.upsertRow( - databaseId: '', - tableId: '', - rowId: '', - ); - 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 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': [],}; + 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.patch, - )).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + final response = await tablesDB.deleteTransaction( + transactionId: '', + ); + }); - 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)); - + 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.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': [],}; + 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()); + }); - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); - + 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.decrementRowColumn( - databaseId: '', - tableId: '', - rowId: '', - column: '', - ); - 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 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)); + 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()); }); -} \ No newline at end of file + }); +} diff --git a/test/services/teams_test.dart b/test/services/teams_test.dart index c2e5ff04..9a2eb930 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,305 +40,280 @@ 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)); - + group('Teams test', () { + late MockClient client; + late Teams teams; - 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()); - - }); + setUp(() { + client = MockClient(); + teams = Teams(client); + }); - 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', - '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, - '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', - '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, - 'roles': [],}; - - - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); - - - final response = await teams.getMembership( - teamId: '', - membershipId: '', - ); - expect(response, isA()); + test('test method list()', () async { + final Map data = { + 'total': 5, + 'teams': [], + }; - }); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - 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', - '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, - 'roles': [],}; + 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.patch, - )).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.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', - '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, - 'roles': [],}; + test('test method delete()', () 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 teams.delete( + teamId: '', + ); + }); + test('test method listMemberships()', () async { + final Map data = { + 'total': 5, + 'memberships': [], + }; - final response = await teams.updateMembershipStatus( - teamId: '', - membershipId: '', - userId: '', - secret: '', - ); - expect(response, isA()); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await teams.listMemberships( + teamId: '', + ); + expect(response, isA()); + }); - test('test method getPrefs()', () async { - final Map data = {}; + 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', + '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, + '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', + '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, + 'roles': [], + }; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + final response = await teams.getMembership( + teamId: '', + membershipId: '', + ); + expect(response, isA()); + }); - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + 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', + '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, + '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 = ''; - final response = await teams.getPrefs( - teamId: '', - ); - expect(response, isA()); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - }); + final response = await teams.deleteMembership( + teamId: '', + membershipId: '', + ); + }); - test('test method updatePrefs()', () async { - 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', + '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, + '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()); }); -} \ No newline at end of file + }); +} 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 be617cc6..fd46464b 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 08da5e9a..e6d6dae5 100644 --- a/test/src/models/file_test.dart +++ b/test/src/models/file_test.dart @@ -21,17 +21,17 @@ 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.chunksTotal, 17890); - expect(result.chunksUploaded, 17890); - }); + 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.chunksTotal, 17890); + expect(result.chunksUploaded, 17890); + }); }); } 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 7724b875..b328ad58 100644 --- a/test/src/models/log_test.dart +++ b/test/src/models/log_test.dart @@ -31,27 +31,27 @@ 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.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.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 32ba0f4e..2fee0d28 100644 --- a/test/src/models/membership_test.dart +++ b/test/src/models/membership_test.dart @@ -23,19 +23,19 @@ 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.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.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.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.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 dcee3fcb..fb964947 100644 --- a/test/src/models/mfa_type_test.dart +++ b/test/src/models/mfa_type_test.dart @@ -12,8 +12,8 @@ void main() { final map = model.toMap(); final result = MfaType.fromMap(map); - expect(result.secret, '1'); - expect(result.uri, '1'); - }); + expect(result.secret, '1'); + expect(result.uri, '1'); + }); }); } 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/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 4c525e1b..fed01ffa 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'); + }); }); }