diff --git a/CHANGELOG.md b/CHANGELOG.md index 7bd8b55b..e3ee6d03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## 25.2.0 + +* Added: Realtime connections now authenticate with the configured JWT. +* Added: Forwarded `impersonateUserId` on `avatars` and `storage` file requests. + ## 25.1.0 * Added: Email metadata fields to `User` (`emailCanonical`, `emailIsFree`, `emailIsDisposable`, `emailIsCorporate`, `emailIsCanonical`). diff --git a/README.md b/README.md index bc73e6c2..a4cf00a8 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Add this to your package's `pubspec.yaml` file: ```yml dependencies: - appwrite: ^25.1.0 + appwrite: ^25.2.0 ``` You can install packages from the command line: diff --git a/docs/examples/account/create.md b/docs/examples/account/create.md index d4bf5757..8343f628 100644 --- a/docs/examples/account/create.md +++ b/docs/examples/account/create.md @@ -10,7 +10,7 @@ Account account = Account(client); User result = await account.create( userId: '', email: 'email@example.com', - password: '', + password: 'password', name: '', // optional ); ``` diff --git a/docs/examples/account/update-password.md b/docs/examples/account/update-password.md index 46fa5a1d..c2604a9c 100644 --- a/docs/examples/account/update-password.md +++ b/docs/examples/account/update-password.md @@ -8,7 +8,7 @@ Client client = Client() Account account = Account(client); User result = await account.updatePassword( - password: '', - oldPassword: '', // optional + password: 'password', + oldPassword: 'password', // optional ); ``` diff --git a/docs/examples/account/update-recovery.md b/docs/examples/account/update-recovery.md index 87ff07bd..809aa044 100644 --- a/docs/examples/account/update-recovery.md +++ b/docs/examples/account/update-recovery.md @@ -10,6 +10,6 @@ Account account = Account(client); Token result = await account.updateRecovery( userId: '', secret: '', - password: '', + password: 'password', ); ``` diff --git a/lib/query.dart b/lib/query.dart index 1a41ba82..3693dce6 100644 --- a/lib/query.dart +++ b/lib/query.dart @@ -222,46 +222,34 @@ 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, - ]) => + String attribute, List values, num distance, + [bool meters = true]) => Query._('distanceEqual', attribute, [ - [values, distance, meters], + [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, - ]) => + String attribute, List values, num distance, + [bool meters = true]) => Query._('distanceNotEqual', attribute, [ - [values, distance, meters], + [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, - ]) => + String attribute, List values, num distance, + [bool meters = true]) => Query._('distanceGreaterThan', attribute, [ - [values, distance, meters], + [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, - ]) => + String attribute, List values, num distance, + [bool meters = true]) => Query._('distanceLessThan', attribute, [ - [values, distance, meters], + [values, distance, meters] ]).toString(); /// Filter resources where [attribute] intersects with the given geometry. diff --git a/lib/services/account.dart b/lib/services/account.dart index 391b0d63..48b60041 100644 --- a/lib/services/account.dart +++ b/lib/services/account.dart @@ -16,12 +16,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); } @@ -33,12 +29,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 { final String apiPath = '/account'; final Map apiParams = { @@ -54,12 +49,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); } @@ -72,10 +63,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 { final String apiPath = '/account/email'; final Map apiParams = { @@ -89,21 +78,15 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); } /// Get the list of identities for the currently logged in user. - Future listIdentities({ - List? queries, - bool? total, - }) async { + Future listIdentities( + {List? queries, bool? total}) async { final String apiPath = '/account/identities'; final Map apiParams = { @@ -116,22 +99,16 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.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 = {}; @@ -140,12 +117,8 @@ class Account extends Service { '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; } @@ -168,12 +141,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Jwt.fromMap(res.data); } @@ -193,12 +162,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.LogList.fromMap(res.data); } @@ -207,7 +172,9 @@ class Account extends Service { Future updateMFA({required bool mfa}) async { final String apiPath = '/account/mfa'; - final Map apiParams = {'mfa': mfa}; + final Map apiParams = { + 'mfa': mfa, + }; final Map apiHeaders = { 'X-Appwrite-Project': client.config['project'] ?? '', @@ -215,12 +182,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); } @@ -230,15 +193,11 @@ 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 = {}; @@ -248,12 +207,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.MfaType.fromMap(res.data); } @@ -262,13 +217,10 @@ 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 = {}; @@ -278,12 +230,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.MfaType.fromMap(res.data); } @@ -292,18 +240,15 @@ 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}; + 'This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead.') + Future updateMfaAuthenticator( + {required enums.AuthenticatorType type, required String otp}) async { + final String apiPath = + '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + + final Map apiParams = { + 'otp': otp, + }; final Map apiHeaders = { 'X-Appwrite-Project': client.config['project'] ?? '', @@ -311,12 +256,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); } @@ -324,16 +265,14 @@ 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, - ); + Future updateMFAAuthenticator( + {required enums.AuthenticatorType type, required String otp}) async { + final String apiPath = + '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); - final Map apiParams = {'otp': otp}; + final Map apiParams = { + 'otp': otp, + }; final Map apiHeaders = { 'X-Appwrite-Project': client.config['project'] ?? '', @@ -341,25 +280,18 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); } /// 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 = {}; @@ -368,22 +300,16 @@ class Account extends Service { '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 = {}; @@ -392,12 +318,8 @@ class Account extends Service { '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; } @@ -406,14 +328,14 @@ 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 { final String apiPath = '/account/mfa/challenges'; - final Map apiParams = {'factor': factor.value}; + final Map apiParams = { + 'factor': factor.value, + }; final Map apiHeaders = { 'X-Appwrite-Project': client.config['project'] ?? '', @@ -421,12 +343,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.MfaChallenge.fromMap(res.data); } @@ -434,12 +352,13 @@ 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 { final String apiPath = '/account/mfa/challenges'; - final Map apiParams = {'factor': factor.value}; + final Map apiParams = { + 'factor': factor.value, + }; final Map apiHeaders = { 'X-Appwrite-Project': client.config['project'] ?? '', @@ -447,12 +366,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.MfaChallenge.fromMap(res.data); } @@ -463,12 +378,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 { final String apiPath = '/account/mfa/challenges'; final Map apiParams = { @@ -482,12 +394,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Session.fromMap(res.data); } @@ -497,10 +405,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 { final String apiPath = '/account/mfa/challenges'; final Map apiParams = { @@ -514,20 +420,15 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Session.fromMap(res.data); } /// 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 { final String apiPath = '/account/mfa/factors'; @@ -538,12 +439,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.MfaFactors.fromMap(res.data); } @@ -559,12 +456,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.MfaFactors.fromMap(res.data); } @@ -574,8 +467,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 { final String apiPath = '/account/mfa/recovery-codes'; @@ -586,12 +478,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.MfaRecoveryCodes.fromMap(res.data); } @@ -610,12 +498,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.MfaRecoveryCodes.fromMap(res.data); } @@ -626,8 +510,7 @@ 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 { final String apiPath = '/account/mfa/recovery-codes'; @@ -639,12 +522,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.MfaRecoveryCodes.fromMap(res.data); } @@ -665,12 +544,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.MfaRecoveryCodes.fromMap(res.data); } @@ -680,8 +555,7 @@ 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 { final String apiPath = '/account/mfa/recovery-codes'; @@ -693,12 +567,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.MfaRecoveryCodes.fromMap(res.data); } @@ -718,12 +588,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.MfaRecoveryCodes.fromMap(res.data); } @@ -732,7 +598,9 @@ class Account extends Service { Future updateName({required String name}) async { final String apiPath = '/account/name'; - final Map apiParams = {'name': name}; + final Map apiParams = { + 'name': name, + }; final Map apiHeaders = { 'X-Appwrite-Project': client.config['project'] ?? '', @@ -740,12 +608,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); } @@ -753,10 +617,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 { final String apiPath = '/account/password'; final Map apiParams = { @@ -770,12 +632,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); } @@ -785,10 +643,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 { final String apiPath = '/account/phone'; final Map apiParams = { @@ -802,12 +658,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); } @@ -823,12 +675,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Preferences.fromMap(res.data); } @@ -839,7 +687,9 @@ class Account extends Service { Future updatePrefs({required Map prefs}) async { final String apiPath = '/account/prefs'; - final Map apiParams = {'prefs': prefs}; + final Map apiParams = { + 'prefs': prefs, + }; final Map apiHeaders = { 'X-Appwrite-Project': client.config['project'] ?? '', @@ -847,12 +697,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); } @@ -865,13 +711,14 @@ class Account extends Service { /// /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#updateRecovery) /// endpoint to complete the process. The verification link sent to the user's /// email address is valid for 1 hour. - Future createRecovery({ - required String email, - required String url, - }) async { + Future createRecovery( + {required String email, required String url}) async { final String apiPath = '/account/recovery'; - final Map apiParams = {'email': email, 'url': url}; + final Map apiParams = { + 'email': email, + 'url': url, + }; final Map apiHeaders = { 'X-Appwrite-Project': client.config['project'] ?? '', @@ -879,12 +726,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Token.fromMap(res.data); } @@ -899,11 +742,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 { final String apiPath = '/account/recovery'; final Map apiParams = { @@ -918,12 +760,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Token.fromMap(res.data); } @@ -940,12 +778,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.SessionList.fromMap(res.data); } @@ -962,12 +796,8 @@ class Account extends Service { '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; } @@ -990,12 +820,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Session.fromMap(res.data); } @@ -1006,10 +832,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 { final String apiPath = '/account/sessions/email'; final Map apiParams = { @@ -1023,12 +847,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Session.fromMap(res.data); } @@ -1037,15 +857,15 @@ 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 { final String apiPath = '/account/sessions/magic-url'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; final Map apiHeaders = { 'X-Appwrite-Project': client.config['project'] ?? '', @@ -1053,12 +873,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Session.fromMap(res.data); } @@ -1079,16 +895,13 @@ 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 = { if (success != null) 'success': success, @@ -1103,8 +916,7 @@ 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)}'); @@ -1113,12 +925,11 @@ class Account extends Service { 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); } @@ -1127,15 +938,15 @@ 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 { final String apiPath = '/account/sessions/phone'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; final Map apiHeaders = { 'X-Appwrite-Project': client.config['project'] ?? '', @@ -1143,12 +954,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Session.fromMap(res.data); } @@ -1156,13 +963,14 @@ 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 { final String apiPath = '/account/sessions/token'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; final Map apiHeaders = { 'X-Appwrite-Project': client.config['project'] ?? '', @@ -1170,12 +978,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Session.fromMap(res.data); } @@ -1183,10 +987,8 @@ 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 = {}; @@ -1195,12 +997,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Session.fromMap(res.data); } @@ -1209,10 +1007,8 @@ 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 = {}; @@ -1222,12 +1018,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Session.fromMap(res.data); } @@ -1238,10 +1030,8 @@ 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 = {}; @@ -1250,12 +1040,8 @@ class Account extends Service { '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; } @@ -1274,12 +1060,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.User.fromMap(res.data); } @@ -1289,11 +1071,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 { final String apiPath = '/account/targets/push'; final Map apiParams = { @@ -1308,12 +1089,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Target.fromMap(res.data); } @@ -1323,16 +1100,14 @@ class Account extends Service { /// email, phone etc.). The target must exist and belong to the current user. /// If you change the provider ID, notifications will be sent through the new /// messaging provider instead. - Future updatePushTarget({ - required String targetId, - required String identifier, - }) async { - final String apiPath = '/account/targets/{targetId}/push'.replaceAll( - '{targetId}', - targetId, - ); + Future updatePushTarget( + {required String targetId, required String identifier}) async { + final String apiPath = + '/account/targets/{targetId}/push'.replaceAll('{targetId}', targetId); - final Map apiParams = {'identifier': identifier}; + final Map apiParams = { + 'identifier': identifier, + }; final Map apiHeaders = { 'X-Appwrite-Project': client.config['project'] ?? '', @@ -1340,12 +1115,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Target.fromMap(res.data); } @@ -1354,10 +1125,8 @@ 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 = {}; @@ -1366,12 +1135,8 @@ class Account extends Service { '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; } @@ -1390,11 +1155,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 { final String apiPath = '/account/tokens/email'; final Map apiParams = { @@ -1409,12 +1171,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Token.fromMap(res.data); } @@ -1433,12 +1191,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 { final String apiPath = '/account/tokens/magic-url'; final Map apiParams = { @@ -1454,12 +1211,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Token.fromMap(res.data); } @@ -1478,16 +1231,13 @@ 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 = { if (success != null) 'success': success, @@ -1502,8 +1252,7 @@ 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)}'); @@ -1512,12 +1261,11 @@ class Account extends Service { 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); } @@ -1532,13 +1280,14 @@ 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 { final String apiPath = '/account/tokens/phone'; - final Map apiParams = {'userId': userId, 'phone': phone}; + final Map apiParams = { + 'userId': userId, + 'phone': phone, + }; final Map apiHeaders = { 'X-Appwrite-Project': client.config['project'] ?? '', @@ -1546,12 +1295,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Token.fromMap(res.data); } @@ -1574,7 +1319,9 @@ class Account extends Service { Future createEmailVerification({required String url}) async { final String apiPath = '/account/verifications/email'; - final Map apiParams = {'url': url}; + final Map apiParams = { + 'url': url, + }; final Map apiHeaders = { 'X-Appwrite-Project': client.config['project'] ?? '', @@ -1582,12 +1329,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Token.fromMap(res.data); } @@ -1608,12 +1351,13 @@ 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 { final String apiPath = '/account/verifications/email'; - final Map apiParams = {'url': url}; + final Map apiParams = { + 'url': url, + }; final Map apiHeaders = { 'X-Appwrite-Project': client.config['project'] ?? '', @@ -1621,12 +1365,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Token.fromMap(res.data); } @@ -1635,13 +1375,14 @@ 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 { final String apiPath = '/account/verifications/email'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; final Map apiHeaders = { 'X-Appwrite-Project': client.config['project'] ?? '', @@ -1649,12 +1390,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Token.fromMap(res.data); } @@ -1664,15 +1401,15 @@ 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 { final String apiPath = '/account/verifications/email'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; final Map apiHeaders = { 'X-Appwrite-Project': client.config['project'] ?? '', @@ -1680,12 +1417,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Token.fromMap(res.data); } @@ -1709,12 +1442,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Token.fromMap(res.data); } @@ -1723,13 +1452,14 @@ 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 { final String apiPath = '/account/verifications/phone'; - final Map apiParams = {'userId': userId, 'secret': secret}; + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; final Map apiHeaders = { 'X-Appwrite-Project': client.config['project'] ?? '', @@ -1737,12 +1467,8 @@ class Account extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Token.fromMap(res.data); } diff --git a/lib/services/avatars.dart b/lib/services/avatars.dart index a3162b76..cdd93e6e 100644 --- a/lib/services/avatars.dart +++ b/lib/services/avatars.dart @@ -16,30 +16,24 @@ 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 = { if (width != null) 'width': width, if (height != null) 'height': height, if (quality != null) 'quality': quality, 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: params, responseType: ResponseType.bytes); return res.data; } @@ -52,30 +46,24 @@ 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 = { if (width != null) 'width': width, if (height != null) 'height': height, if (quality != null) 'quality': quality, 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: params, responseType: ResponseType.bytes); return res.data; } @@ -89,14 +77,11 @@ class Avatars extends Service { final Map params = { 'url': url, 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: params, responseType: ResponseType.bytes); return res.data; } @@ -110,30 +95,21 @@ 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 = { if (width != null) 'width': width, if (height != null) 'height': height, if (quality != null) 'quality': quality, 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: params, responseType: ResponseType.bytes); return res.data; } @@ -148,11 +124,8 @@ 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 { final String apiPath = '/avatars/image'; final Map params = { @@ -160,14 +133,11 @@ class Avatars extends Service { if (width != null) 'width': width, if (height != null) 'height': height, 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: params, responseType: ResponseType.bytes); return res.data; } @@ -187,12 +157,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 { final String apiPath = '/avatars/initials'; final Map params = { @@ -201,26 +167,19 @@ class Avatars extends Service { if (height != null) 'height': height, if (background != null) 'background': background, 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: params, responseType: ResponseType.bytes); return res.data; } /// Converts a given plain text to a QR code image. You can use the query /// parameters to change the size and style of the resulting image. /// - Future getQR({ - required String text, - int? size, - int? margin, - bool? download, - }) async { + Future getQR( + {required String text, int? size, int? margin, bool? download}) async { final String apiPath = '/avatars/qr'; final Map params = { @@ -229,14 +188,11 @@ class Avatars extends Service { if (margin != null) 'margin': margin, if (download != null) 'download': download, 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: params, responseType: ResponseType.bytes); return res.data; } @@ -250,28 +206,27 @@ class Avatars extends Service { /// When width and height are specified, the image is resized accordingly. If /// both dimensions are 0, the API provides an image at original size. If /// dimensions are not specified, the default viewport size is 1280x720px. - Future getScreenshot({ - required String url, - Map? headers, - int? viewportWidth, - int? viewportHeight, - double? scale, - enums.BrowserTheme? theme, - String? userAgent, - bool? fullpage, - String? locale, - enums.Timezone? timezone, - double? latitude, - double? longitude, - double? accuracy, - bool? touch, - List? permissions, - int? sleep, - int? width, - int? height, - int? quality, - enums.ImageFormat? output, - }) async { + Future getScreenshot( + {required String url, + Map? headers, + int? viewportWidth, + int? viewportHeight, + double? scale, + enums.BrowserTheme? theme, + String? userAgent, + bool? fullpage, + String? locale, + enums.Timezone? timezone, + double? latitude, + double? longitude, + double? accuracy, + bool? touch, + List? permissions, + int? sleep, + int? width, + int? height, + int? quality, + enums.ImageFormat? output}) async { final String apiPath = '/avatars/screenshots'; final Map params = { @@ -297,14 +252,11 @@ class Avatars extends Service { if (quality != null) 'quality': quality, if (output != null) 'output': output.value, 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: params, responseType: ResponseType.bytes); return res.data; } } diff --git a/lib/services/databases.dart b/lib/services/databases.dart index 84df4444..0ff3fb72 100644 --- a/lib/services/databases.dart +++ b/lib/services/databases.dart @@ -7,9 +7,10 @@ class Databases extends Service { Databases(super.client); /// List transactions across all databases. - Future listTransactions({ - List? queries, - }) async { + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.listTransactions` instead.') + Future listTransactions( + {List? queries}) async { final String apiPath = '/databases/transactions'; final Map apiParams = { @@ -21,21 +22,21 @@ class Databases extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.TransactionList.fromMap(res.data); } /// Create a new transaction. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.createTransaction` instead.') Future createTransaction({int? ttl}) async { final String apiPath = '/databases/transactions'; - final Map apiParams = {if (ttl != null) 'ttl': ttl}; + final Map apiParams = { + if (ttl != null) 'ttl': ttl, + }; final Map apiHeaders = { 'X-Appwrite-Project': client.config['project'] ?? '', @@ -43,24 +44,19 @@ class Databases extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Transaction.fromMap(res.data); } /// Get a transaction by its unique ID. - Future getTransaction({ - required String transactionId, - }) async { - final String apiPath = '/databases/transactions/{transactionId}'.replaceAll( - '{transactionId}', - transactionId, - ); + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.getTransaction` instead.') + Future getTransaction( + {required String transactionId}) async { + final String apiPath = '/databases/transactions/{transactionId}' + .replaceAll('{transactionId}', transactionId); final Map apiParams = {}; @@ -69,26 +65,19 @@ class Databases extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Transaction.fromMap(res.data); } /// 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, - ); + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.updateTransaction` instead.') + Future updateTransaction( + {required String transactionId, bool? commit, bool? rollback}) async { + final String apiPath = '/databases/transactions/{transactionId}' + .replaceAll('{transactionId}', transactionId); final Map apiParams = { if (commit != null) 'commit': commit, @@ -101,22 +90,18 @@ class Databases extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Transaction.fromMap(res.data); } /// Delete a transaction by its unique ID. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.deleteTransaction` instead.') Future deleteTransaction({required String transactionId}) async { - final String apiPath = '/databases/transactions/{transactionId}'.replaceAll( - '{transactionId}', - transactionId, - ); + final String apiPath = '/databases/transactions/{transactionId}' + .replaceAll('{transactionId}', transactionId); final Map apiParams = {}; @@ -125,21 +110,17 @@ class Databases extends Service { '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 { + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.createOperations` instead.') + Future createOperations( + {required String transactionId, List? operations}) async { final String apiPath = '/databases/transactions/{transactionId}/operations' .replaceAll('{transactionId}', transactionId); @@ -153,12 +134,8 @@ class Databases extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Transaction.fromMap(res.data); } @@ -166,16 +143,14 @@ 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, - bool? total, - int? ttl, - }) 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, + bool? total, + int? ttl}) async { final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents' .replaceAll('{databaseId}', databaseId) @@ -193,12 +168,8 @@ class Databases extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.DocumentList.fromMap(res.data); } @@ -208,16 +179,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) @@ -236,12 +205,8 @@ class Databases extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Document.fromMap(res.data); } @@ -249,15 +214,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) @@ -274,12 +237,8 @@ class Databases extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Document.fromMap(res.data); } @@ -289,16 +248,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, - 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, + Map? data, + List? permissions, + String? transactionId}) async { final String apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' .replaceAll('{databaseId}', databaseId) @@ -317,12 +274,8 @@ class Databases extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Document.fromMap(res.data); } @@ -330,16 +283,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) @@ -358,62 +309,52 @@ class Databases extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.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 = { + if (transactionId != null) 'transactionId': transactionId, + }; final Map apiHeaders = { 'X-Appwrite-Project': client.config['project'] ?? '', 'content-type': 'application/json', }; - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + 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) @@ -433,29 +374,23 @@ class Databases extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.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) @@ -475,12 +410,8 @@ class Databases extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Document.fromMap(res.data); } diff --git a/lib/services/functions.dart b/lib/services/functions.dart index 7f0606a5..ed97921b 100644 --- a/lib/services/functions.dart +++ b/lib/services/functions.dart @@ -8,15 +8,10 @@ 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, - bool? total, - }) async { - final String apiPath = '/functions/{functionId}/executions'.replaceAll( - '{functionId}', - functionId, - ); + Future listExecutions( + {required String functionId, List? queries, bool? total}) async { + final String apiPath = '/functions/{functionId}/executions' + .replaceAll('{functionId}', functionId); final Map apiParams = { if (queries != null) 'queries': queries, @@ -28,12 +23,8 @@ class Functions extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.ExecutionList.fromMap(res.data); } @@ -42,19 +33,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 = { if (body != null) 'body': body, @@ -71,21 +59,15 @@ class Functions extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.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); @@ -97,12 +79,8 @@ class Functions extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Execution.fromMap(res.data); } diff --git a/lib/services/graphql.dart b/lib/services/graphql.dart index 048d4d98..c86f3719 100644 --- a/lib/services/graphql.dart +++ b/lib/services/graphql.dart @@ -10,7 +10,9 @@ class Graphql extends Service { Future query({required Map query}) async { final String apiPath = '/graphql'; - final Map apiParams = {'query': query}; + final Map apiParams = { + 'query': query, + }; final Map apiHeaders = { 'X-Appwrite-Project': client.config['project'] ?? '', @@ -19,12 +21,8 @@ class Graphql extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return res.data; } @@ -33,7 +31,9 @@ class Graphql extends Service { Future mutation({required Map query}) async { final String apiPath = '/graphql/mutation'; - final Map apiParams = {'query': query}; + final Map apiParams = { + 'query': query, + }; final Map apiHeaders = { 'X-Appwrite-Project': client.config['project'] ?? '', @@ -42,12 +42,8 @@ class Graphql extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return res.data; } diff --git a/lib/services/locale.dart b/lib/services/locale.dart index d4831b74..87ea162e 100644 --- a/lib/services/locale.dart +++ b/lib/services/locale.dart @@ -22,12 +22,8 @@ class Locale extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Locale.fromMap(res.data); } @@ -44,12 +40,8 @@ class Locale extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.LocaleCodeList.fromMap(res.data); } @@ -66,12 +58,8 @@ class Locale extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.ContinentList.fromMap(res.data); } @@ -88,12 +76,8 @@ class Locale extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.CountryList.fromMap(res.data); } @@ -110,12 +94,8 @@ class Locale extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.CountryList.fromMap(res.data); } @@ -132,12 +112,8 @@ class Locale extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.PhoneList.fromMap(res.data); } @@ -155,12 +131,8 @@ class Locale extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.CurrencyList.fromMap(res.data); } @@ -177,12 +149,8 @@ class Locale extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.LanguageList.fromMap(res.data); } diff --git a/lib/services/messaging.dart b/lib/services/messaging.dart index 15585ec4..61ecefee 100644 --- a/lib/services/messaging.dart +++ b/lib/services/messaging.dart @@ -7,15 +7,12 @@ 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, @@ -28,21 +25,15 @@ class Messaging extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.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) @@ -55,12 +46,8 @@ class Messaging extends Service { '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/presences.dart b/lib/services/presences.dart index 2e3d6114..1c9b651b 100644 --- a/lib/services/presences.dart +++ b/lib/services/presences.dart @@ -6,11 +6,8 @@ class Presences extends Service { /// List presence logs. Expired entries are filtered out automatically. /// - Future list({ - List? queries, - bool? total, - int? ttl, - }) async { + Future list( + {List? queries, bool? total, int? ttl}) async { final String apiPath = '/presences'; final Map apiParams = { @@ -24,12 +21,8 @@ class Presences extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.PresenceList.fromMap(res.data); } @@ -38,10 +31,8 @@ class Presences extends Service { /// past are treated as not found. /// Future get({required String presenceId}) async { - final String apiPath = '/presences/{presenceId}'.replaceAll( - '{presenceId}', - presenceId, - ); + final String apiPath = + '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); final Map apiParams = {}; @@ -50,29 +41,22 @@ class Presences extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Presence.fromMap(res.data); } /// Create or update a presence log by its user ID. /// - Future upsert({ - required String presenceId, - required String status, - List? permissions, - String? expiresAt, - Map? metadata, - }) async { - final String apiPath = '/presences/{presenceId}'.replaceAll( - '{presenceId}', - presenceId, - ); + Future upsert( + {required String presenceId, + required String status, + List? permissions, + String? expiresAt, + Map? metadata}) async { + final String apiPath = + '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); final Map apiParams = { 'status': status, @@ -87,12 +71,8 @@ class Presences extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Presence.fromMap(res.data); } @@ -100,18 +80,15 @@ class Presences extends Service { /// Update a presence log by its unique ID. Using the patch method you can pass /// only specific fields that will get updated. /// - Future update({ - required String presenceId, - String? status, - String? expiresAt, - Map? metadata, - List? permissions, - bool? purge, - }) async { - final String apiPath = '/presences/{presenceId}'.replaceAll( - '{presenceId}', - presenceId, - ); + Future update( + {required String presenceId, + String? status, + String? expiresAt, + Map? metadata, + List? permissions, + bool? purge}) async { + final String apiPath = + '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); final Map apiParams = { if (status != null) 'status': status, @@ -127,12 +104,8 @@ class Presences extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Presence.fromMap(res.data); } @@ -140,10 +113,8 @@ class Presences extends Service { /// Delete a presence log by its unique ID. /// Future delete({required String presenceId}) async { - final String apiPath = '/presences/{presenceId}'.replaceAll( - '{presenceId}', - presenceId, - ); + final String apiPath = + '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); final Map apiParams = {}; @@ -152,12 +123,8 @@ class Presences extends Service { '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 83438aaa..cdb626de 100644 --- a/lib/services/storage.dart +++ b/lib/services/storage.dart @@ -7,16 +7,13 @@ 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, - bool? total, - }) async { - final String apiPath = '/storage/buckets/{bucketId}/files'.replaceAll( - '{bucketId}', - bucketId, - ); + Future listFiles( + {required String bucketId, + List? queries, + String? search, + bool? total}) async { + final String apiPath = + '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); final Map apiParams = { if (queries != null) 'queries': queries, @@ -29,12 +26,8 @@ class Storage extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.FileList.fromMap(res.data); } @@ -57,17 +50,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, @@ -98,10 +88,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); @@ -113,24 +101,19 @@ class Storage extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.File.fromMap(res.data); } /// 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); @@ -146,12 +129,8 @@ class Storage extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); return models.File.fromMap(res.data); } @@ -170,12 +149,8 @@ class Storage extends Service { '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; } @@ -183,11 +158,8 @@ 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); @@ -195,14 +167,11 @@ class Storage extends Service { final Map params = { if (token != null) 'token': token, 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: params, responseType: ResponseType.bytes); return res.data; } @@ -211,22 +180,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); @@ -245,25 +213,19 @@ class Storage extends Service { if (output != null) 'output': output.value, if (token != null) 'token': token, 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); + 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); @@ -271,14 +233,11 @@ class Storage extends Service { final Map params = { if (token != null) 'token': token, 'project': client.config['project'], + 'impersonateuserid': client.config['impersonateuserid'], }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: params, - responseType: ResponseType.bytes, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: params, responseType: ResponseType.bytes); return res.data; } } diff --git a/lib/services/tables_db.dart b/lib/services/tables_db.dart index f27da9da..8b6284b3 100644 --- a/lib/services/tables_db.dart +++ b/lib/services/tables_db.dart @@ -5,9 +5,8 @@ class TablesDB extends Service { TablesDB(super.client); /// List transactions across all databases. - Future listTransactions({ - List? queries, - }) async { + Future listTransactions( + {List? queries}) async { final String apiPath = '/tablesdb/transactions'; final Map apiParams = { @@ -19,12 +18,8 @@ class TablesDB extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.TransactionList.fromMap(res.data); } @@ -33,7 +28,9 @@ class TablesDB extends Service { Future createTransaction({int? ttl}) async { final String apiPath = '/tablesdb/transactions'; - final Map apiParams = {if (ttl != null) 'ttl': ttl}; + final Map apiParams = { + if (ttl != null) 'ttl': ttl, + }; final Map apiHeaders = { 'X-Appwrite-Project': client.config['project'] ?? '', @@ -41,24 +38,17 @@ class TablesDB extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Transaction.fromMap(res.data); } /// 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 = {}; @@ -67,26 +57,17 @@ class TablesDB extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Transaction.fromMap(res.data); } /// 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 = { if (commit != null) 'commit': commit, @@ -99,22 +80,16 @@ class TablesDB extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.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 = {}; @@ -123,21 +98,15 @@ class TablesDB extends Service { '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); @@ -151,26 +120,21 @@ class TablesDB extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Transaction.fromMap(res.data); } /// Get a list of all the user's rows in a given table. You can use the query /// params to filter your results. - Future listRows({ - required String databaseId, - required String tableId, - List? queries, - String? transactionId, - bool? total, - int? ttl, - }) async { + Future listRows( + {required String databaseId, + required String tableId, + List? queries, + String? transactionId, + bool? total, + int? ttl}) async { final String apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows' .replaceAll('{databaseId}', databaseId) .replaceAll('{tableId}', tableId); @@ -187,12 +151,8 @@ class TablesDB extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.RowList.fromMap(res.data); } @@ -201,14 +161,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); @@ -226,25 +185,20 @@ class TablesDB extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.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) @@ -261,12 +215,8 @@ class TablesDB extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Row.fromMap(res.data); } @@ -275,14 +225,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) @@ -301,26 +250,21 @@ class TablesDB extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); return models.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) @@ -339,56 +283,48 @@ class TablesDB extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.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 = { + if (transactionId != null) 'transactionId': transactionId, + }; final Map apiHeaders = { 'X-Appwrite-Project': client.config['project'] ?? '', 'content-type': 'application/json', }; - final res = await client.call( - HttpMethod.delete, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + 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) @@ -408,26 +344,21 @@ class TablesDB extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.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) @@ -447,12 +378,8 @@ class TablesDB extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Row.fromMap(res.data); } diff --git a/lib/services/teams.dart b/lib/services/teams.dart index efd66405..1f4022f6 100644 --- a/lib/services/teams.dart +++ b/lib/services/teams.dart @@ -8,11 +8,8 @@ class Teams extends Service { /// Get a list of all the teams in which the current user is a member. You can /// use the parameters to filter your results. - Future list({ - List? queries, - String? search, - bool? total, - }) async { + Future list( + {List? queries, String? search, bool? total}) async { final String apiPath = '/teams'; final Map apiParams = { @@ -26,12 +23,8 @@ class Teams extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.TeamList.fromMap(res.data); } @@ -39,11 +32,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 { final String apiPath = '/teams'; final Map apiParams = { @@ -58,12 +50,8 @@ class Teams extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Team.fromMap(res.data); } @@ -79,24 +67,20 @@ class Teams extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Team.fromMap(res.data); } /// Update the team's name by its unique ID. - Future updateName({ - required String teamId, - required String name, - }) async { + Future updateName( + {required String teamId, required String name}) async { final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); - final Map apiParams = {'name': name}; + final Map apiParams = { + 'name': name, + }; final Map apiHeaders = { 'X-Appwrite-Project': client.config['project'] ?? '', @@ -104,12 +88,8 @@ class Teams extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Team.fromMap(res.data); } @@ -126,12 +106,8 @@ class Teams extends Service { '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; } @@ -139,16 +115,13 @@ 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, - bool? total, - }) async { - final String apiPath = '/teams/{teamId}/memberships'.replaceAll( - '{teamId}', - teamId, - ); + Future listMemberships( + {required String teamId, + List? queries, + String? search, + bool? total}) async { + final String apiPath = + '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); final Map apiParams = { if (queries != null) 'queries': queries, @@ -161,12 +134,8 @@ class Teams extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.MembershipList.fromMap(res.data); } @@ -192,19 +161,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 = { if (email != null) 'email': email, @@ -221,12 +187,8 @@ class Teams extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.post, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.post, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Membership.fromMap(res.data); } @@ -234,10 +196,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); @@ -249,12 +209,8 @@ class Teams extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Membership.fromMap(res.data); } @@ -263,16 +219,17 @@ 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 = { 'X-Appwrite-Project': client.config['project'] ?? '', @@ -280,12 +237,8 @@ class Teams extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Membership.fromMap(res.data); } @@ -293,10 +246,8 @@ 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); @@ -308,12 +259,8 @@ class Teams extends Service { '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; } @@ -325,17 +272,19 @@ 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 = { 'X-Appwrite-Project': client.config['project'] ?? '', @@ -343,12 +292,8 @@ class Teams extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.patch, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.patch, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Membership.fromMap(res.data); } @@ -357,10 +302,8 @@ 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 = {}; @@ -369,12 +312,8 @@ class Teams extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.get, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Preferences.fromMap(res.data); } @@ -382,16 +321,14 @@ 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, - ); + Future updatePrefs( + {required String teamId, required Map prefs}) async { + final String apiPath = + '/teams/{teamId}/prefs'.replaceAll('{teamId}', teamId); - final Map apiParams = {'prefs': prefs}; + final Map apiParams = { + 'prefs': prefs, + }; final Map apiHeaders = { 'X-Appwrite-Project': client.config['project'] ?? '', @@ -399,12 +336,8 @@ class Teams extends Service { 'accept': 'application/json', }; - final res = await client.call( - HttpMethod.put, - path: apiPath, - params: apiParams, - headers: apiHeaders, - ); + final res = await client.call(HttpMethod.put, + path: apiPath, params: apiParams, headers: apiHeaders); return models.Preferences.fromMap(res.data); } diff --git a/lib/src/client.dart b/lib/src/client.dart index 940ddb5e..cc077e56 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -86,17 +86,17 @@ abstract class Client { /// Set ImpersonateUserId. /// - /// Impersonate a user by ID on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data.. + /// Impersonate a user by ID. Client setImpersonateUserId(String value); /// Set ImpersonateUserEmail. /// - /// Impersonate a user by email on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data.. + /// Impersonate a user by email. Client setImpersonateUserEmail(String value); /// Set ImpersonateUserPhone. /// - /// Impersonate a user by phone on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data.. + /// Impersonate a user by phone. Client setImpersonateUserPhone(String value); /// Add headers that should be sent with all API calls. @@ -105,7 +105,7 @@ abstract class Client { /// Get the current request headers. Map getHeaders(); - /// Sends a "ping" request to Appwrite to verify connectivity. + /// Send a ping to project as part of onboarding. Future ping(); /// Send the API request. diff --git a/lib/src/client_base.dart b/lib/src/client_base.dart index d3f47540..da1a5225 100644 --- a/lib/src/client_base.dart +++ b/lib/src/client_base.dart @@ -25,15 +25,15 @@ abstract class ClientBase implements Client { @override ClientBase setCookie(value); - /// Impersonate a user by ID on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. + /// Impersonate a user by ID @override ClientBase setImpersonateUserId(value); - /// Impersonate a user by email on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. + /// Impersonate a user by email @override ClientBase setImpersonateUserEmail(value); - /// Impersonate a user by phone on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. + /// Impersonate a user by phone @override ClientBase setImpersonateUserPhone(value); @@ -58,7 +58,10 @@ abstract class ClientBase implements Client { final response = await call( HttpMethod.get, path: apiPath, - headers: {'X-Appwrite-Project': config['project'] ?? ''}, + headers: { + 'X-Appwrite-Project': config['project'] ?? '', + 'accept': 'application/json', + }, responseType: ResponseType.plain, ); return response.data; diff --git a/lib/src/client_browser.dart b/lib/src/client_browser.dart index 516021dd..32945efd 100644 --- a/lib/src/client_browser.dart +++ b/lib/src/client_browser.dart @@ -40,7 +40,7 @@ class ClientBrowser extends ClientBase with ClientMixin { 'x-sdk-name': 'Flutter', 'x-sdk-platform': 'client', 'x-sdk-language': 'flutter', - 'x-sdk-version': '25.1.0', + 'x-sdk-version': '25.2.0', 'X-Appwrite-Response-Format': '1.9.5', }; @@ -102,7 +102,7 @@ class ClientBrowser extends ClientBase with ClientMixin { return this; } - /// Impersonate a user by ID on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. + /// Impersonate a user by ID @override ClientBrowser setImpersonateUserId(value) { config['impersonateUserId'] = value; @@ -110,7 +110,7 @@ class ClientBrowser extends ClientBase with ClientMixin { return this; } - /// Impersonate a user by email on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. + /// Impersonate a user by email @override ClientBrowser setImpersonateUserEmail(value) { config['impersonateUserEmail'] = value; @@ -118,7 +118,7 @@ class ClientBrowser extends ClientBase with ClientMixin { return this; } - /// Impersonate a user by phone on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. + /// Impersonate a user by phone @override ClientBrowser setImpersonateUserPhone(value) { config['impersonateUserPhone'] = value; @@ -228,11 +228,7 @@ class ClientBrowser extends ClientBase with ClientMixin { final totalChunks = (size / chunkSize).ceil(); Future uploadChunk( - int index, - int start, - int end, - String? id, - ) async { + int index, int start, int end, String? id) async { List chunk = []; chunk = file.bytes!.getRange(start, end).toList(); @@ -287,7 +283,11 @@ class ClientBrowser extends ClientBase with ClientMixin { final chunks = >[]; for (var start = firstEnd; start < size; start += chunkSize) { final end = min(start + chunkSize, size); - chunks.add({'index': start ~/ chunkSize, 'start': start, 'end': end}); + chunks.add({ + 'index': start ~/ chunkSize, + 'start': start, + 'end': end, + }); } var nextChunk = 0; diff --git a/lib/src/client_io.dart b/lib/src/client_io.dart index 645efba1..78a368ae 100644 --- a/lib/src/client_io.dart +++ b/lib/src/client_io.dart @@ -58,7 +58,7 @@ class ClientIO extends ClientBase with ClientMixin { 'x-sdk-name': 'Flutter', 'x-sdk-platform': 'client', 'x-sdk-language': 'flutter', - 'x-sdk-version': '25.1.0', + 'x-sdk-version': '25.2.0', 'X-Appwrite-Response-Format': '1.9.5', }; @@ -128,7 +128,7 @@ class ClientIO extends ClientBase with ClientMixin { return this; } - /// Impersonate a user by ID on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. + /// Impersonate a user by ID @override ClientIO setImpersonateUserId(value) { config['impersonateUserId'] = value; @@ -136,7 +136,7 @@ class ClientIO extends ClientBase with ClientMixin { return this; } - /// Impersonate a user by email on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. + /// Impersonate a user by email @override ClientIO setImpersonateUserEmail(value) { config['impersonateUserEmail'] = value; @@ -144,7 +144,7 @@ class ClientIO extends ClientBase with ClientMixin { return this; } - /// Impersonate a user by phone on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. + /// Impersonate a user by phone @override ClientIO setImpersonateUserPhone(value) { config['impersonateUserPhone'] = value; @@ -348,13 +348,8 @@ class ClientIO extends ClientBase with ClientMixin { final totalChunks = (size / chunkSize).ceil(); - Future uploadChunk( - int index, - int start, - int end, - String? id, [ - RandomAccessFile? raf, - ]) async { + Future uploadChunk(int index, int start, int end, String? id, + [RandomAccessFile? raf]) async { List chunk = []; if (file.bytes != null) { chunk = file.bytes!.getRange(start, end).toList(); @@ -424,7 +419,11 @@ class ClientIO extends ClientBase with ClientMixin { final chunks = >[]; for (var start = firstEnd; start < size; start += chunkSize) { final end = min(start + chunkSize, size); - chunks.add({'index': start ~/ chunkSize, 'start': start, 'end': end}); + chunks.add({ + 'index': start ~/ chunkSize, + 'start': start, + 'end': end, + }); } var nextChunk = 0; @@ -477,7 +476,9 @@ class ClientIO extends ClientBase with ClientMixin { callbackUrlScheme: callbackUrlScheme != null && _customSchemeAllowed ? callbackUrlScheme : "appwrite-callback-${config['project']!}", - options: const FlutterWebAuth2Options(useWebview: false), + options: const FlutterWebAuth2Options( + useWebview: false, + ), ).then((value) async { Uri url = Uri.parse(value); final key = url.queryParameters['key']; diff --git a/lib/src/client_mixin.dart b/lib/src/client_mixin.dart index 8783f6e8..89aad359 100644 --- a/lib/src/client_mixin.dart +++ b/lib/src/client_mixin.dart @@ -130,11 +130,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 c345e705..6b1e67cd 100644 --- a/lib/src/cookie_manager.dart +++ b/lib/src/cookie_manager.dart @@ -11,7 +11,9 @@ class CookieManager extends Interceptor { CookieManager(this.cookieJar); @override - FutureOr onRequest(http.BaseRequest request) async { + FutureOr onRequest( + http.BaseRequest request, + ) async { await cookieJar .loadForRequest(Uri(scheme: request.url.scheme, host: request.url.host)) .then((cookies) { @@ -41,9 +43,8 @@ class CookieManager extends Interceptor { var cookies = cookie.split(exp); await cookieJar.saveFromResponse( Uri( - scheme: response.request!.url.scheme, - host: response.request!.url.host, - ), + scheme: response.request!.url.scheme, + host: response.request!.url.host), cookies.map((str) => Cookie.fromSetCookieValue(str)).toList(), ); } diff --git a/lib/src/enums.dart b/lib/src/enums.dart index 0f250ea3..595afdc2 100644 --- a/lib/src/enums.dart +++ b/lib/src/enums.dart @@ -17,5 +17,5 @@ enum ResponseType { plain, /// Get original bytes, the type of response will be `List` - bytes, + bytes } diff --git a/lib/src/models/algo_bcrypt.dart b/lib/src/models/algo_bcrypt.dart index a8b682fb..9909265e 100644 --- a/lib/src/models/algo_bcrypt.dart +++ b/lib/src/models/algo_bcrypt.dart @@ -5,14 +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 f5d7bc9a..746fbd52 100644 --- a/lib/src/models/algo_md5.dart +++ b/lib/src/models/algo_md5.dart @@ -5,14 +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 e17a69a8..cab45e49 100644 --- a/lib/src/models/algo_phpass.dart +++ b/lib/src/models/algo_phpass.dart @@ -5,14 +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_sha.dart b/lib/src/models/algo_sha.dart index 1ab20633..4984df75 100644 --- a/lib/src/models/algo_sha.dart +++ b/lib/src/models/algo_sha.dart @@ -5,14 +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 9f832f6c..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( @@ -19,6 +22,9 @@ 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 fa2f5f7b..df28f04b 100644 --- a/lib/src/models/continent_list.dart +++ b/lib/src/models/continent_list.dart @@ -8,14 +8,16 @@ 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))), ); } diff --git a/lib/src/models/country.dart b/lib/src/models/country.dart index 0ce90cf6..3bcbb76d 100644 --- a/lib/src/models/country.dart +++ b/lib/src/models/country.dart @@ -8,14 +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 32df44f7..79cb1256 100644 --- a/lib/src/models/country_list.dart +++ b/lib/src/models/country_list.dart @@ -8,14 +8,16 @@ 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))), ); } diff --git a/lib/src/models/currency_list.dart b/lib/src/models/currency_list.dart index 6c4a94da..6c39ae2e 100644 --- a/lib/src/models/currency_list.dart +++ b/lib/src/models/currency_list.dart @@ -8,14 +8,16 @@ 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))), ); } diff --git a/lib/src/models/document_list.dart b/lib/src/models/document_list.dart index ca84e1b6..76a07309 100644 --- a/lib/src/models/document_list.dart +++ b/lib/src/models/document_list.dart @@ -8,14 +8,16 @@ 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))), ); } diff --git a/lib/src/models/execution.dart b/lib/src/models/execution.dart index 92c27230..3629e1d6 100644 --- a/lib/src/models/execution.dart +++ b/lib/src/models/execution.dart @@ -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(), diff --git a/lib/src/models/execution_list.dart b/lib/src/models/execution_list.dart index 7737afaa..63c2ad7e 100644 --- a/lib/src/models/execution_list.dart +++ b/lib/src/models/execution_list.dart @@ -8,14 +8,16 @@ 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))), ); } diff --git a/lib/src/models/file_list.dart b/lib/src/models/file_list.dart index 500e09fe..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( @@ -19,6 +22,9 @@ 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 df11e0fb..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( @@ -19,6 +22,9 @@ class Headers implements Model { @override Map toMap() { - return {"name": name, "value": value}; + return { + "name": name, + "value": value, + }; } } diff --git a/lib/src/models/identity_list.dart b/lib/src/models/identity_list.dart index f8eda904..a5d39ea0 100644 --- a/lib/src/models/identity_list.dart +++ b/lib/src/models/identity_list.dart @@ -8,14 +8,16 @@ 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))), ); } diff --git a/lib/src/models/jwt.dart b/lib/src/models/jwt.dart index 1de0ca29..cda66c70 100644 --- a/lib/src/models/jwt.dart +++ b/lib/src/models/jwt.dart @@ -5,14 +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 d2807477..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( @@ -23,6 +27,10 @@ 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 de936431..6198d61e 100644 --- a/lib/src/models/language_list.dart +++ b/lib/src/models/language_list.dart @@ -8,14 +8,16 @@ 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))), ); } diff --git a/lib/src/models/locale_code.dart b/lib/src/models/locale_code.dart index 3255ef92..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( @@ -19,6 +22,9 @@ 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 af24267e..202355a4 100644 --- a/lib/src/models/locale_code_list.dart +++ b/lib/src/models/locale_code_list.dart @@ -8,14 +8,16 @@ 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))), ); } diff --git a/lib/src/models/log_list.dart b/lib/src/models/log_list.dart index 50695e4a..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( @@ -19,6 +22,9 @@ 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_list.dart b/lib/src/models/membership_list.dart index cc11b182..cc664c9f 100644 --- a/lib/src/models/membership_list.dart +++ b/lib/src/models/membership_list.dart @@ -8,14 +8,16 @@ 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))), ); } diff --git a/lib/src/models/mfa_recovery_codes.dart b/lib/src/models/mfa_recovery_codes.dart index fb3af632..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( @@ -15,6 +17,8 @@ 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 4debb42e..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( @@ -19,6 +22,9 @@ class MfaType implements Model { @override Map toMap() { - return {"secret": secret, "uri": uri}; + return { + "secret": secret, + "uri": uri, + }; } } diff --git a/lib/src/models/phone_list.dart b/lib/src/models/phone_list.dart index e4376c98..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( @@ -19,6 +22,9 @@ 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 d10c62fc..3ca04118 100644 --- a/lib/src/models/preferences.dart +++ b/lib/src/models/preferences.dart @@ -4,15 +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/presence_list.dart b/lib/src/models/presence_list.dart index ec5f575b..3d010b1c 100644 --- a/lib/src/models/presence_list.dart +++ b/lib/src/models/presence_list.dart @@ -8,14 +8,16 @@ class PresenceList implements Model { /// List of presences. final List presences; - PresenceList({required this.total, required this.presences}); + PresenceList({ + required this.total, + required this.presences, + }); factory PresenceList.fromMap(Map map) { return PresenceList( total: map['total'], - presences: List.from( - map['presences'].map((p) => Presence.fromMap(p)), - ), + presences: + List.from(map['presences'].map((p) => Presence.fromMap(p))), ); } diff --git a/lib/src/models/row_list.dart b/lib/src/models/row_list.dart index 0ec8cfce..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( @@ -19,7 +22,10 @@ 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_list.dart b/lib/src/models/session_list.dart index 1a10a711..4ea12394 100644 --- a/lib/src/models/session_list.dart +++ b/lib/src/models/session_list.dart @@ -8,14 +8,16 @@ 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))), ); } diff --git a/lib/src/models/team_list.dart b/lib/src/models/team_list.dart index cdd54fba..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( @@ -19,6 +22,9 @@ 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/transaction_list.dart b/lib/src/models/transaction_list.dart index bb39e8c8..7f321175 100644 --- a/lib/src/models/transaction_list.dart +++ b/lib/src/models/transaction_list.dart @@ -8,14 +8,16 @@ 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))), ); } diff --git a/lib/src/realtime_browser.dart b/lib/src/realtime_browser.dart index 3563e7d9..a0f4193a 100644 --- a/lib/src/realtime_browser.dart +++ b/lib/src/realtime_browser.dart @@ -22,6 +22,15 @@ class RealtimeBrowser extends RealtimeBase with RealtimeMixin { Future _getWebSocket(Uri uri) async { await (client as ClientBrowser).init(); + + final jwt = client.config['jwt']; + if (jwt != null && jwt.isNotEmpty) { + uri = uri.replace(queryParameters: { + ...uri.queryParameters, + 'jwt': jwt, + }); + } + return HtmlWebSocketChannel.connect(uri); } diff --git a/lib/src/realtime_io.dart b/lib/src/realtime_io.dart index edff9665..0ed367a6 100644 --- a/lib/src/realtime_io.dart +++ b/lib/src/realtime_io.dart @@ -32,11 +32,14 @@ class RealtimeIO extends RealtimeBase with RealtimeMixin { final cookies = await (client as ClientIO).cookieJar.loadForRequest(uri); headers = {HttpHeaders.cookieHeader: CookieManager.getCookies(cookies)}; - final websok = IOWebSocketChannel( - (client as ClientIO).selfSigned - ? await _connectForSelfSignedCert(uri, headers) - : await WebSocket.connect(uri.toString(), headers: headers), - ); + final jwt = client.config['jwt']; + if (jwt != null && jwt.isNotEmpty) { + headers['x-appwrite-jwt'] = jwt; + } + + final websok = IOWebSocketChannel((client as ClientIO).selfSigned + ? await _connectForSelfSignedCert(uri, headers) + : await WebSocket.connect(uri.toString(), headers: headers)); return websok; } @@ -70,9 +73,7 @@ class RealtimeIO extends RealtimeBase with RealtimeMixin { // https://github.com/jonataslaw/getsocket/blob/f25b3a264d8cc6f82458c949b86d286cd0343792/lib/src/io.dart#L104 // and from official dart sdk websocket_impl.dart connect method Future _connectForSelfSignedCert( - Uri uri, - Map headers, - ) async { + Uri uri, Map headers) async { try { var r = Random(); var key = base64.encode(List.generate(16, (_) => r.nextInt(255))); diff --git a/lib/src/realtime_mixin.dart b/lib/src/realtime_mixin.dart index 0102de03..72edf5ee 100644 --- a/lib/src/realtime_mixin.dart +++ b/lib/src/realtime_mixin.dart @@ -100,78 +100,74 @@ mixin RealtimeMixin { _websok = await getWebSocket(uri); } _retries = 0; - _websocketSubscription = _websok?.stream.listen( - (response) { - final data = RealtimeResponse.fromJson(response); - switch (data.type) { - case 'error': - handleError(data); - break; - case 'connected': - final message = RealtimeResponseConnected.fromMap(data.data); - - if (message.user.isEmpty) { - // send fallback cookie if exists - final cookie = getFallbackCookie?.call(); - if (cookie != null) { - _websok?.sink.add( - jsonEncode({ - "type": "authentication", - "data": {"session": cookie}, - }), - ); - } - } - for (var entry in _subscriptions.entries) { - _pendingSubscribes[entry.key] = { - 'subscriptionId': entry.key, - 'channels': entry.value.channels, - 'queries': entry.value.queries, - }; + _websocketSubscription = _websok?.stream.listen((response) { + final data = RealtimeResponse.fromJson(response); + switch (data.type) { + case 'error': + handleError(data); + break; + case 'connected': + final message = RealtimeResponseConnected.fromMap(data.data); + + if (message.user.isEmpty) { + // send fallback cookie if exists + final cookie = getFallbackCookie?.call(); + if (cookie != null) { + _websok?.sink.add(jsonEncode({ + "type": "authentication", + "data": { + "session": cookie, + }, + })); } - _appConnected = true; - _sendPendingSubscribes(); - _flushPendingPresence(); - _startHeartbeat(); // Start heartbeat after successful connection - break; - case 'pong': + } + for (var entry in _subscriptions.entries) { + _pendingSubscribes[entry.key] = { + 'subscriptionId': entry.key, + 'channels': entry.value.channels, + 'queries': entry.value.queries, + }; + } + _appConnected = true; + _sendPendingSubscribes(); + _flushPendingPresence(); + _startHeartbeat(); // Start heartbeat after successful connection + break; + case 'pong': + break; + case 'event': + final messageData = data.data as Map; + final message = RealtimeMessage.fromMap(messageData); + final subscriptions = + (messageData['subscriptions'] as List?) + ?.map((x) => x.toString()) + .toList() ?? + []; + + if (subscriptions.isEmpty) { break; - case 'event': - final messageData = data.data as Map; - final message = RealtimeMessage.fromMap(messageData); - final subscriptions = - (messageData['subscriptions'] as List?) - ?.map((x) => x.toString()) - .toList() ?? - []; - - if (subscriptions.isEmpty) { - break; - } + } - for (var subscriptionId in subscriptions) { - final subscription = _subscriptions[subscriptionId]; - if (subscription != null) { - subscription.controller.add(message); - } + for (var subscriptionId in subscriptions) { + final subscription = _subscriptions[subscriptionId]; + if (subscription != null) { + subscription.controller.add(message); } - break; - } - }, - onDone: () { - _appConnected = false; - _stopHeartbeat(); - _retry(); - }, - onError: (err, stack) { - _appConnected = false; - _stopHeartbeat(); - for (var subscription in _subscriptions.values) { - subscription.controller.addError(err, stack); - } - _retry(); - }, - ); + } + break; + } + }, onDone: () { + _appConnected = false; + _stopHeartbeat(); + _retry(); + }, onError: (err, stack) { + _appConnected = false; + _stopHeartbeat(); + for (var subscription in _subscriptions.values) { + subscription.controller.addError(err, stack); + } + _retry(); + }); } catch (e) { if (e is AppwriteException) { rethrow; @@ -210,8 +206,7 @@ mixin RealtimeMixin { Uri _prepareUri() { if (client.endPointRealtime == null) { throw AppwriteException( - "Please set endPointRealtime to connect to realtime server", - ); + "Please set endPointRealtime to connect to realtime server"); } var uri = Uri.parse(client.endPointRealtime!); @@ -222,8 +217,7 @@ mixin RealtimeMixin { ? ':${uri.port}' : ''; return Uri.parse( - "${uri.scheme}://${uri.host}$portPart${uri.path}/realtime?$queryParams", - ); + "${uri.scheme}://${uri.host}$portPart${uri.path}/realtime?$queryParams"); } void _sendUnsubscribeMessage(List subscriptionIds) { @@ -233,12 +227,10 @@ mixin RealtimeMixin { if (_websok == null || _websok?.closeCode != null) { return; } - _websok!.sink.add( - jsonEncode({ - 'type': 'unsubscribe', - 'data': subscriptionIds.map((id) => {'subscriptionId': id}).toList(), - }), - ); + _websok!.sink.add(jsonEncode({ + 'type': 'unsubscribe', + 'data': subscriptionIds.map((id) => {'subscriptionId': id}).toList(), + })); } String _generateUniqueSubscriptionId() { @@ -300,7 +292,10 @@ mixin RealtimeMixin { final rows = _pendingSubscribes.values.toList(); _pendingSubscribes.clear(); - _websok!.sink.add(jsonEncode({'type': 'subscribe', 'data': rows})); + _websok!.sink.add(jsonEncode({ + 'type': 'subscribe', + 'data': rows, + })); } void _flushPendingPresence() { @@ -317,10 +312,8 @@ mixin RealtimeMixin { return channel is String ? channel : channel.toString(); } - RealtimeSubscription subscribeTo( - List channels, [ - List queries = const [], - ]) { + RealtimeSubscription subscribeTo(List channels, + [List queries = const []]) { StreamController controller = StreamController.broadcast(); final channelStrings = channels.map((ch) => _channelToString(ch)).toList().cast(); @@ -405,7 +398,10 @@ mixin RealtimeMixin { List? permissions, Map? metadata, }) { - final data = {'status': status, 'presenceId': presenceId}; + final data = { + 'status': status, + 'presenceId': presenceId, + }; if (permissions != null) data['permissions'] = permissions; if (metadata != null) data['metadata'] = metadata; 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/pubspec.yaml b/pubspec.yaml index 21fc904f..1277dec1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: appwrite -version: 25.1.0 +version: 25.2.0 description: Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API homepage: https://appwrite.io repository: https://github.com/appwrite/sdk-for-flutter diff --git a/test/channel_test.dart b/test/channel_test.dart index 5ed52b81..9e0e11d3 100644 --- a/test/channel_test.dart +++ b/test/channel_test.dart @@ -8,28 +8,28 @@ void main() { }); test('returns database channel with specific IDs', () { - expect( - Channel.database('db1').collection('col1').document().toString(), - 'databases.db1.collections.col1.documents', - ); + expect(Channel.database('db1').collection('col1').document().toString(), + 'databases.db1.collections.col1.documents'); }); test('returns database channel with action', () { expect( - Channel.database( - 'db1', - ).collection('col1').document('doc1').create().toString(), - 'databases.db1.collections.col1.documents.doc1.create', - ); + Channel.database('db1') + .collection('col1') + .document('doc1') + .create() + .toString(), + 'databases.db1.collections.col1.documents.doc1.create'); }); test('returns database channel with upsert action', () { expect( - Channel.database( - 'db1', - ).collection('col1').document('doc1').upsert().toString(), - 'databases.db1.collections.col1.documents.doc1.upsert', - ); + Channel.database('db1') + .collection('col1') + .document('doc1') + .upsert() + .toString(), + 'databases.db1.collections.col1.documents.doc1.upsert'); }); }); @@ -39,17 +39,18 @@ void main() { }); test('returns tablesdb channel with specific IDs', () { - expect( - Channel.tablesdb('db1').table('table1').row().toString(), - 'tablesdb.db1.tables.table1.rows', - ); + expect(Channel.tablesdb('db1').table('table1').row().toString(), + 'tablesdb.db1.tables.table1.rows'); }); test('returns tablesdb channel with action', () { expect( - Channel.tablesdb('db1').table('table1').row('row1').update().toString(), - 'tablesdb.db1.tables.table1.rows.row1.update', - ); + Channel.tablesdb('db1') + .table('table1') + .row('row1') + .update() + .toString(), + 'tablesdb.db1.tables.table1.rows.row1.update'); }); }); @@ -66,16 +67,12 @@ void main() { test('returns buckets channel with specific IDs', () { expect( - Channel.bucket('bucket1').file().toString(), - 'buckets.bucket1.files', - ); + Channel.bucket('bucket1').file().toString(), 'buckets.bucket1.files'); }); test('returns buckets channel with action', () { - expect( - Channel.bucket('bucket1').file('file1').delete().toString(), - 'buckets.bucket1.files.file1.delete', - ); + expect(Channel.bucket('bucket1').file('file1').delete().toString(), + 'buckets.bucket1.files.file1.delete'); }); }); @@ -119,17 +116,13 @@ void main() { }); test('returns memberships channel with specific membership ID', () { - expect( - Channel.membership('membership1').toString(), - 'memberships.membership1', - ); + expect(Channel.membership('membership1').toString(), + 'memberships.membership1'); }); test('returns memberships channel with action', () { - expect( - Channel.membership('membership1').update().toString(), - 'memberships.membership1.update', - ); + expect(Channel.membership('membership1').update().toString(), + 'memberships.membership1.update'); }); }); @@ -147,31 +140,23 @@ void main() { }); test('returns presence channel with create action', () { - expect( - Channel.presence('presence1').create().toString(), - 'presences.presence1.create', - ); + expect(Channel.presence('presence1').create().toString(), + 'presences.presence1.create'); }); test('returns presence channel with upsert action', () { - expect( - Channel.presence('presence1').upsert().toString(), - 'presences.presence1.upsert', - ); + expect(Channel.presence('presence1').upsert().toString(), + 'presences.presence1.upsert'); }); test('returns presence channel with update action', () { - expect( - Channel.presence('presence1').update().toString(), - 'presences.presence1.update', - ); + expect(Channel.presence('presence1').update().toString(), + 'presences.presence1.update'); }); test('returns presence channel with delete action', () { - expect( - Channel.presence('presence1').delete().toString(), - 'presences.presence1.delete', - ); + expect(Channel.presence('presence1').delete().toString(), + 'presences.presence1.delete'); }); }); } diff --git a/test/query_test.dart b/test/query_test.dart index dce037c0..db7b9214 100644 --- a/test/query_test.dart +++ b/test/query_test.dart @@ -63,12 +63,16 @@ void main() { group('notEqual()', () { for (var t in tests) { - test(t.description, () { - final query = jsonDecode(Query.notEqual('attr', t.value)); - expect(query['attribute'], 'attr'); - expect(query['values'], t.expectedValues); - expect(query['method'], 'notEqual'); - }, skip: t.value is List); + test( + t.description, + () { + final query = jsonDecode(Query.notEqual('attr', t.value)); + expect(query['attribute'], 'attr'); + expect(query['values'], t.expectedValues); + expect(query['method'], 'notEqual'); + }, + skip: t.value is List, + ); } }); diff --git a/test/services/account_test.dart b/test/services/account_test.dart index f0790ac8..d5d61fe7 100644 --- a/test/services/account_test.dart +++ b/test/services/account_test.dart @@ -18,18 +18,17 @@ class MockClient extends Mock implements Client { Map params = const {}, ResponseType? responseType, }) async { - return super.noSuchMethod( - Invocation.method(#call, [method]), - returnValue: Response(), - ); + return super.noSuchMethod(Invocation.method(#call, [method]), + returnValue: Response()); } @override - Future webAuth(Uri? url, {String? callbackUrlScheme}) async { - return super.noSuchMethod( - Invocation.method(#webAuth, [url]), - returnValue: 'done', - ); + Future webAuth( + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -42,15 +41,9 @@ class MockClient extends Mock implements Client { Function(UploadProgress)? onProgress, }) async { return super.noSuchMethod( - Invocation.method(#chunkedUpload, [ - path, - params, - paramName, - idParamName, - headers, - ]), - returnValue: Response(data: {}), - ); + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } @@ -84,9 +77,9 @@ void main() { 'accessedAt': '2020-10-15T06:38:00.000+00:00', }; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); final response = await account.get(); expect(response, isA()); @@ -112,14 +105,14 @@ void main() { 'accessedAt': '2020-10-15T06:38:00.000+00:00', }; - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); final response = await account.create( userId: '', email: 'email@example.com', - password: '', + password: 'password', ); expect(response, isA()); }); @@ -144,9 +137,9 @@ void main() { 'accessedAt': '2020-10-15T06:38:00.000+00:00', }; - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); final response = await account.updateEmail( email: 'email@example.com', @@ -156,11 +149,14 @@ void main() { }); test('test method listIdentities()', () async { - final Map data = {'total': 5, 'identities': []}; + final Map data = { + 'total': 5, + 'identities': [], + }; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); final response = await account.listIdentities(); expect(response, isA()); @@ -169,9 +165,9 @@ void main() { test('test method deleteIdentity()', () async { final data = ''; - when( - client.call(HttpMethod.delete), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); final response = await account.deleteIdentity( identityId: '', @@ -184,20 +180,23 @@ void main() { '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()); }); test('test method listLogs()', () async { - final Map data = {'total': 5, 'logs': []}; + final Map data = { + 'total': 5, + 'logs': [], + }; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); final response = await account.listLogs(); expect(response, isA()); @@ -223,11 +222,13 @@ void main() { 'accessedAt': '2020-10-15T06:38:00.000+00:00', }; - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); - final response = await account.updateMFA(mfa: true); + final response = await account.updateMFA( + mfa: true, + ); expect(response, isA()); }); @@ -238,9 +239,9 @@ void main() { 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', }; - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); final response = await account.createMfaAuthenticator( type: enums.AuthenticatorType.totp, @@ -255,9 +256,9 @@ void main() { 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', }; - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); final response = await account.createMFAAuthenticator( type: enums.AuthenticatorType.totp, @@ -285,9 +286,9 @@ void main() { 'accessedAt': '2020-10-15T06:38:00.000+00:00', }; - when( - client.call(HttpMethod.put), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); final response = await account.updateMfaAuthenticator( type: enums.AuthenticatorType.totp, @@ -316,9 +317,9 @@ void main() { 'accessedAt': '2020-10-15T06:38:00.000+00:00', }; - when( - client.call(HttpMethod.put), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); final response = await account.updateMFAAuthenticator( type: enums.AuthenticatorType.totp, @@ -330,9 +331,9 @@ void main() { test('test method deleteMfaAuthenticator()', () async { final data = ''; - when( - client.call(HttpMethod.delete), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); final response = await account.deleteMfaAuthenticator( type: enums.AuthenticatorType.totp, @@ -342,9 +343,9 @@ void main() { test('test method deleteMFAAuthenticator()', () async { final data = ''; - when( - client.call(HttpMethod.delete), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); final response = await account.deleteMFAAuthenticator( type: enums.AuthenticatorType.totp, @@ -359,9 +360,9 @@ void main() { 'expire': '2020-10-15T06:38:00.000+00:00', }; - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); final response = await account.createMfaChallenge( factor: enums.AuthenticationFactor.email, @@ -377,9 +378,9 @@ void main() { 'expire': '2020-10-15T06:38:00.000+00:00', }; - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); final response = await account.createMFAChallenge( factor: enums.AuthenticationFactor.email, @@ -420,9 +421,9 @@ void main() { 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', }; - when( - client.call(HttpMethod.put), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); final response = await account.updateMfaChallenge( challengeId: '', @@ -464,9 +465,9 @@ void main() { 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', }; - when( - client.call(HttpMethod.put), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); final response = await account.updateMFAChallenge( challengeId: '', @@ -483,9 +484,9 @@ void main() { 'recoveryCode': true, }; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); final response = await account.listMfaFactors(); expect(response, isA()); @@ -499,75 +500,87 @@ void main() { 'recoveryCode': true, }; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + 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': []}; + final Map data = { + 'recoveryCodes': [], + }; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + 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': []}; + final Map data = { + 'recoveryCodes': [], + }; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); final response = await account.getMFARecoveryCodes(); expect(response, isA()); }); test('test method createMfaRecoveryCodes()', () async { - final Map data = {'recoveryCodes': []}; + 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 createMFARecoveryCodes()', () async { - final Map data = {'recoveryCodes': []}; + 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 Map data = { + 'recoveryCodes': [], + }; - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); final response = await account.updateMfaRecoveryCodes(); expect(response, isA()); }); test('test method updateMFARecoveryCodes()', () async { - final Map data = {'recoveryCodes': []}; + final Map data = { + 'recoveryCodes': [], + }; - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); final response = await account.updateMFARecoveryCodes(); expect(response, isA()); @@ -593,11 +606,13 @@ void main() { 'accessedAt': '2020-10-15T06:38:00.000+00:00', }; - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); - final response = await account.updateName(name: ''); + final response = await account.updateName( + name: '', + ); expect(response, isA()); }); @@ -621,11 +636,13 @@ void main() { 'accessedAt': '2020-10-15T06:38:00.000+00:00', }; - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); - final response = await account.updatePassword(password: ''); + final response = await account.updatePassword( + password: 'password', + ); expect(response, isA()); }); @@ -649,9 +666,9 @@ void main() { 'accessedAt': '2020-10-15T06:38:00.000+00:00', }; - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); final response = await account.updatePhone( phone: '+12065550100', @@ -663,9 +680,9 @@ void main() { test('test method getPrefs()', () async { final Map data = {}; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); final response = await account.getPrefs(); expect(response, isA()); @@ -691,11 +708,13 @@ void main() { 'accessedAt': '2020-10-15T06:38:00.000+00:00', }; - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); - final response = await account.updatePrefs(prefs: {}); + final response = await account.updatePrefs( + prefs: {}, + ); expect(response, isA()); }); @@ -709,9 +728,9 @@ void main() { 'phrase': 'Golden Fox', }; - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); final response = await account.createRecovery( email: 'email@example.com', @@ -730,24 +749,27 @@ void main() { 'phrase': 'Golden Fox', }; - when( - client.call(HttpMethod.put), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); final response = await account.updateRecovery( userId: '', secret: '', - password: '', + password: 'password', ); expect(response, isA()); }); test('test method listSessions()', () async { - final Map data = {'total': 5, 'sessions': []}; + final Map data = { + 'total': 5, + 'sessions': [], + }; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); final response = await account.listSessions(); expect(response, isA()); @@ -756,9 +778,9 @@ void main() { test('test method deleteSessions()', () async { final data = ''; - when( - client.call(HttpMethod.delete), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); final response = await account.deleteSessions(); }); @@ -796,9 +818,9 @@ void main() { 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', }; - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); final response = await account.createAnonymousSession(); expect(response, isA()); @@ -837,9 +859,9 @@ void main() { 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', }; - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); final response = await account.createEmailPasswordSession( email: 'email@example.com', @@ -881,9 +903,9 @@ void main() { 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', }; - when( - client.call(HttpMethod.put), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); final response = await account.updateMagicURLSession( userId: '', @@ -893,7 +915,9 @@ void main() { }); test('test method createOAuth2Session()', () async { - when(client.webAuth(argThat(isNotNull))).thenAnswer((_) async => 'done'); + when(client.webAuth( + argThat(isNotNull), + )).thenAnswer((_) async => 'done'); final response = await account.createOAuth2Session( provider: enums.OAuthProvider.amazon, @@ -934,9 +958,9 @@ void main() { 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', }; - when( - client.call(HttpMethod.put), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); final response = await account.updatePhoneSession( userId: '', @@ -978,9 +1002,9 @@ void main() { 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', }; - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); final response = await account.createSession( userId: '', @@ -1022,11 +1046,13 @@ void main() { 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', }; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await account.getSession(sessionId: ''); + final response = await account.getSession( + sessionId: '', + ); expect(response, isA()); }); @@ -1063,22 +1089,26 @@ void main() { 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', }; - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); - final response = await account.updateSession(sessionId: ''); + 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)); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - final response = await account.deleteSession(sessionId: ''); + final response = await account.deleteSession( + sessionId: '', + ); }); test('test method updateStatus()', () async { @@ -1101,9 +1131,9 @@ void main() { 'accessedAt': '2020-10-15T06:38:00.000+00:00', }; - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); final response = await account.updateStatus(); expect(response, isA()); @@ -1121,9 +1151,9 @@ void main() { 'expired': true, }; - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); final response = await account.createPushTarget( targetId: '', @@ -1144,9 +1174,9 @@ void main() { 'expired': true, }; - when( - client.call(HttpMethod.put), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); final response = await account.updatePushTarget( targetId: '', @@ -1158,11 +1188,13 @@ void main() { test('test method deletePushTarget()', () async { final data = ''; - when( - client.call(HttpMethod.delete), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - final response = await account.deletePushTarget(targetId: ''); + final response = await account.deletePushTarget( + targetId: '', + ); }); test('test method createEmailToken()', () async { @@ -1175,9 +1207,9 @@ void main() { 'phrase': 'Golden Fox', }; - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); final response = await account.createEmailToken( userId: '', @@ -1196,9 +1228,9 @@ void main() { 'phrase': 'Golden Fox', }; - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); final response = await account.createMagicURLToken( userId: '', @@ -1208,7 +1240,9 @@ void main() { }); test('test method createOAuth2Token()', () async { - when(client.webAuth(argThat(isNotNull))).thenAnswer((_) async => 'done'); + when(client.webAuth( + argThat(isNotNull), + )).thenAnswer((_) async => 'done'); final response = await account.createOAuth2Token( provider: enums.OAuthProvider.amazon, @@ -1226,9 +1260,9 @@ void main() { 'phrase': 'Golden Fox', }; - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); final response = await account.createPhoneToken( userId: '', @@ -1247,9 +1281,9 @@ void main() { 'phrase': 'Golden Fox', }; - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); final response = await account.createEmailVerification( url: 'https://example.com', @@ -1267,9 +1301,9 @@ void main() { 'phrase': 'Golden Fox', }; - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); final response = await account.createVerification( url: 'https://example.com', @@ -1287,9 +1321,9 @@ void main() { 'phrase': 'Golden Fox', }; - when( - client.call(HttpMethod.put), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); final response = await account.updateEmailVerification( userId: '', @@ -1308,9 +1342,9 @@ void main() { 'phrase': 'Golden Fox', }; - when( - client.call(HttpMethod.put), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); final response = await account.updateVerification( userId: '', @@ -1329,9 +1363,9 @@ void main() { 'phrase': 'Golden Fox', }; - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); final response = await account.createPhoneVerification(); expect(response, isA()); @@ -1347,9 +1381,9 @@ void main() { 'phrase': 'Golden Fox', }; - when( - client.call(HttpMethod.put), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); final response = await account.updatePhoneVerification( userId: '', diff --git a/test/services/avatars_test.dart b/test/services/avatars_test.dart index 5b4a7340..8d2c48fb 100644 --- a/test/services/avatars_test.dart +++ b/test/services/avatars_test.dart @@ -18,18 +18,17 @@ class MockClient extends Mock implements Client { Map params = const {}, ResponseType? responseType, }) async { - return super.noSuchMethod( - Invocation.method(#call, [method]), - returnValue: Response(), - ); + return super.noSuchMethod(Invocation.method(#call, [method]), + returnValue: Response()); } @override - Future webAuth(Uri? url, {String? callbackUrlScheme}) async { - return super.noSuchMethod( - Invocation.method(#webAuth, [url]), - returnValue: 'done', - ); + Future webAuth( + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -42,15 +41,9 @@ class MockClient extends Mock implements Client { Function(UploadProgress)? onProgress, }) async { return super.noSuchMethod( - Invocation.method(#chunkedUpload, [ - path, - params, - paramName, - idParamName, - headers, - ]), - returnValue: Response(data: {}), - ); + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } @@ -67,9 +60,9 @@ void main() { 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, @@ -80,9 +73,9 @@ void main() { test('test method getCreditCard()', () async { final Uint8List data = Uint8List.fromList([]); - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); final response = await avatars.getCreditCard( code: enums.CreditCard.americanExpress, @@ -93,42 +86,48 @@ void main() { test('test method getFavicon()', () async { final Uint8List data = Uint8List.fromList([]); - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await avatars.getFavicon(url: 'https://example.com'); + final response = await avatars.getFavicon( + url: 'https://example.com', + ); expect(response, isA()); }); test('test method getFlag()', () async { final Uint8List data = Uint8List.fromList([]); - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await avatars.getFlag(code: enums.Flag.afghanistan); + final response = await avatars.getFlag( + code: enums.Flag.afghanistan, + ); expect(response, isA()); }); test('test method getImage()', () async { final Uint8List data = Uint8List.fromList([]); - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await avatars.getImage(url: 'https://example.com'); + final response = await avatars.getImage( + url: 'https://example.com', + ); expect(response, isA()); }); test('test method getInitials()', () async { final Uint8List data = Uint8List.fromList([]); - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); final response = await avatars.getInitials(); expect(response, isA()); @@ -137,22 +136,26 @@ void main() { test('test method getQR()', () async { final Uint8List data = Uint8List.fromList([]); - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await avatars.getQR(text: ''); + final response = await avatars.getQR( + text: '', + ); expect(response, isA()); }); test('test method getScreenshot()', () async { final Uint8List data = Uint8List.fromList([]); - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await avatars.getScreenshot(url: 'https://example.com'); + final response = await avatars.getScreenshot( + url: 'https://example.com', + ); expect(response, isA()); }); }); diff --git a/test/services/databases_test.dart b/test/services/databases_test.dart index 1cd1e982..a3807093 100644 --- a/test/services/databases_test.dart +++ b/test/services/databases_test.dart @@ -18,18 +18,17 @@ class MockClient extends Mock implements Client { Map params = const {}, ResponseType? responseType, }) async { - return super.noSuchMethod( - Invocation.method(#call, [method]), - returnValue: Response(), - ); + return super.noSuchMethod(Invocation.method(#call, [method]), + returnValue: Response()); } @override - Future webAuth(Uri? url, {String? callbackUrlScheme}) async { - return super.noSuchMethod( - Invocation.method(#webAuth, [url]), - returnValue: 'done', - ); + Future webAuth( + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -42,15 +41,9 @@ class MockClient extends Mock implements Client { Function(UploadProgress)? onProgress, }) async { return super.noSuchMethod( - Invocation.method(#chunkedUpload, [ - path, - params, - paramName, - idParamName, - headers, - ]), - returnValue: Response(data: {}), - ); + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } @@ -65,11 +58,14 @@ void main() { }); test('test method listTransactions()', () async { - final Map data = {'total': 5, 'transactions': []}; + final Map data = { + 'total': 5, + 'transactions': [], + }; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); final response = await databases.listTransactions(); expect(response, isA()); @@ -85,9 +81,9 @@ void main() { 'expiresAt': '2020-10-15T06:38:00.000+00:00', }; - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); final response = await databases.createTransaction(); expect(response, isA()); @@ -103,9 +99,9 @@ void main() { 'expiresAt': '2020-10-15T06:38:00.000+00:00', }; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); final response = await databases.getTransaction( transactionId: '', @@ -123,9 +119,9 @@ void main() { 'expiresAt': '2020-10-15T06:38:00.000+00:00', }; - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); final response = await databases.updateTransaction( transactionId: '', @@ -136,9 +132,9 @@ void main() { test('test method deleteTransaction()', () async { final data = ''; - when( - client.call(HttpMethod.delete), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); final response = await databases.deleteTransaction( transactionId: '', @@ -155,9 +151,9 @@ void main() { 'expiresAt': '2020-10-15T06:38:00.000+00:00', }; - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); final response = await databases.createOperations( transactionId: '', @@ -166,11 +162,14 @@ void main() { }); test('test method listDocuments()', () async { - final Map data = {'total': 5, 'documents': []}; + final Map data = { + 'total': 5, + 'documents': [], + }; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); final response = await databases.listDocuments( databaseId: '', @@ -190,9 +189,9 @@ void main() { '\$permissions': [], }; - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); final response = await databases.createDocument( databaseId: '', @@ -214,9 +213,9 @@ void main() { '\$permissions': [], }; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); final response = await databases.getDocument( databaseId: '', @@ -237,9 +236,9 @@ void main() { '\$permissions': [], }; - when( - client.call(HttpMethod.put), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); final response = await databases.upsertDocument( databaseId: '', @@ -260,9 +259,9 @@ void main() { '\$permissions': [], }; - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); final response = await databases.updateDocument( databaseId: '', @@ -275,9 +274,9 @@ void main() { test('test method deleteDocument()', () async { final data = ''; - when( - client.call(HttpMethod.delete), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); final response = await databases.deleteDocument( databaseId: '', @@ -297,9 +296,9 @@ void main() { '\$permissions': [], }; - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); final response = await databases.decrementDocumentAttribute( databaseId: '', @@ -321,9 +320,9 @@ void main() { '\$permissions': [], }; - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); final response = await databases.incrementDocumentAttribute( databaseId: '', diff --git a/test/services/functions_test.dart b/test/services/functions_test.dart index 119f56f9..c6e50a50 100644 --- a/test/services/functions_test.dart +++ b/test/services/functions_test.dart @@ -18,18 +18,17 @@ class MockClient extends Mock implements Client { Map params = const {}, ResponseType? responseType, }) async { - return super.noSuchMethod( - Invocation.method(#call, [method]), - returnValue: Response(), - ); + return super.noSuchMethod(Invocation.method(#call, [method]), + returnValue: Response()); } @override - Future webAuth(Uri? url, {String? callbackUrlScheme}) async { - return super.noSuchMethod( - Invocation.method(#webAuth, [url]), - returnValue: 'done', - ); + Future webAuth( + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -42,15 +41,9 @@ class MockClient extends Mock implements Client { Function(UploadProgress)? onProgress, }) async { return super.noSuchMethod( - Invocation.method(#chunkedUpload, [ - path, - params, - paramName, - idParamName, - headers, - ]), - returnValue: Response(data: {}), - ); + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } @@ -65,11 +58,14 @@ void main() { }); test('test method listExecutions()', () async { - final Map data = {'total': 5, 'executions': []}; + final Map data = { + 'total': 5, + 'executions': [], + }; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); final response = await functions.listExecutions( functionId: '', @@ -98,9 +94,9 @@ void main() { 'duration': 0.4, }; - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); final response = await functions.createExecution( functionId: '', @@ -129,9 +125,9 @@ void main() { 'duration': 0.4, }; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); final response = await functions.getExecution( functionId: '', diff --git a/test/services/graphql_test.dart b/test/services/graphql_test.dart index 59026cd2..84b7de1c 100644 --- a/test/services/graphql_test.dart +++ b/test/services/graphql_test.dart @@ -18,18 +18,17 @@ class MockClient extends Mock implements Client { Map params = const {}, ResponseType? responseType, }) async { - return super.noSuchMethod( - Invocation.method(#call, [method]), - returnValue: Response(), - ); + return super.noSuchMethod(Invocation.method(#call, [method]), + returnValue: Response()); } @override - Future webAuth(Uri? url, {String? callbackUrlScheme}) async { - return super.noSuchMethod( - Invocation.method(#webAuth, [url]), - returnValue: 'done', - ); + Future webAuth( + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -42,15 +41,9 @@ class MockClient extends Mock implements Client { Function(UploadProgress)? onProgress, }) async { return super.noSuchMethod( - Invocation.method(#chunkedUpload, [ - path, - params, - paramName, - idParamName, - headers, - ]), - returnValue: Response(data: {}), - ); + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } @@ -67,21 +60,25 @@ void main() { test('test method query()', () 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: {}); + final response = await graphql.query( + query: {}, + ); }); 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.mutation(query: {}); + final response = await graphql.mutation( + query: {}, + ); }); }); } diff --git a/test/services/locale_test.dart b/test/services/locale_test.dart index 4fabebb0..f9f6489d 100644 --- a/test/services/locale_test.dart +++ b/test/services/locale_test.dart @@ -18,18 +18,17 @@ class MockClient extends Mock implements Client { Map params = const {}, ResponseType? responseType, }) async { - return super.noSuchMethod( - Invocation.method(#call, [method]), - returnValue: Response(), - ); + return super.noSuchMethod(Invocation.method(#call, [method]), + returnValue: Response()); } @override - Future webAuth(Uri? url, {String? callbackUrlScheme}) async { - return super.noSuchMethod( - Invocation.method(#webAuth, [url]), - returnValue: 'done', - ); + Future webAuth( + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -42,15 +41,9 @@ class MockClient extends Mock implements Client { Function(UploadProgress)? onProgress, }) async { return super.noSuchMethod( - Invocation.method(#chunkedUpload, [ - path, - params, - paramName, - idParamName, - headers, - ]), - returnValue: Response(data: {}), - ); + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } @@ -75,86 +68,107 @@ void main() { 'currency': 'USD', }; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + 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': []}; + final Map data = { + 'total': 5, + 'localeCodes': [], + }; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); final response = await locale.listCodes(); expect(response, isA()); }); test('test method listContinents()', () async { - final Map data = {'total': 5, 'continents': []}; + final 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()); }); test('test method listCountries()', () async { - final Map data = {'total': 5, 'countries': []}; + 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.listCountries(); expect(response, isA()); }); test('test method listCountriesEU()', () async { - final Map data = {'total': 5, 'countries': []}; + 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()); }); test('test method listCountriesPhones()', () async { - final Map data = {'total': 5, 'phones': []}; + final Map data = { + 'total': 5, + 'phones': [], + }; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); final response = await locale.listCountriesPhones(); expect(response, isA()); }); test('test method listCurrencies()', () async { - final Map data = {'total': 5, 'currencies': []}; + 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()); }); test('test method listLanguages()', () async { - final Map data = {'total': 5, 'languages': []}; + final Map data = { + 'total': 5, + 'languages': [], + }; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); final response = await locale.listLanguages(); expect(response, isA()); diff --git a/test/services/messaging_test.dart b/test/services/messaging_test.dart index 96484f89..0c938eff 100644 --- a/test/services/messaging_test.dart +++ b/test/services/messaging_test.dart @@ -18,18 +18,17 @@ class MockClient extends Mock implements Client { Map params = const {}, ResponseType? responseType, }) async { - return super.noSuchMethod( - Invocation.method(#call, [method]), - returnValue: Response(), - ); + return super.noSuchMethod(Invocation.method(#call, [method]), + returnValue: Response()); } @override - Future webAuth(Uri? url, {String? callbackUrlScheme}) async { - return super.noSuchMethod( - Invocation.method(#webAuth, [url]), - returnValue: 'done', - ); + Future webAuth( + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -42,15 +41,9 @@ class MockClient extends Mock implements Client { Function(UploadProgress)? onProgress, }) async { return super.noSuchMethod( - Invocation.method(#chunkedUpload, [ - path, - params, - paramName, - idParamName, - headers, - ]), - returnValue: Response(data: {}), - ); + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } @@ -86,9 +79,9 @@ void main() { 'providerType': 'email', }; - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); final response = await messaging.createSubscriber( topicId: '', @@ -101,9 +94,9 @@ void main() { test('test method deleteSubscriber()', () async { final data = ''; - when( - client.call(HttpMethod.delete), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); final response = await messaging.deleteSubscriber( topicId: '', diff --git a/test/services/presences_test.dart b/test/services/presences_test.dart index 02e8a8a7..7fed0439 100644 --- a/test/services/presences_test.dart +++ b/test/services/presences_test.dart @@ -18,18 +18,17 @@ class MockClient extends Mock implements Client { Map params = const {}, ResponseType? responseType, }) async { - return super.noSuchMethod( - Invocation.method(#call, [method]), - returnValue: Response(), - ); + return super.noSuchMethod(Invocation.method(#call, [method]), + returnValue: Response()); } @override - Future webAuth(Uri? url, {String? callbackUrlScheme}) async { - return super.noSuchMethod( - Invocation.method(#webAuth, [url]), - returnValue: 'done', - ); + Future webAuth( + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -42,15 +41,9 @@ class MockClient extends Mock implements Client { Function(UploadProgress)? onProgress, }) async { return super.noSuchMethod( - Invocation.method(#chunkedUpload, [ - path, - params, - paramName, - idParamName, - headers, - ]), - returnValue: Response(data: {}), - ); + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } @@ -65,11 +58,14 @@ void main() { }); test('test method list()', () async { - final Map data = {'total': 5, 'presences': []}; + final Map data = { + 'total': 5, + 'presences': [], + }; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); final response = await presences.list(); expect(response, isA()); @@ -85,11 +81,13 @@ void main() { 'source': 'HTTP', }; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await presences.get(presenceId: ''); + final response = await presences.get( + presenceId: '', + ); expect(response, isA()); }); @@ -103,9 +101,9 @@ void main() { 'source': 'HTTP', }; - when( - client.call(HttpMethod.put), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); final response = await presences.upsert( presenceId: '', @@ -124,22 +122,26 @@ void main() { 'source': 'HTTP', }; - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); - final response = await presences.update(presenceId: ''); + final response = await presences.update( + presenceId: '', + ); expect(response, isA()); }); test('test method delete()', () async { final data = ''; - when( - client.call(HttpMethod.delete), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - final response = await presences.delete(presenceId: ''); + final response = await presences.delete( + presenceId: '', + ); }); }); } diff --git a/test/services/storage_test.dart b/test/services/storage_test.dart index 4326f3d0..55a42f94 100644 --- a/test/services/storage_test.dart +++ b/test/services/storage_test.dart @@ -18,18 +18,17 @@ class MockClient extends Mock implements Client { Map params = const {}, ResponseType? responseType, }) async { - return super.noSuchMethod( - Invocation.method(#call, [method]), - returnValue: Response(), - ); + return super.noSuchMethod(Invocation.method(#call, [method]), + returnValue: Response()); } @override - Future webAuth(Uri? url, {String? callbackUrlScheme}) async { - return super.noSuchMethod( - Invocation.method(#webAuth, [url]), - returnValue: 'done', - ); + Future webAuth( + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -42,15 +41,9 @@ class MockClient extends Mock implements Client { Function(UploadProgress)? onProgress, }) async { return super.noSuchMethod( - Invocation.method(#chunkedUpload, [ - path, - params, - paramName, - idParamName, - headers, - ]), - returnValue: Response(data: {}), - ); + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } @@ -65,13 +58,18 @@ void main() { }); test('test method listFiles()', () async { - final Map data = {'total': 5, 'files': []}; + final Map data = { + 'total': 5, + 'files': [], + }; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await storage.listFiles(bucketId: ''); + final response = await storage.listFiles( + bucketId: '', + ); expect(response, isA()); }); @@ -93,15 +91,13 @@ void main() { 'compression': 'gzip', }; - when( - client.chunkedUpload( - path: argThat(isNotNull), - params: argThat(isNotNull), - paramName: argThat(isNotNull), - idParamName: argThat(isNotNull), - headers: argThat(isNotNull), - ), - ).thenAnswer((_) async => Response(data: data)); + 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: '', @@ -129,9 +125,9 @@ void main() { 'compression': 'gzip', }; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); final response = await storage.getFile( bucketId: '', @@ -158,9 +154,9 @@ void main() { 'compression': 'gzip', }; - when( - client.call(HttpMethod.put), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); final response = await storage.updateFile( bucketId: '', @@ -172,9 +168,9 @@ void main() { test('test method deleteFile()', () async { final data = ''; - when( - client.call(HttpMethod.delete), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); final response = await storage.deleteFile( bucketId: '', @@ -185,9 +181,9 @@ void main() { test('test method getFileDownload()', () 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.getFileDownload( bucketId: '', @@ -199,9 +195,9 @@ void main() { 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: '', @@ -213,9 +209,9 @@ void main() { test('test method getFileView()', () 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.getFileView( bucketId: '', diff --git a/test/services/tables_db_test.dart b/test/services/tables_db_test.dart index 935db401..f318cad2 100644 --- a/test/services/tables_db_test.dart +++ b/test/services/tables_db_test.dart @@ -18,18 +18,17 @@ class MockClient extends Mock implements Client { Map params = const {}, ResponseType? responseType, }) async { - return super.noSuchMethod( - Invocation.method(#call, [method]), - returnValue: Response(), - ); + return super.noSuchMethod(Invocation.method(#call, [method]), + returnValue: Response()); } @override - Future webAuth(Uri? url, {String? callbackUrlScheme}) async { - return super.noSuchMethod( - Invocation.method(#webAuth, [url]), - returnValue: 'done', - ); + Future webAuth( + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -42,15 +41,9 @@ class MockClient extends Mock implements Client { Function(UploadProgress)? onProgress, }) async { return super.noSuchMethod( - Invocation.method(#chunkedUpload, [ - path, - params, - paramName, - idParamName, - headers, - ]), - returnValue: Response(data: {}), - ); + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } @@ -65,11 +58,14 @@ void main() { }); test('test method listTransactions()', () async { - final Map data = {'total': 5, 'transactions': []}; + final Map data = { + 'total': 5, + 'transactions': [], + }; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); final response = await tablesDB.listTransactions(); expect(response, isA()); @@ -85,9 +81,9 @@ void main() { 'expiresAt': '2020-10-15T06:38:00.000+00:00', }; - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); final response = await tablesDB.createTransaction(); expect(response, isA()); @@ -103,9 +99,9 @@ void main() { 'expiresAt': '2020-10-15T06:38:00.000+00:00', }; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); final response = await tablesDB.getTransaction( transactionId: '', @@ -123,9 +119,9 @@ void main() { 'expiresAt': '2020-10-15T06:38:00.000+00:00', }; - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); final response = await tablesDB.updateTransaction( transactionId: '', @@ -136,9 +132,9 @@ void main() { test('test method deleteTransaction()', () async { final data = ''; - when( - client.call(HttpMethod.delete), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); final response = await tablesDB.deleteTransaction( transactionId: '', @@ -155,9 +151,9 @@ void main() { 'expiresAt': '2020-10-15T06:38:00.000+00:00', }; - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); final response = await tablesDB.createOperations( transactionId: '', @@ -166,11 +162,14 @@ void main() { }); test('test method listRows()', () async { - final Map data = {'total': 5, 'rows': []}; + final Map data = { + 'total': 5, + 'rows': [], + }; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); final response = await tablesDB.listRows( databaseId: '', @@ -190,9 +189,9 @@ void main() { '\$permissions': [], }; - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); final response = await tablesDB.createRow( databaseId: '', @@ -214,9 +213,9 @@ void main() { '\$permissions': [], }; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); final response = await tablesDB.getRow( databaseId: '', @@ -237,9 +236,9 @@ void main() { '\$permissions': [], }; - when( - client.call(HttpMethod.put), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); final response = await tablesDB.upsertRow( databaseId: '', @@ -260,9 +259,9 @@ void main() { '\$permissions': [], }; - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); final response = await tablesDB.updateRow( databaseId: '', @@ -275,9 +274,9 @@ void main() { test('test method deleteRow()', () async { final data = ''; - when( - client.call(HttpMethod.delete), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); final response = await tablesDB.deleteRow( databaseId: '', @@ -297,9 +296,9 @@ void main() { '\$permissions': [], }; - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); final response = await tablesDB.decrementRowColumn( databaseId: '', @@ -321,9 +320,9 @@ void main() { '\$permissions': [], }; - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); final response = await tablesDB.incrementRowColumn( databaseId: '', diff --git a/test/services/teams_test.dart b/test/services/teams_test.dart index 30fcc639..83f2667b 100644 --- a/test/services/teams_test.dart +++ b/test/services/teams_test.dart @@ -18,18 +18,17 @@ class MockClient extends Mock implements Client { Map params = const {}, ResponseType? responseType, }) async { - return super.noSuchMethod( - Invocation.method(#call, [method]), - returnValue: Response(), - ); + return super.noSuchMethod(Invocation.method(#call, [method]), + returnValue: Response()); } @override - Future webAuth(Uri? url, {String? callbackUrlScheme}) async { - return super.noSuchMethod( - Invocation.method(#webAuth, [url]), - returnValue: 'done', - ); + Future webAuth( + Uri? url, { + String? callbackUrlScheme, + }) async { + return super + .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); } @override @@ -42,15 +41,9 @@ class MockClient extends Mock implements Client { Function(UploadProgress)? onProgress, }) async { return super.noSuchMethod( - Invocation.method(#chunkedUpload, [ - path, - params, - paramName, - idParamName, - headers, - ]), - returnValue: Response(data: {}), - ); + Invocation.method( + #chunkedUpload, [path, params, paramName, idParamName, headers]), + returnValue: Response(data: {})); } } @@ -65,11 +58,14 @@ void main() { }); test('test method list()', () async { - final Map data = {'total': 5, 'teams': []}; + final Map data = { + 'total': 5, + 'teams': [], + }; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); final response = await teams.list(); expect(response, isA()); @@ -85,11 +81,14 @@ void main() { 'prefs': {}, }; - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); - final response = await teams.create(teamId: '', name: ''); + final response = await teams.create( + teamId: '', + name: '', + ); expect(response, isA()); }); @@ -103,11 +102,13 @@ void main() { 'prefs': {}, }; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await teams.get(teamId: ''); + final response = await teams.get( + teamId: '', + ); expect(response, isA()); }); @@ -121,9 +122,9 @@ void main() { 'prefs': {}, }; - when( - client.call(HttpMethod.put), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); final response = await teams.updateName( teamId: '', @@ -135,21 +136,28 @@ void main() { test('test method delete()', () async { final data = ''; - when( - client.call(HttpMethod.delete), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); - final response = await teams.delete(teamId: ''); + final response = await teams.delete( + teamId: '', + ); }); test('test method listMemberships()', () async { - final Map data = {'total': 5, 'memberships': []}; + final Map data = { + 'total': 5, + 'memberships': [], + }; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await teams.listMemberships(teamId: ''); + final response = await teams.listMemberships( + teamId: '', + ); expect(response, isA()); }); @@ -172,9 +180,9 @@ void main() { 'roles': [], }; - when( - client.call(HttpMethod.post), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); final response = await teams.createMembership( teamId: '', @@ -202,9 +210,9 @@ void main() { 'roles': [], }; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); final response = await teams.getMembership( teamId: '', @@ -232,9 +240,9 @@ void main() { 'roles': [], }; - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); final response = await teams.updateMembership( teamId: '', @@ -247,9 +255,9 @@ void main() { test('test method deleteMembership()', () async { final data = ''; - when( - client.call(HttpMethod.delete), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); final response = await teams.deleteMembership( teamId: '', @@ -276,9 +284,9 @@ void main() { 'roles': [], }; - when( - client.call(HttpMethod.patch), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); final response = await teams.updateMembershipStatus( teamId: '', @@ -292,22 +300,27 @@ void main() { test('test method getPrefs()', () async { final Map data = {}; - when( - client.call(HttpMethod.get), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); - final response = await teams.getPrefs(teamId: ''); + final response = await teams.getPrefs( + teamId: '', + ); expect(response, isA()); }); test('test method updatePrefs()', () async { final Map data = {}; - when( - client.call(HttpMethod.put), - ).thenAnswer((_) async => Response(data: data)); + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); - final response = await teams.updatePrefs(teamId: '', prefs: {}); + final response = await teams.updatePrefs( + teamId: '', + prefs: {}, + ); expect(response, isA()); }); }); diff --git a/test/src/cookie_manager_test.dart b/test/src/cookie_manager_test.dart index b20f6ff1..c6343f72 100644 --- a/test/src/cookie_manager_test.dart +++ b/test/src/cookie_manager_test.dart @@ -11,7 +11,10 @@ void main() { Cookie('name2', 'value2'), ]; - expect(CookieManager.getCookies(cookies), "name=value; name2=value2"); + expect( + CookieManager.getCookies(cookies), + "name=value; name2=value2", + ); }); }); @@ -32,12 +35,17 @@ void main() { test('with cookie', () async { final uri = Uri.parse('https://appwrite.io'); - final cookies = [Cookie('name', 'value'), Cookie('name2', 'value2')]; + final cookies = [ + Cookie('name', 'value'), + Cookie('name2', 'value2'), + ]; cookieJar.saveFromResponse(uri, cookies); final request = Request('GET', uri); await cookieManager.onRequest(request); - expect(request.headers, {'cookie': 'name=value; name2=value2'}); + expect(request.headers, { + 'cookie': 'name=value; name2=value2', + }); }); }); @@ -53,7 +61,12 @@ void main() { test('without cookie', () async { final uri = Uri.parse('https://appwrite.io'); final request = Request('POST', uri); - final response = Response('body', 200, headers: {}, request: request); + final response = Response( + 'body', + 200, + headers: {}, + request: request, + ); await cookieManager.onResponse(response); @@ -68,7 +81,9 @@ void main() { final response = Response( 'body', 200, - headers: {'set-cookie': 'name=value'}, + headers: { + 'set-cookie': 'name=value', + }, request: request, ); diff --git a/test/src/exception_test.dart b/test/src/exception_test.dart index 10db5745..c3de9fcb 100644 --- a/test/src/exception_test.dart +++ b/test/src/exception_test.dart @@ -20,7 +20,9 @@ void main() { ); expect( exception3.toString(), - equals('AppwriteException: ValidationError, Invalid request (400)'), + equals( + 'AppwriteException: ValidationError, Invalid request (400)', + ), ); }); }); diff --git a/test/src/input_file_test.dart b/test/src/input_file_test.dart index 046fa07b..3d301a85 100644 --- a/test/src/input_file_test.dart +++ b/test/src/input_file_test.dart @@ -7,26 +7,22 @@ void main() { test('throws exception when neither path nor bytes are provided', () { expect( () => InputFile(), - throwsA( - isA().having( - (e) => e.message, - 'message', - 'One of `path` or `bytes` is required', - ), - ), + throwsA(isA().having( + (e) => e.message, + 'message', + 'One of `path` or `bytes` is required', + )), ); }); test('throws exception when path and bytes are both null', () { expect( () => InputFile(path: null, bytes: null), - throwsA( - isA().having( - (e) => e.message, - 'message', - 'One of `path` or `bytes` is required', - ), - ), + throwsA(isA().having( + (e) => e.message, + 'message', + 'One of `path` or `bytes` is required', + )), ); }); diff --git a/test/src/models/algo_bcrypt_test.dart b/test/src/models/algo_bcrypt_test.dart index 949502ca..3da36624 100644 --- a/test/src/models/algo_bcrypt_test.dart +++ b/test/src/models/algo_bcrypt_test.dart @@ -4,7 +4,9 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('AlgoBcrypt', () { test('model', () { - final model = AlgoBcrypt(type: 'bcrypt'); + final model = AlgoBcrypt( + type: 'bcrypt', + ); final map = model.toMap(); final result = AlgoBcrypt.fromMap(map); diff --git a/test/src/models/algo_md5_test.dart b/test/src/models/algo_md5_test.dart index bfeb1de2..e58fa5b5 100644 --- a/test/src/models/algo_md5_test.dart +++ b/test/src/models/algo_md5_test.dart @@ -4,7 +4,9 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('AlgoMd5', () { test('model', () { - final model = AlgoMd5(type: 'md5'); + final model = AlgoMd5( + type: 'md5', + ); final map = model.toMap(); final result = AlgoMd5.fromMap(map); diff --git a/test/src/models/algo_phpass_test.dart b/test/src/models/algo_phpass_test.dart index 0141ca54..3bcbb488 100644 --- a/test/src/models/algo_phpass_test.dart +++ b/test/src/models/algo_phpass_test.dart @@ -4,7 +4,9 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('AlgoPhpass', () { test('model', () { - final model = AlgoPhpass(type: 'phpass'); + final model = AlgoPhpass( + type: 'phpass', + ); final map = model.toMap(); final result = AlgoPhpass.fromMap(map); diff --git a/test/src/models/algo_scrypt_modified_test.dart b/test/src/models/algo_scrypt_modified_test.dart index 0103ed60..b2084927 100644 --- a/test/src/models/algo_scrypt_modified_test.dart +++ b/test/src/models/algo_scrypt_modified_test.dart @@ -18,10 +18,8 @@ void main() { expect(result.type, 'scryptMod'); expect(result.salt, 'UxLMreBr6tYyjQ=='); expect(result.saltSeparator, 'Bw=='); - expect( - result.signerKey, - 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ==', - ); + expect(result.signerKey, + 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ=='); }); }); } diff --git a/test/src/models/algo_sha_test.dart b/test/src/models/algo_sha_test.dart index 205ab2d3..d080569c 100644 --- a/test/src/models/algo_sha_test.dart +++ b/test/src/models/algo_sha_test.dart @@ -4,7 +4,9 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('AlgoSha', () { test('model', () { - final model = AlgoSha(type: 'sha'); + final model = AlgoSha( + type: 'sha', + ); final map = model.toMap(); final result = AlgoSha.fromMap(map); diff --git a/test/src/models/continent_list_test.dart b/test/src/models/continent_list_test.dart index b12c806b..e71dcae1 100644 --- a/test/src/models/continent_list_test.dart +++ b/test/src/models/continent_list_test.dart @@ -4,7 +4,10 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('ContinentList', () { test('model', () { - final model = ContinentList(total: 5, continents: []); + final model = ContinentList( + total: 5, + continents: [], + ); final map = model.toMap(); final result = ContinentList.fromMap(map); diff --git a/test/src/models/continent_test.dart b/test/src/models/continent_test.dart index e8afc544..85e559f5 100644 --- a/test/src/models/continent_test.dart +++ b/test/src/models/continent_test.dart @@ -4,7 +4,10 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('Continent', () { test('model', () { - final model = Continent(name: 'Europe', code: 'EU'); + final model = Continent( + name: 'Europe', + code: 'EU', + ); final map = model.toMap(); final result = Continent.fromMap(map); diff --git a/test/src/models/country_list_test.dart b/test/src/models/country_list_test.dart index 42736ba9..6df5c584 100644 --- a/test/src/models/country_list_test.dart +++ b/test/src/models/country_list_test.dart @@ -4,7 +4,10 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('CountryList', () { test('model', () { - final model = CountryList(total: 5, countries: []); + final model = CountryList( + total: 5, + countries: [], + ); final map = model.toMap(); final result = CountryList.fromMap(map); diff --git a/test/src/models/country_test.dart b/test/src/models/country_test.dart index 1fe85efe..d5404a7f 100644 --- a/test/src/models/country_test.dart +++ b/test/src/models/country_test.dart @@ -4,7 +4,10 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('Country', () { test('model', () { - final model = Country(name: 'United States', code: 'US'); + final model = Country( + name: 'United States', + code: 'US', + ); final map = model.toMap(); final result = Country.fromMap(map); diff --git a/test/src/models/currency_list_test.dart b/test/src/models/currency_list_test.dart index d110e0e9..d7410db8 100644 --- a/test/src/models/currency_list_test.dart +++ b/test/src/models/currency_list_test.dart @@ -4,7 +4,10 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('CurrencyList', () { test('model', () { - final model = CurrencyList(total: 5, currencies: []); + final model = CurrencyList( + total: 5, + currencies: [], + ); final map = model.toMap(); final result = CurrencyList.fromMap(map); diff --git a/test/src/models/document_list_test.dart b/test/src/models/document_list_test.dart index 4cb4a66a..217d37e8 100644 --- a/test/src/models/document_list_test.dart +++ b/test/src/models/document_list_test.dart @@ -4,7 +4,10 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('DocumentList', () { test('model', () { - final model = DocumentList(total: 5, documents: []); + final model = DocumentList( + total: 5, + documents: [], + ); final map = model.toMap(); final result = DocumentList.fromMap(map); diff --git a/test/src/models/execution_list_test.dart b/test/src/models/execution_list_test.dart index 32b82cb9..a3305e55 100644 --- a/test/src/models/execution_list_test.dart +++ b/test/src/models/execution_list_test.dart @@ -4,7 +4,10 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('ExecutionList', () { test('model', () { - final model = ExecutionList(total: 5, executions: []); + final model = ExecutionList( + total: 5, + executions: [], + ); final map = model.toMap(); final result = ExecutionList.fromMap(map); diff --git a/test/src/models/file_list_test.dart b/test/src/models/file_list_test.dart index 5761b36a..8e02f65e 100644 --- a/test/src/models/file_list_test.dart +++ b/test/src/models/file_list_test.dart @@ -4,7 +4,10 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('FileList', () { test('model', () { - final model = FileList(total: 5, files: []); + final model = FileList( + total: 5, + files: [], + ); final map = model.toMap(); final result = FileList.fromMap(map); diff --git a/test/src/models/headers_test.dart b/test/src/models/headers_test.dart index 1c36d21a..9252b469 100644 --- a/test/src/models/headers_test.dart +++ b/test/src/models/headers_test.dart @@ -4,7 +4,10 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('Headers', () { test('model', () { - final model = Headers(name: 'Content-Type', value: 'application/json'); + final model = Headers( + name: 'Content-Type', + value: 'application/json', + ); final map = model.toMap(); final result = Headers.fromMap(map); diff --git a/test/src/models/identity_list_test.dart b/test/src/models/identity_list_test.dart index f8078db9..8c35afec 100644 --- a/test/src/models/identity_list_test.dart +++ b/test/src/models/identity_list_test.dart @@ -4,7 +4,10 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('IdentityList', () { test('model', () { - final model = IdentityList(total: 5, identities: []); + final model = IdentityList( + total: 5, + identities: [], + ); final map = model.toMap(); final result = IdentityList.fromMap(map); diff --git a/test/src/models/jwt_test.dart b/test/src/models/jwt_test.dart index c2166441..93376af1 100644 --- a/test/src/models/jwt_test.dart +++ b/test/src/models/jwt_test.dart @@ -12,10 +12,8 @@ void main() { final map = model.toMap(); final result = Jwt.fromMap(map); - expect( - result.jwt, - 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', - ); + expect(result.jwt, + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'); }); }); } diff --git a/test/src/models/language_list_test.dart b/test/src/models/language_list_test.dart index 919fd9d1..a07c0b5f 100644 --- a/test/src/models/language_list_test.dart +++ b/test/src/models/language_list_test.dart @@ -4,7 +4,10 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('LanguageList', () { test('model', () { - final model = LanguageList(total: 5, languages: []); + final model = LanguageList( + total: 5, + languages: [], + ); final map = model.toMap(); final result = LanguageList.fromMap(map); diff --git a/test/src/models/locale_code_list_test.dart b/test/src/models/locale_code_list_test.dart index 8896c83d..65b44ad1 100644 --- a/test/src/models/locale_code_list_test.dart +++ b/test/src/models/locale_code_list_test.dart @@ -4,7 +4,10 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('LocaleCodeList', () { test('model', () { - final model = LocaleCodeList(total: 5, localeCodes: []); + final model = LocaleCodeList( + total: 5, + localeCodes: [], + ); final map = model.toMap(); final result = LocaleCodeList.fromMap(map); diff --git a/test/src/models/locale_code_test.dart b/test/src/models/locale_code_test.dart index 831c4a17..88cf157b 100644 --- a/test/src/models/locale_code_test.dart +++ b/test/src/models/locale_code_test.dart @@ -4,7 +4,10 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('LocaleCode', () { test('model', () { - final model = LocaleCode(code: 'en-us', name: 'US'); + final model = LocaleCode( + code: 'en-us', + name: 'US', + ); final map = model.toMap(); final result = LocaleCode.fromMap(map); diff --git a/test/src/models/log_list_test.dart b/test/src/models/log_list_test.dart index 715cab0d..b07ca8ee 100644 --- a/test/src/models/log_list_test.dart +++ b/test/src/models/log_list_test.dart @@ -4,7 +4,10 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('LogList', () { test('model', () { - final model = LogList(total: 5, logs: []); + final model = LogList( + total: 5, + logs: [], + ); final map = model.toMap(); final result = LogList.fromMap(map); diff --git a/test/src/models/membership_list_test.dart b/test/src/models/membership_list_test.dart index 5a1f5ee8..4f30c48e 100644 --- a/test/src/models/membership_list_test.dart +++ b/test/src/models/membership_list_test.dart @@ -4,7 +4,10 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('MembershipList', () { test('model', () { - final model = MembershipList(total: 5, memberships: []); + final model = MembershipList( + total: 5, + memberships: [], + ); final map = model.toMap(); final result = MembershipList.fromMap(map); diff --git a/test/src/models/mfa_recovery_codes_test.dart b/test/src/models/mfa_recovery_codes_test.dart index 8202a631..500913c8 100644 --- a/test/src/models/mfa_recovery_codes_test.dart +++ b/test/src/models/mfa_recovery_codes_test.dart @@ -4,7 +4,9 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('MfaRecoveryCodes', () { test('model', () { - final model = MfaRecoveryCodes(recoveryCodes: []); + final model = MfaRecoveryCodes( + recoveryCodes: [], + ); final map = model.toMap(); final result = MfaRecoveryCodes.fromMap(map); diff --git a/test/src/models/mfa_type_test.dart b/test/src/models/mfa_type_test.dart index e50b7d4d..81657394 100644 --- a/test/src/models/mfa_type_test.dart +++ b/test/src/models/mfa_type_test.dart @@ -14,10 +14,8 @@ void main() { final result = MfaType.fromMap(map); expect(result.secret, '[SHARED_SECRET]'); - expect( - result.uri, - 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', - ); + expect(result.uri, + 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite'); }); }); } diff --git a/test/src/models/phone_list_test.dart b/test/src/models/phone_list_test.dart index bc3231a4..bf22a5c7 100644 --- a/test/src/models/phone_list_test.dart +++ b/test/src/models/phone_list_test.dart @@ -4,7 +4,10 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('PhoneList', () { test('model', () { - final model = PhoneList(total: 5, phones: []); + final model = PhoneList( + total: 5, + phones: [], + ); final map = model.toMap(); final result = PhoneList.fromMap(map); diff --git a/test/src/models/preferences_test.dart b/test/src/models/preferences_test.dart index 8977b11a..9db30b03 100644 --- a/test/src/models/preferences_test.dart +++ b/test/src/models/preferences_test.dart @@ -4,7 +4,9 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('Preferences', () { test('model', () { - final model = Preferences(data: {}); + final model = Preferences( + data: {}, + ); final map = model.toMap(); final result = Preferences.fromMap(map); diff --git a/test/src/models/presence_list_test.dart b/test/src/models/presence_list_test.dart index 9a5d97a3..46f69af6 100644 --- a/test/src/models/presence_list_test.dart +++ b/test/src/models/presence_list_test.dart @@ -4,7 +4,10 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('PresenceList', () { test('model', () { - final model = PresenceList(total: 5, presences: []); + final model = PresenceList( + total: 5, + presences: [], + ); final map = model.toMap(); final result = PresenceList.fromMap(map); diff --git a/test/src/models/row_list_test.dart b/test/src/models/row_list_test.dart index 7b7a9f0d..12693926 100644 --- a/test/src/models/row_list_test.dart +++ b/test/src/models/row_list_test.dart @@ -4,7 +4,10 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('RowList', () { test('model', () { - final model = RowList(total: 5, rows: []); + final model = RowList( + total: 5, + rows: [], + ); final map = model.toMap(); final result = RowList.fromMap(map); diff --git a/test/src/models/session_list_test.dart b/test/src/models/session_list_test.dart index 61f2eaeb..708e0583 100644 --- a/test/src/models/session_list_test.dart +++ b/test/src/models/session_list_test.dart @@ -4,7 +4,10 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('SessionList', () { test('model', () { - final model = SessionList(total: 5, sessions: []); + final model = SessionList( + total: 5, + sessions: [], + ); final map = model.toMap(); final result = SessionList.fromMap(map); diff --git a/test/src/models/team_list_test.dart b/test/src/models/team_list_test.dart index eb459ac2..fe2f4a85 100644 --- a/test/src/models/team_list_test.dart +++ b/test/src/models/team_list_test.dart @@ -4,7 +4,10 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('TeamList', () { test('model', () { - final model = TeamList(total: 5, teams: []); + final model = TeamList( + total: 5, + teams: [], + ); final map = model.toMap(); final result = TeamList.fromMap(map); diff --git a/test/src/models/transaction_list_test.dart b/test/src/models/transaction_list_test.dart index 35acd271..a524ef71 100644 --- a/test/src/models/transaction_list_test.dart +++ b/test/src/models/transaction_list_test.dart @@ -4,7 +4,10 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('TransactionList', () { test('model', () { - final model = TransactionList(total: 5, transactions: []); + final model = TransactionList( + total: 5, + transactions: [], + ); final map = model.toMap(); final result = TransactionList.fromMap(map); diff --git a/test/src/realtime_response_connected_test.dart b/test/src/realtime_response_connected_test.dart index 56897e43..7c43878b 100644 --- a/test/src/realtime_response_connected_test.dart +++ b/test/src/realtime_response_connected_test.dart @@ -52,7 +52,9 @@ void main() { expect( responseString, - equals('RealtimeResponseConnected(channels: $channels, user: $user)'), + equals( + 'RealtimeResponseConnected(channels: $channels, user: $user)', + ), ); }); diff --git a/test/src/realtime_response_test.dart b/test/src/realtime_response_test.dart index 029c35bf..4435280a 100644 --- a/test/src/realtime_response_test.dart +++ b/test/src/realtime_response_test.dart @@ -48,9 +48,7 @@ void main() { final responseString = response1.toString(); expect( - responseString, - equals('RealtimeResponse(type: $type, data: $data)'), - ); + responseString, equals('RealtimeResponse(type: $type, data: $data)')); }); test('equality operator should compare two instances', () { diff --git a/test/src/realtime_subscription_test.dart b/test/src/realtime_subscription_test.dart index d19e6eac..1515f1a3 100644 --- a/test/src/realtime_subscription_test.dart +++ b/test/src/realtime_subscription_test.dart @@ -8,18 +8,15 @@ void main() { final mockStream = StreamController.broadcast(); final mockCloseFunction = () async {}; final mockUnsubscribeFunction = () async {}; - Future mockUpdateFunction({ - List? channels, - List? queries, - }) async {} + Future mockUpdateFunction( + {List? channels, List? queries}) async {} final subscription = RealtimeSubscription( - controller: mockStream, - close: mockCloseFunction, - unsubscribe: mockUnsubscribeFunction, - update: mockUpdateFunction, - channels: ['documents'], - queries: const [], - ); + controller: mockStream, + close: mockCloseFunction, + unsubscribe: mockUnsubscribeFunction, + update: mockUpdateFunction, + channels: ['documents'], + queries: const []); test('should have the correct stream and close function', () { expect(subscription.controller, equals(mockStream)); diff --git a/test/src/upload_progress_test.dart b/test/src/upload_progress_test.dart index 3dce66c9..d21607ec 100644 --- a/test/src/upload_progress_test.dart +++ b/test/src/upload_progress_test.dart @@ -14,7 +14,7 @@ void main() { "progress": progress, "sizeUploaded": sizeUploaded, "chunksTotal": chunksTotal, - "chunksUploaded": chunksUploaded, + "chunksUploaded": chunksUploaded }; final uploadProgress = UploadProgress( $id: id,