diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml deleted file mode 100644 index 0e4bf293..00000000 --- a/.github/workflows/format.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Format and push - -# Github action will require permission to write to repo -on: - pull_request: - branches: - - main - workflow_dispatch: - -jobs: - format: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: true - ref: ${{ github.event.pull_request.head.ref }} - - - name: Install Flutter - uses: subosito/flutter-action@1a449444c387b1966244ae4d4f8c696479add0b2 # v2.23.0 - with: - channel: stable - - - name: Install dependencies - run: flutter pub get - - - name: Format Dart code - run: dart format . - - - name: git config - run: git config --global --add safe.directory /__w/sdk-for-flutter/sdk-for-flutter # required to fix dubious ownership - - - name: Add & Commit - uses: EndBug/add-and-commit@290ea2c423ad77ca9c62ae0f5b224379612c0321 # v10.0.0 - with: - add: '["lib", "test"]' - diff --git a/CHANGELOG.md b/CHANGELOG.md index 99ca59f2..ce971fde 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Change Log +## 26.0.0 + +* Breaking: `Execution.functionId` replaced by `resourceId` and `resourceType`, now that executions cover both functions and sites +* Added: `avatars.getPhoto` returning the user's best available profile photo +* Added: `huggingface` OAuth provider +* Added: `custom` authentication factor +* Added: `ExecutionResourceType` enum and `resourceType` attribute on the `Execution` model +* Fixed: OAuth2 failures now surface the error returned in the callback URL +* Fixed: empty JSON error responses no longer throw `FormatException` +* Updated: relaxed `device_info_plus` to `<14.0.0` and `package_info_plus` to `<11.0.0` +* Updated: minimum Dart SDK is now 3.7.0 and minimum Flutter 3.29.0 + ## 25.4.0 * Added: `Organization` service for managing app installations diff --git a/README.md b/README.md index d65b5309..74165e5c 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Add this to your package's `pubspec.yaml` file: ```yml dependencies: - appwrite: ^25.4.0 + appwrite: ^26.0.0 ``` You can install packages from the command line: diff --git a/analysis_options.yaml b/analysis_options.yaml index a3be6b82..85ac0167 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1 +1,4 @@ -include: package:flutter_lints/flutter.yaml \ No newline at end of file +include: package:flutter_lints/flutter.yaml + +formatter: + trailing_commas: preserve diff --git a/docs/examples/avatars/get-browser.md b/docs/examples/avatars/get-browser.md index 19026083..91cd7be6 100644 --- a/docs/examples/avatars/get-browser.md +++ b/docs/examples/avatars/get-browser.md @@ -1,4 +1,7 @@ ```dart +import 'dart:io'; +import 'dart:typed_data'; +import 'package:flutter/material.dart'; import 'package:appwrite/appwrite.dart'; import 'package:appwrite/enums.dart' as enums; @@ -14,23 +17,23 @@ Uint8List bytes = await avatars.getBrowser( width: 0, // optional height: 0, // optional quality: -1, // optional -) +); final file = File('path_to_file/filename.ext'); file.writeAsBytesSync(bytes); // Displaying image preview -FutureBuilder( +FutureBuilder( future: avatars.getBrowser( - code: enums.Browser.avantBrowser, - width:0 , // optional - height:0 , // optional - quality:-1 , // optional -), // Works for both public file and private file, for private files you need to be logged in + code: enums.Browser.avantBrowser, + width: 0, // optional + height: 0, // optional + quality: -1, // optional + ), // Works for both public file and private file, for private files you need to be logged in builder: (context, snapshot) { - return snapshot.hasData && snapshot.data != null - ? Image.memory(snapshot.data) - : CircularProgressIndicator(); - } + return snapshot.hasData && snapshot.data != null + ? Image.memory(snapshot.data!) + : const CircularProgressIndicator(); + }, ); ``` diff --git a/docs/examples/avatars/get-credit-card.md b/docs/examples/avatars/get-credit-card.md index 395608a4..4665fcce 100644 --- a/docs/examples/avatars/get-credit-card.md +++ b/docs/examples/avatars/get-credit-card.md @@ -1,4 +1,7 @@ ```dart +import 'dart:io'; +import 'dart:typed_data'; +import 'package:flutter/material.dart'; import 'package:appwrite/appwrite.dart'; import 'package:appwrite/enums.dart' as enums; @@ -14,23 +17,23 @@ Uint8List bytes = await avatars.getCreditCard( width: 0, // optional height: 0, // optional quality: -1, // optional -) +); final file = File('path_to_file/filename.ext'); file.writeAsBytesSync(bytes); // Displaying image preview -FutureBuilder( +FutureBuilder( future: avatars.getCreditCard( - code: enums.CreditCard.americanExpress, - width:0 , // optional - height:0 , // optional - quality:-1 , // optional -), // Works for both public file and private file, for private files you need to be logged in + code: enums.CreditCard.americanExpress, + width: 0, // optional + height: 0, // optional + quality: -1, // optional + ), // Works for both public file and private file, for private files you need to be logged in builder: (context, snapshot) { - return snapshot.hasData && snapshot.data != null - ? Image.memory(snapshot.data) - : CircularProgressIndicator(); - } + return snapshot.hasData && snapshot.data != null + ? Image.memory(snapshot.data!) + : const CircularProgressIndicator(); + }, ); ``` diff --git a/docs/examples/avatars/get-favicon.md b/docs/examples/avatars/get-favicon.md index fd1d0df7..5f523f81 100644 --- a/docs/examples/avatars/get-favicon.md +++ b/docs/examples/avatars/get-favicon.md @@ -1,4 +1,7 @@ ```dart +import 'dart:io'; +import 'dart:typed_data'; +import 'package:flutter/material.dart'; import 'package:appwrite/appwrite.dart'; Client client = Client() @@ -10,20 +13,20 @@ Avatars avatars = Avatars(client); // Downloading file Uint8List bytes = await avatars.getFavicon( url: 'https://example.com', -) +); final file = File('path_to_file/filename.ext'); file.writeAsBytesSync(bytes); // Displaying image preview -FutureBuilder( +FutureBuilder( future: avatars.getFavicon( - url:'https://example.com' , -), // Works for both public file and private file, for private files you need to be logged in + url: 'https://example.com', + ), // Works for both public file and private file, for private files you need to be logged in builder: (context, snapshot) { - return snapshot.hasData && snapshot.data != null - ? Image.memory(snapshot.data) - : CircularProgressIndicator(); - } + return snapshot.hasData && snapshot.data != null + ? Image.memory(snapshot.data!) + : const CircularProgressIndicator(); + }, ); ``` diff --git a/docs/examples/avatars/get-flag.md b/docs/examples/avatars/get-flag.md index a5753f6c..552c22cc 100644 --- a/docs/examples/avatars/get-flag.md +++ b/docs/examples/avatars/get-flag.md @@ -1,4 +1,7 @@ ```dart +import 'dart:io'; +import 'dart:typed_data'; +import 'package:flutter/material.dart'; import 'package:appwrite/appwrite.dart'; import 'package:appwrite/enums.dart' as enums; @@ -14,23 +17,23 @@ Uint8List bytes = await avatars.getFlag( width: 0, // optional height: 0, // optional quality: -1, // optional -) +); final file = File('path_to_file/filename.ext'); file.writeAsBytesSync(bytes); // Displaying image preview -FutureBuilder( +FutureBuilder( future: avatars.getFlag( - code: enums.Flag.afghanistan, - width:0 , // optional - height:0 , // optional - quality:-1 , // optional -), // Works for both public file and private file, for private files you need to be logged in + code: enums.Flag.afghanistan, + width: 0, // optional + height: 0, // optional + quality: -1, // optional + ), // Works for both public file and private file, for private files you need to be logged in builder: (context, snapshot) { - return snapshot.hasData && snapshot.data != null - ? Image.memory(snapshot.data) - : CircularProgressIndicator(); - } + return snapshot.hasData && snapshot.data != null + ? Image.memory(snapshot.data!) + : const CircularProgressIndicator(); + }, ); ``` diff --git a/docs/examples/avatars/get-image.md b/docs/examples/avatars/get-image.md index 4e75bc7e..3f74cae0 100644 --- a/docs/examples/avatars/get-image.md +++ b/docs/examples/avatars/get-image.md @@ -1,4 +1,7 @@ ```dart +import 'dart:io'; +import 'dart:typed_data'; +import 'package:flutter/material.dart'; import 'package:appwrite/appwrite.dart'; Client client = Client() @@ -12,22 +15,22 @@ Uint8List bytes = await avatars.getImage( url: 'https://example.com', width: 0, // optional height: 0, // optional -) +); final file = File('path_to_file/filename.ext'); file.writeAsBytesSync(bytes); // Displaying image preview -FutureBuilder( +FutureBuilder( future: avatars.getImage( - url:'https://example.com' , - width:0 , // optional - height:0 , // optional -), // Works for both public file and private file, for private files you need to be logged in + url: 'https://example.com', + width: 0, // optional + height: 0, // optional + ), // Works for both public file and private file, for private files you need to be logged in builder: (context, snapshot) { - return snapshot.hasData && snapshot.data != null - ? Image.memory(snapshot.data) - : CircularProgressIndicator(); - } + return snapshot.hasData && snapshot.data != null + ? Image.memory(snapshot.data!) + : const CircularProgressIndicator(); + }, ); ``` diff --git a/docs/examples/avatars/get-initials.md b/docs/examples/avatars/get-initials.md index 3b5bb68e..c832a1c8 100644 --- a/docs/examples/avatars/get-initials.md +++ b/docs/examples/avatars/get-initials.md @@ -1,4 +1,7 @@ ```dart +import 'dart:io'; +import 'dart:typed_data'; +import 'package:flutter/material.dart'; import 'package:appwrite/appwrite.dart'; Client client = Client() @@ -13,23 +16,23 @@ Uint8List bytes = await avatars.getInitials( width: 0, // optional height: 0, // optional background: '', // optional -) +); final file = File('path_to_file/filename.ext'); file.writeAsBytesSync(bytes); // Displaying image preview -FutureBuilder( +FutureBuilder( future: avatars.getInitials( - name:'' , // optional - width:0 , // optional - height:0 , // optional - background:'' , // optional -), // Works for both public file and private file, for private files you need to be logged in + name: '', // optional + width: 0, // optional + height: 0, // optional + background: '', // optional + ), // Works for both public file and private file, for private files you need to be logged in builder: (context, snapshot) { - return snapshot.hasData && snapshot.data != null - ? Image.memory(snapshot.data) - : CircularProgressIndicator(); - } + return snapshot.hasData && snapshot.data != null + ? Image.memory(snapshot.data!) + : const CircularProgressIndicator(); + }, ); ``` diff --git a/docs/examples/avatars/get-photo.md b/docs/examples/avatars/get-photo.md new file mode 100644 index 00000000..d9baf564 --- /dev/null +++ b/docs/examples/avatars/get-photo.md @@ -0,0 +1,40 @@ +```dart +import 'dart:io'; +import 'dart:typed_data'; +import 'package:flutter/material.dart'; +import 'package:appwrite/appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +Avatars avatars = Avatars(client); + +// Downloading file +Uint8List bytes = await avatars.getPhoto( + width: 0, // optional + height: 0, // optional + quality: 0, // optional + output: 'png', // optional + rating: 'g', // optional +); + +final file = File('path_to_file/filename.ext'); +file.writeAsBytesSync(bytes); + +// Displaying image preview +FutureBuilder( + future: avatars.getPhoto( + width: 0, // optional + height: 0, // optional + quality: 0, // optional + output: 'png', // optional + rating: 'g', // optional + ), // Works for both public file and private file, for private files you need to be logged in + builder: (context, snapshot) { + return snapshot.hasData && snapshot.data != null + ? Image.memory(snapshot.data!) + : const CircularProgressIndicator(); + }, +); +``` diff --git a/docs/examples/avatars/get-qr.md b/docs/examples/avatars/get-qr.md index 8a6dc770..3579f431 100644 --- a/docs/examples/avatars/get-qr.md +++ b/docs/examples/avatars/get-qr.md @@ -1,4 +1,7 @@ ```dart +import 'dart:io'; +import 'dart:typed_data'; +import 'package:flutter/material.dart'; import 'package:appwrite/appwrite.dart'; Client client = Client() @@ -13,23 +16,23 @@ Uint8List bytes = await avatars.getQR( size: 1, // optional margin: 0, // optional download: false, // optional -) +); final file = File('path_to_file/filename.ext'); file.writeAsBytesSync(bytes); // Displaying image preview -FutureBuilder( +FutureBuilder( future: avatars.getQR( - text:'' , - size:1 , // optional - margin:0 , // optional - download:false , // optional -), // Works for both public file and private file, for private files you need to be logged in + text: '', + size: 1, // optional + margin: 0, // optional + download: false, // optional + ), // Works for both public file and private file, for private files you need to be logged in builder: (context, snapshot) { - return snapshot.hasData && snapshot.data != null - ? Image.memory(snapshot.data) - : CircularProgressIndicator(); - } + return snapshot.hasData && snapshot.data != null + ? Image.memory(snapshot.data!) + : const CircularProgressIndicator(); + }, ); ``` diff --git a/docs/examples/avatars/get-screenshot.md b/docs/examples/avatars/get-screenshot.md index 7de27d7b..daa38d17 100644 --- a/docs/examples/avatars/get-screenshot.md +++ b/docs/examples/avatars/get-screenshot.md @@ -1,4 +1,7 @@ ```dart +import 'dart:io'; +import 'dart:typed_data'; +import 'package:flutter/material.dart'; import 'package:appwrite/appwrite.dart'; import 'package:appwrite/enums.dart' as enums; @@ -33,42 +36,42 @@ Uint8List bytes = await avatars.getScreenshot( height: 600, // optional quality: 85, // optional output: enums.ImageFormat.jpeg, // optional -) +); final file = File('path_to_file/filename.ext'); file.writeAsBytesSync(bytes); // Displaying image preview -FutureBuilder( +FutureBuilder( future: avatars.getScreenshot( - url:'https://example.com' , - headers:{ + url: 'https://example.com', + headers: { "Authorization": "Bearer token123", "X-Custom-Header": "value" - } , // optional - viewportWidth:1920 , // optional - viewportHeight:1080 , // optional - scale:2 , // optional - theme: enums.BrowserTheme.dark, // optional - userAgent:'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15' , // optional - fullpage:true , // optional - locale:'en-US' , // optional - timezone: enums.Timezone.africaAbidjan, // optional - latitude:37.7749 , // optional - longitude:-122.4194 , // optional - accuracy:100 , // optional - touch:true , // optional - permissions: [enums.BrowserPermission.geolocation, enums.BrowserPermission.notifications], // optional - sleep:3 , // optional - width:800 , // optional - height:600 , // optional - quality:85 , // optional - output: enums.ImageFormat.jpeg, // optional -), // Works for both public file and private file, for private files you need to be logged in + }, // optional + viewportWidth: 1920, // optional + viewportHeight: 1080, // optional + scale: 2, // optional + theme: enums.BrowserTheme.dark, // optional + userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15', // optional + fullpage: true, // optional + locale: 'en-US', // optional + timezone: enums.Timezone.africaAbidjan, // optional + latitude: 37.7749, // optional + longitude: -122.4194, // optional + accuracy: 100, // optional + touch: true, // optional + permissions: [enums.BrowserPermission.geolocation, enums.BrowserPermission.notifications], // optional + sleep: 3, // optional + width: 800, // optional + height: 600, // optional + quality: 85, // optional + output: enums.ImageFormat.jpeg, // optional + ), // Works for both public file and private file, for private files you need to be logged in builder: (context, snapshot) { - return snapshot.hasData && snapshot.data != null - ? Image.memory(snapshot.data) - : CircularProgressIndicator(); - } + return snapshot.hasData && snapshot.data != null + ? Image.memory(snapshot.data!) + : const CircularProgressIndicator(); + }, ); ``` diff --git a/docs/examples/storage/get-file-download.md b/docs/examples/storage/get-file-download.md index 8fc48d15..8e6e75ef 100644 --- a/docs/examples/storage/get-file-download.md +++ b/docs/examples/storage/get-file-download.md @@ -1,4 +1,7 @@ ```dart +import 'dart:io'; +import 'dart:typed_data'; +import 'package:flutter/material.dart'; import 'package:appwrite/appwrite.dart'; Client client = Client() @@ -12,22 +15,22 @@ Uint8List bytes = await storage.getFileDownload( bucketId: '', fileId: '', token: '', // optional -) +); final file = File('path_to_file/filename.ext'); file.writeAsBytesSync(bytes); // Displaying image preview -FutureBuilder( +FutureBuilder( future: storage.getFileDownload( - bucketId:'' , - fileId:'' , - token:'' , // optional -), // Works for both public file and private file, for private files you need to be logged in + bucketId: '', + fileId: '', + token: '', // optional + ), // Works for both public file and private file, for private files you need to be logged in builder: (context, snapshot) { - return snapshot.hasData && snapshot.data != null - ? Image.memory(snapshot.data) - : CircularProgressIndicator(); - } + return snapshot.hasData && snapshot.data != null + ? Image.memory(snapshot.data!) + : const CircularProgressIndicator(); + }, ); ``` diff --git a/docs/examples/storage/get-file-preview.md b/docs/examples/storage/get-file-preview.md index 06e583a3..bfb15b91 100644 --- a/docs/examples/storage/get-file-preview.md +++ b/docs/examples/storage/get-file-preview.md @@ -1,4 +1,7 @@ ```dart +import 'dart:io'; +import 'dart:typed_data'; +import 'package:flutter/material.dart'; import 'package:appwrite/appwrite.dart'; import 'package:appwrite/enums.dart' as enums; @@ -24,33 +27,33 @@ Uint8List bytes = await storage.getFilePreview( background: '', // optional output: enums.ImageFormat.jpg, // optional token: '', // optional -) +); final file = File('path_to_file/filename.ext'); file.writeAsBytesSync(bytes); // Displaying image preview -FutureBuilder( +FutureBuilder( future: storage.getFilePreview( - bucketId:'' , - fileId:'' , - width:0 , // optional - height:0 , // optional - gravity: enums.ImageGravity.center, // optional - quality:-1 , // optional - borderWidth:0 , // optional - borderColor:'' , // optional - borderRadius:0 , // optional - opacity:0 , // optional - rotation:-360 , // optional - background:'' , // optional - output: enums.ImageFormat.jpg, // optional - token:'' , // optional -), // Works for both public file and private file, for private files you need to be logged in + bucketId: '', + fileId: '', + width: 0, // optional + height: 0, // optional + gravity: enums.ImageGravity.center, // optional + quality: -1, // optional + borderWidth: 0, // optional + borderColor: '', // optional + borderRadius: 0, // optional + opacity: 0, // optional + rotation: -360, // optional + background: '', // optional + output: enums.ImageFormat.jpg, // optional + token: '', // optional + ), // Works for both public file and private file, for private files you need to be logged in builder: (context, snapshot) { - return snapshot.hasData && snapshot.data != null - ? Image.memory(snapshot.data) - : CircularProgressIndicator(); - } + return snapshot.hasData && snapshot.data != null + ? Image.memory(snapshot.data!) + : const CircularProgressIndicator(); + }, ); ``` diff --git a/docs/examples/storage/get-file-view.md b/docs/examples/storage/get-file-view.md index 56d2652d..6cc01b65 100644 --- a/docs/examples/storage/get-file-view.md +++ b/docs/examples/storage/get-file-view.md @@ -1,4 +1,7 @@ ```dart +import 'dart:io'; +import 'dart:typed_data'; +import 'package:flutter/material.dart'; import 'package:appwrite/appwrite.dart'; Client client = Client() @@ -12,22 +15,22 @@ Uint8List bytes = await storage.getFileView( bucketId: '', fileId: '', token: '', // optional -) +); final file = File('path_to_file/filename.ext'); file.writeAsBytesSync(bytes); // Displaying image preview -FutureBuilder( +FutureBuilder( future: storage.getFileView( - bucketId:'' , - fileId:'' , - token:'' , // optional -), // Works for both public file and private file, for private files you need to be logged in + bucketId: '', + fileId: '', + token: '', // optional + ), // Works for both public file and private file, for private files you need to be logged in builder: (context, snapshot) { - return snapshot.hasData && snapshot.data != null - ? Image.memory(snapshot.data) - : CircularProgressIndicator(); - } + return snapshot.hasData && snapshot.data != null + ? Image.memory(snapshot.data!) + : const CircularProgressIndicator(); + }, ); ``` diff --git a/lib/enums.dart b/lib/enums.dart index f9b21727..a9677f03 100644 --- a/lib/enums.dart +++ b/lib/enums.dart @@ -13,5 +13,6 @@ part 'src/enums/browser_permission.dart'; part 'src/enums/image_format.dart'; part 'src/enums/execution_method.dart'; part 'src/enums/image_gravity.dart'; +part 'src/enums/execution_resource_type.dart'; part 'src/enums/execution_trigger.dart'; part 'src/enums/execution_status.dart'; diff --git a/lib/query.dart b/lib/query.dart index 2772116a..2e809e22 100644 --- a/lib/query.dart +++ b/lib/query.dart @@ -159,13 +159,15 @@ class Query { static String updatedBetween(String start, String end) => between('\$updatedAt', start, end); - static String or(List queries) => Query._( + static String or(List queries) => + Query._( 'or', null, queries.map((query) => jsonDecode(query)).toList(), ).toString(); - static String and(List queries) => Query._( + static String and(List queries) => + Query._( 'and', null, queries.map((query) => jsonDecode(query)).toList(), @@ -175,7 +177,8 @@ class Query { /// /// [attribute] The attribute containing the array to filter on. /// [queries] The list of query strings to match against array elements. - static String elemMatch(String attribute, List queries) => Query._( + static String elemMatch(String attribute, List queries) => + Query._( 'elemMatch', attribute, queries.map((query) => jsonDecode(query)).toList(), @@ -222,34 +225,46 @@ 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 using vector dot product similarity. diff --git a/lib/services/account.dart b/lib/services/account.dart index 3b8fbded..41a32f4a 100644 --- a/lib/services/account.dart +++ b/lib/services/account.dart @@ -16,8 +16,12 @@ 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); } @@ -29,11 +33,12 @@ 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 = { @@ -49,16 +54,22 @@ 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); } /// Get a list of the OAuth2 consents the current user has given to third-party /// apps. - Future listConsents( - {List? queries, bool? total}) async { + Future listConsents({ + List? queries, + bool? total, + }) async { final String apiPath = '/account/consents'; final Map apiParams = { @@ -71,17 +82,25 @@ 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.Oauth2ConsentList.fromMap(res.data); } /// Get an OAuth2 consent the current user has given to a third-party app by /// its unique ID. - Future getConsent({required String consentId}) async { - final String apiPath = - '/account/consents/{consentId}'.replaceAll('{consentId}', consentId); + Future getConsent({ + required String consentId, + }) async { + final String apiPath = '/account/consents/{consentId}'.replaceAll( + '{consentId}', + consentId, + ); final Map apiParams = {}; @@ -90,8 +109,12 @@ 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.Oauth2Consent.fromMap(res.data); } @@ -99,9 +122,13 @@ class Account extends Service { /// Delete an OAuth2 consent by its unique ID. All token families issued under /// the consent are revoked, and the app must ask for consent again to regain /// access. - Future deleteConsent({required String consentId}) async { - final String apiPath = - '/account/consents/{consentId}'.replaceAll('{consentId}', consentId); + Future deleteConsent({ + required String consentId, + }) async { + final String apiPath = '/account/consents/{consentId}'.replaceAll( + '{consentId}', + consentId, + ); final Map apiParams = {}; @@ -111,8 +138,12 @@ class Account extends Service { 'accept': '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; } @@ -120,10 +151,15 @@ class Account extends Service { /// Get a list of the token families issued under an OAuth2 consent. Each entry /// represents one authorized device or session; the token secrets themselves /// are never returned. - Future listConsentTokens( - {required String consentId, List? queries, bool? total}) async { - final String apiPath = '/account/consents/{consentId}/tokens' - .replaceAll('{consentId}', consentId); + Future listConsentTokens({ + required String consentId, + List? queries, + bool? total, + }) async { + final String apiPath = '/account/consents/{consentId}/tokens'.replaceAll( + '{consentId}', + consentId, + ); final Map apiParams = { if (queries != null) 'queries': queries, @@ -135,19 +171,31 @@ 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.Oauth2ConsentTokenList.fromMap(res.data); } /// Get a token family issued under an OAuth2 consent by its unique ID. The /// token secrets themselves are never returned. - Future getConsentToken( - {required String consentId, required String tokenId}) async { + Future getConsentToken({ + required String consentId, + required String tokenId, + }) async { final String apiPath = '/account/consents/{consentId}/tokens/{tokenId}' - .replaceAll('{consentId}', consentId) - .replaceAll('{tokenId}', tokenId); + .replaceAll( + '{consentId}', + consentId, + ) + .replaceAll( + '{tokenId}', + tokenId, + ); final Map apiParams = {}; @@ -156,8 +204,12 @@ 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.Oauth2ConsentToken.fromMap(res.data); } @@ -165,11 +217,19 @@ class Account extends Service { /// Delete a token family issued under an OAuth2 consent by its unique ID. The /// access and refresh tokens of the family stop working immediately; other /// token families and the consent itself are unaffected. - Future deleteConsentToken( - {required String consentId, required String tokenId}) async { + Future deleteConsentToken({ + required String consentId, + required String tokenId, + }) async { final String apiPath = '/account/consents/{consentId}/tokens/{tokenId}' - .replaceAll('{consentId}', consentId) - .replaceAll('{tokenId}', tokenId); + .replaceAll( + '{consentId}', + consentId, + ) + .replaceAll( + '{tokenId}', + tokenId, + ); final Map apiParams = {}; @@ -179,8 +239,12 @@ class Account extends Service { 'accept': '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; } @@ -192,9 +256,10 @@ class Account extends Service { /// user password is required to complete this request. /// This endpoint can also be used to convert an anonymous account to a normal /// one, by passing an email address and a new password. - /// - Future updateEmail( - {required String email, required String password}) async { + Future updateEmail({ + required String email, + required String password, + }) async { final String apiPath = '/account/email'; final Map apiParams = { @@ -208,15 +273,21 @@ 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 = { @@ -229,16 +300,24 @@ 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); + Future deleteIdentity({ + required String identityId, + }) async { + final String apiPath = '/account/identities/{identityId}'.replaceAll( + '{identityId}', + identityId, + ); final Map apiParams = {}; @@ -247,8 +326,12 @@ 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; } @@ -258,7 +341,9 @@ class Account extends Service { /// Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes /// from its creation and will be invalid if the user will logout in that time /// frame. - Future createJWT({int? duration}) async { + Future createJWT({ + int? duration, + }) async { final String apiPath = '/account/jwts'; final Map apiParams = { @@ -271,15 +356,22 @@ 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); } /// Get the list of latest security activity logs for the currently logged in /// user. Each log returns user IP address, location and date and time of log. - Future listLogs({List? queries, bool? total}) async { + Future listLogs({ + List? queries, + bool? total, + }) async { final String apiPath = '/account/logs'; final Map apiParams = { @@ -292,14 +384,20 @@ 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); } /// Enable or disable MFA on an account. - Future updateMFA({required bool mfa}) async { + Future updateMFA({ + required bool mfa, + }) async { final String apiPath = '/account/mfa'; final Map apiParams = { @@ -312,8 +410,12 @@ 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); } @@ -323,11 +425,15 @@ 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 = {}; @@ -337,8 +443,12 @@ 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); } @@ -347,10 +457,13 @@ 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 = {}; @@ -360,8 +473,12 @@ 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); } @@ -370,11 +487,16 @@ 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); + '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, @@ -386,8 +508,12 @@ 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); } @@ -395,10 +521,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, @@ -410,18 +540,27 @@ 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.') - Future deleteMfaAuthenticator({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.deleteMFAAuthenticator` instead.', + ) + Future deleteMfaAuthenticator({ + required enums.AuthenticatorType type, + }) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( + '{type}', + type.value, + ); final Map apiParams = {}; @@ -430,16 +569,24 @@ 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); + Future deleteMFAAuthenticator({ + required enums.AuthenticatorType type, + }) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll( + '{type}', + type.value, + ); final Map apiParams = {}; @@ -448,8 +595,12 @@ 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; } @@ -458,9 +609,11 @@ 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 = { @@ -473,8 +626,12 @@ 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); } @@ -482,8 +639,9 @@ 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 = { @@ -496,8 +654,12 @@ 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); } @@ -508,9 +670,12 @@ 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 = { @@ -524,8 +689,12 @@ 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); } @@ -535,8 +704,10 @@ 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 = { @@ -550,15 +721,20 @@ 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'; @@ -569,8 +745,12 @@ 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); } @@ -586,8 +766,12 @@ 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); } @@ -597,7 +781,8 @@ 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'; @@ -608,8 +793,12 @@ 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); } @@ -628,8 +817,12 @@ 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); } @@ -640,7 +833,8 @@ 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'; @@ -652,8 +846,12 @@ 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); } @@ -674,8 +872,12 @@ 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); } @@ -685,7 +887,8 @@ 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'; @@ -697,8 +900,12 @@ 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,14 +925,20 @@ 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); } /// Update currently logged in user account name. - Future updateName({required String name}) async { + Future updateName({ + required String name, + }) async { final String apiPath = '/account/name'; final Map apiParams = { @@ -738,8 +951,12 @@ 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); } @@ -747,8 +964,10 @@ 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 = { @@ -762,8 +981,12 @@ 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); } @@ -773,8 +996,10 @@ 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 = { @@ -788,8 +1013,12 @@ 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); } @@ -805,8 +1034,12 @@ 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); } @@ -814,7 +1047,9 @@ class Account extends Service { /// Update currently logged in user account preferences. The object you pass is /// stored as is, and replaces any previous value. The maximum allowed prefs /// size is 64kB and throws error if exceeded. - Future updatePrefs({required Map prefs}) async { + Future updatePrefs({ + required Map prefs, + }) async { final String apiPath = '/account/prefs'; final Map apiParams = { @@ -827,8 +1062,12 @@ 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); } @@ -841,8 +1080,10 @@ 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 = { @@ -856,8 +1097,12 @@ 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); } @@ -872,10 +1117,11 @@ 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 = { @@ -890,8 +1136,12 @@ 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); } @@ -908,8 +1158,12 @@ 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); } @@ -926,8 +1180,12 @@ 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; } @@ -950,8 +1208,12 @@ 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); } @@ -962,8 +1224,10 @@ 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 = { @@ -977,8 +1241,12 @@ 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); } @@ -987,9 +1255,12 @@ 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 = { @@ -1003,8 +1274,12 @@ 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); } @@ -1024,14 +1299,16 @@ 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 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, @@ -1046,20 +1323,22 @@ 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)}'); } }); - 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('&')); + final Uri endpoint = Uri.parse(client.endPoint); + final Uri url = Uri( + scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + apiPath, + query: query.join('&'), + ); return client.webAuth(url, callbackUrlScheme: success); } @@ -1068,9 +1347,12 @@ 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 = { @@ -1084,8 +1366,12 @@ 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); } @@ -1093,8 +1379,10 @@ 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 = { @@ -1108,17 +1396,25 @@ 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); } /// 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); + Future getSession({ + required String sessionId, + }) async { + final String apiPath = '/account/sessions/{sessionId}'.replaceAll( + '{sessionId}', + sessionId, + ); final Map apiParams = {}; @@ -1127,8 +1423,12 @@ 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); } @@ -1136,9 +1436,13 @@ class Account extends Service { /// Use this endpoint to extend a session's length. Extending a session is /// useful when session expiry is short. If the session was created using an /// OAuth provider, this endpoint refreshes the access token from the provider. - Future updateSession({required String sessionId}) async { - final String apiPath = - '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); + Future updateSession({ + required String sessionId, + }) async { + final String apiPath = '/account/sessions/{sessionId}'.replaceAll( + '{sessionId}', + sessionId, + ); final Map apiParams = {}; @@ -1148,8 +1452,12 @@ 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); } @@ -1159,9 +1467,13 @@ class Account extends Service { /// the user on all devices, use [Delete /// 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); + Future deleteSession({ + required String sessionId, + }) async { + final String apiPath = '/account/sessions/{sessionId}'.replaceAll( + '{sessionId}', + sessionId, + ); final Map apiParams = {}; @@ -1170,8 +1482,12 @@ 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; } @@ -1190,8 +1506,12 @@ 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); } @@ -1201,10 +1521,11 @@ 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 = { @@ -1219,8 +1540,12 @@ 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); } @@ -1230,10 +1555,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, @@ -1245,8 +1574,12 @@ 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); } @@ -1254,9 +1587,13 @@ class Account extends Service { /// Delete a push notification target for the currently logged in user. After /// deletion, the device will no longer receive push notifications. The target /// must exist and belong to the current user. - Future deletePushTarget({required String targetId}) async { - final String apiPath = - '/account/targets/{targetId}/push'.replaceAll('{targetId}', targetId); + Future deletePushTarget({ + required String targetId, + }) async { + final String apiPath = '/account/targets/{targetId}/push'.replaceAll( + '{targetId}', + targetId, + ); final Map apiParams = {}; @@ -1265,8 +1602,12 @@ 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; } @@ -1284,9 +1625,11 @@ 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 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 = { @@ -1301,8 +1644,12 @@ 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); } @@ -1320,12 +1667,12 @@ 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 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 = { @@ -1341,8 +1688,12 @@ 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); } @@ -1361,13 +1712,16 @@ 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, @@ -1382,20 +1736,22 @@ 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)}'); } }); - 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('&')); + final Uri endpoint = Uri.parse(client.endPoint); + final Uri url = Uri( + scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + apiPath, + query: query.join('&'), + ); return client.webAuth(url, callbackUrlScheme: success); } @@ -1410,8 +1766,10 @@ 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 = { @@ -1425,8 +1783,12 @@ 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); } @@ -1445,8 +1807,9 @@ 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 createEmailVerification({required String url}) async { + Future createEmailVerification({ + required String url, + }) async { final String apiPath = '/account/verifications/email'; final Map apiParams = { @@ -1459,8 +1822,12 @@ 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); } @@ -1479,10 +1846,12 @@ 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. - /// @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `Account.createEmailVerification` instead.') - Future createVerification({required String url}) async { + '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 = { @@ -1495,8 +1864,12 @@ 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); } @@ -1505,8 +1878,10 @@ 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 = { @@ -1520,8 +1895,12 @@ 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); } @@ -1531,9 +1910,12 @@ 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 = { @@ -1547,8 +1929,12 @@ 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); } @@ -1572,8 +1958,12 @@ 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); } @@ -1582,8 +1972,10 @@ 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 = { @@ -1597,8 +1989,12 @@ 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 2fe54e87..ba09d21e 100644 --- a/lib/services/avatars.dart +++ b/lib/services/avatars.dart @@ -16,13 +16,16 @@ 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 apiParams = { if (width != null) 'width': width, @@ -35,11 +38,13 @@ class Avatars extends Service { 'accept': 'image/png', }; - final res = await client.call(HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - responseType: ResponseType.bytes); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + responseType: ResponseType.bytes, + ); return res.data; } @@ -51,14 +56,16 @@ 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 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 apiParams = { if (width != null) 'width': width, @@ -71,11 +78,13 @@ class Avatars extends Service { 'accept': 'image/png', }; - final res = await client.call(HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - responseType: ResponseType.bytes); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + responseType: ResponseType.bytes, + ); return res.data; } @@ -83,7 +92,9 @@ class Avatars extends Service { /// website URL. /// /// This endpoint does not follow HTTP redirects. - Future getFavicon({required String url}) async { + Future getFavicon({ + required String url, + }) async { final String apiPath = '/avatars/favicon'; final Map apiParams = { @@ -95,11 +106,13 @@ class Avatars extends Service { 'accept': 'image/*', }; - final res = await client.call(HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - responseType: ResponseType.bytes); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + responseType: ResponseType.bytes, + ); return res.data; } @@ -112,11 +125,16 @@ 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 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 apiParams = { if (width != null) 'width': width, @@ -129,11 +147,13 @@ class Avatars extends Service { 'accept': 'image/png', }; - final res = await client.call(HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - responseType: ResponseType.bytes); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + responseType: ResponseType.bytes, + ); return res.data; } @@ -148,8 +168,11 @@ 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 apiParams = { @@ -163,11 +186,13 @@ class Avatars extends Service { 'accept': 'image/*', }; - final res = await client.call(HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - responseType: ResponseType.bytes); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + responseType: ResponseType.bytes, + ); return res.data; } @@ -186,9 +211,12 @@ 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 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 apiParams = { @@ -203,19 +231,60 @@ class Avatars extends Service { 'accept': 'image/png', }; - final res = await client.call(HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - responseType: ResponseType.bytes); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + responseType: ResponseType.bytes, + ); + return res.data; + } + + /// Returns the best available profile photo for the currently authenticated + /// user. The endpoint tries each source in priority order and returns the + /// first successful result: Gravatar, Libavatar, Appwrite Initials, built-in + /// static fallback file. + Future getPhoto({ + int? width, + int? height, + int? quality, + String? output, + String? rating, + }) async { + final String apiPath = '/avatars/photo'; + + final Map apiParams = { + if (width != null) 'width': width, + if (height != null) 'height': height, + if (quality != null) 'quality': quality, + if (output != null) 'output': output, + if (rating != null) 'rating': rating, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'image/*', + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + 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 apiParams = { @@ -230,11 +299,13 @@ class Avatars extends Service { 'accept': 'image/png', }; - final res = await client.call(HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - responseType: ResponseType.bytes); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + responseType: ResponseType.bytes, + ); return res.data; } @@ -248,27 +319,28 @@ 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 apiParams = { @@ -277,22 +349,22 @@ class Avatars extends Service { if (viewportWidth != null) 'viewportWidth': viewportWidth, if (viewportHeight != null) 'viewportHeight': viewportHeight, if (scale != null) 'scale': scale, - if (theme != null) 'theme': theme.value, + if (theme != null) 'theme': theme?.value, if (userAgent != null) 'userAgent': userAgent, if (fullpage != null) 'fullpage': fullpage, if (locale != null) 'locale': locale, - if (timezone != null) 'timezone': timezone.value, + if (timezone != null) 'timezone': timezone?.value, if (latitude != null) 'latitude': latitude, if (longitude != null) 'longitude': longitude, if (accuracy != null) 'accuracy': accuracy, if (touch != null) 'touch': touch, if (permissions != null) - 'permissions': permissions.map((e) => e.value).toList(), + 'permissions': permissions?.map((e) => e.value).toList(), if (sleep != null) 'sleep': sleep, if (width != null) 'width': width, if (height != null) 'height': height, if (quality != null) 'quality': quality, - if (output != null) 'output': output.value, + if (output != null) 'output': output?.value, }; final Map apiHeaders = { @@ -300,11 +372,13 @@ class Avatars extends Service { 'accept': 'image/png', }; - final res = await client.call(HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - responseType: ResponseType.bytes); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + responseType: ResponseType.bytes, + ); return res.data; } } diff --git a/lib/services/databases.dart b/lib/services/databases.dart index d298cec0..adbd28cc 100644 --- a/lib/services/databases.dart +++ b/lib/services/databases.dart @@ -8,9 +8,11 @@ class Databases extends Service { /// List transactions across all databases. @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.listTransactions` instead.') - Future listTransactions( - {List? queries}) async { + '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 = { @@ -22,16 +24,23 @@ 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 { + '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 = { @@ -44,19 +53,27 @@ 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. @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); + '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 = {}; @@ -65,19 +82,29 @@ 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. @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); + '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, @@ -90,18 +117,27 @@ 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); + 'This API has been deprecated since 1.8.0. Please use `TablesDB.deleteTransaction` instead.', + ) + Future deleteTransaction({ + required String transactionId, + }) async { + final String apiPath = '/databases/transactions/{transactionId}'.replaceAll( + '{transactionId}', + transactionId, + ); final Map apiParams = {}; @@ -110,19 +146,29 @@ 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. @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.createOperations` instead.') - Future createOperations( - {required String transactionId, List? operations}) async { + '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); + .replaceAll( + '{transactionId}', + transactionId, + ); final Map apiParams = { if (operations != null) 'operations': operations, @@ -134,8 +180,12 @@ 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); } @@ -143,18 +193,26 @@ 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) - .replaceAll('{collectionId}', collectionId); + .replaceAll( + '{databaseId}', + databaseId, + ) + .replaceAll( + '{collectionId}', + collectionId, + ); final Map apiParams = { if (queries != null) 'queries': queries, @@ -168,8 +226,12 @@ 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); } @@ -179,18 +241,26 @@ 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) - .replaceAll('{collectionId}', collectionId); + .replaceAll( + '{databaseId}', + databaseId, + ) + .replaceAll( + '{collectionId}', + collectionId, + ); final Map apiParams = { 'documentId': documentId, @@ -205,8 +275,12 @@ 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); } @@ -214,18 +288,29 @@ 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) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); + .replaceAll( + '{databaseId}', + databaseId, + ) + .replaceAll( + '{collectionId}', + collectionId, + ) + .replaceAll( + '{documentId}', + documentId, + ); final Map apiParams = { if (queries != null) 'queries': queries, @@ -237,8 +322,12 @@ 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); } @@ -248,19 +337,30 @@ 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) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); + .replaceAll( + '{databaseId}', + databaseId, + ) + .replaceAll( + '{collectionId}', + collectionId, + ) + .replaceAll( + '{documentId}', + documentId, + ); final Map apiParams = { if (data != null) 'data': data, @@ -274,8 +374,12 @@ 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); } @@ -283,19 +387,30 @@ 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) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId); + .replaceAll( + '{databaseId}', + databaseId, + ) + .replaceAll( + '{collectionId}', + collectionId, + ) + .replaceAll( + '{documentId}', + documentId, + ); final Map apiParams = { if (data != null) 'data': data, @@ -309,25 +424,40 @@ 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); + .replaceAll( + '{databaseId}', + databaseId, + ) + .replaceAll( + '{collectionId}', + collectionId, + ) + .replaceAll( + '{documentId}', + documentId, + ); final Map apiParams = { if (transactionId != null) 'transactionId': transactionId, @@ -338,29 +468,47 @@ 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; } /// 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) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId) - .replaceAll('{attribute}', attribute); + .replaceAll( + '{databaseId}', + databaseId, + ) + .replaceAll( + '{collectionId}', + collectionId, + ) + .replaceAll( + '{documentId}', + documentId, + ) + .replaceAll( + '{attribute}', + attribute, + ); final Map apiParams = { if (value != null) 'value': value, @@ -374,29 +522,47 @@ 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) - .replaceAll('{collectionId}', collectionId) - .replaceAll('{documentId}', documentId) - .replaceAll('{attribute}', attribute); + .replaceAll( + '{databaseId}', + databaseId, + ) + .replaceAll( + '{collectionId}', + collectionId, + ) + .replaceAll( + '{documentId}', + documentId, + ) + .replaceAll( + '{attribute}', + attribute, + ); final Map apiParams = { if (value != null) 'value': value, @@ -410,8 +576,12 @@ 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 6cde02ed..fc5f460e 100644 --- a/lib/services/functions.dart +++ b/lib/services/functions.dart @@ -8,10 +8,15 @@ 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, @@ -23,8 +28,12 @@ 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); } @@ -33,22 +42,25 @@ 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, if (xasync != null) 'async': xasync, if (path != null) 'path': path, - if (method != null) 'method': method.value, + if (method != null) 'method': method?.value, if (headers != null) 'headers': headers, if (scheduledAt != null) 'scheduledAt': scheduledAt, }; @@ -59,18 +71,30 @@ 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); + .replaceAll( + '{functionId}', + functionId, + ) + .replaceAll( + '{executionId}', + executionId, + ); final Map apiParams = {}; @@ -79,8 +103,12 @@ 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 c86f3719..c4a643db 100644 --- a/lib/services/graphql.dart +++ b/lib/services/graphql.dart @@ -7,7 +7,9 @@ class Graphql extends Service { Graphql(super.client); /// Execute a GraphQL mutation. - Future query({required Map query}) async { + Future query({ + required Map query, + }) async { final String apiPath = '/graphql'; final Map apiParams = { @@ -21,14 +23,20 @@ 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; } /// Execute a GraphQL mutation. - Future mutation({required Map query}) async { + Future mutation({ + required Map query, + }) async { final String apiPath = '/graphql/mutation'; final Map apiParams = { @@ -42,8 +50,12 @@ 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 87ea162e..d4831b74 100644 --- a/lib/services/locale.dart +++ b/lib/services/locale.dart @@ -22,8 +22,12 @@ 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); } @@ -40,8 +44,12 @@ 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); } @@ -58,8 +66,12 @@ 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); } @@ -76,8 +88,12 @@ 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); } @@ -94,8 +110,12 @@ 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); } @@ -112,8 +132,12 @@ 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); } @@ -131,8 +155,12 @@ 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); } @@ -149,8 +177,12 @@ 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 61ecefee..d213b55f 100644 --- a/lib/services/messaging.dart +++ b/lib/services/messaging.dart @@ -7,12 +7,15 @@ 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, @@ -25,19 +28,31 @@ 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) - .replaceAll('{subscriberId}', subscriberId); + .replaceAll( + '{topicId}', + topicId, + ) + .replaceAll( + '{subscriberId}', + subscriberId, + ); final Map apiParams = {}; @@ -46,8 +61,12 @@ 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/organization.dart b/lib/services/organization.dart index 68275296..70e4576a 100644 --- a/lib/services/organization.dart +++ b/lib/services/organization.dart @@ -7,8 +7,10 @@ class Organization extends Service { /// List app installations on the organization. Any organization member can /// read installations. - Future listInstallations( - {List? queries, bool? total}) async { + Future listInstallations({ + List? queries, + bool? total, + }) async { final String apiPath = '/organization/installations'; final Map apiParams = { @@ -21,8 +23,12 @@ class Organization 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.AppInstallationList.fromMap(res.data); } @@ -30,8 +36,10 @@ class Organization extends Service { /// Install an app on the organization. Only organization members with the /// owner role can install apps. The installation is granted the scopes the app /// currently requests. - Future createInstallation( - {required String appId, String? authorizationDetails}) async { + Future createInstallation({ + required String appId, + String? authorizationDetails, + }) async { final String apiPath = '/organization/installations'; final Map apiParams = { @@ -46,18 +54,26 @@ class Organization 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.AppInstallation.fromMap(res.data); } /// Get an app installation on the organization by its unique ID. Any /// organization member can read installations. - Future getInstallation( - {required String installationId}) async { + Future getInstallation({ + required String installationId, + }) async { final String apiPath = '/organization/installations/{installationId}' - .replaceAll('{installationId}', installationId); + .replaceAll( + '{installationId}', + installationId, + ); final Map apiParams = {}; @@ -66,8 +82,12 @@ class Organization 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.AppInstallation.fromMap(res.data); } @@ -76,10 +96,15 @@ class Organization extends Service { /// with the owner role can update installations. The installation's granted /// scopes are refreshed to the scopes the app currently requests; previously /// issued installation access tokens are revoked. - Future updateInstallation( - {required String installationId, String? authorizationDetails}) async { + Future updateInstallation({ + required String installationId, + String? authorizationDetails, + }) async { final String apiPath = '/organization/installations/{installationId}' - .replaceAll('{installationId}', installationId); + .replaceAll( + '{installationId}', + installationId, + ); final Map apiParams = { if (authorizationDetails != null) @@ -92,8 +117,12 @@ class Organization 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.AppInstallation.fromMap(res.data); } @@ -101,9 +130,14 @@ class Organization extends Service { /// Uninstall an app from the organization by its installation ID. Only /// organization members with the owner role can remove installations. /// Previously issued installation access tokens are revoked. - Future deleteInstallation({required String installationId}) async { + Future deleteInstallation({ + required String installationId, + }) async { final String apiPath = '/organization/installations/{installationId}' - .replaceAll('{installationId}', installationId); + .replaceAll( + '{installationId}', + installationId, + ); final Map apiParams = {}; @@ -113,8 +147,12 @@ class Organization extends Service { 'accept': '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 fd5d6be2..f40c07e3 100644 --- a/lib/services/presences.dart +++ b/lib/services/presences.dart @@ -7,9 +7,11 @@ class Presences extends Service { Presences(super.client); /// List presence logs. Expired entries are filtered out automatically. - /// - Future list( - {List? queries, bool? total, int? ttl}) async { + Future list({ + List? queries, + bool? total, + int? ttl, + }) async { final String apiPath = '/presences'; final Map apiParams = { @@ -23,18 +25,25 @@ 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); } /// Get a presence log by its unique ID. Entries whose `expiresAt` is in the /// past are treated as not found. - /// - Future get({required String presenceId}) async { - final String apiPath = - '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); + Future get({ + required String presenceId, + }) async { + final String apiPath = '/presences/{presenceId}'.replaceAll( + '{presenceId}', + presenceId, + ); final Map apiParams = {}; @@ -43,22 +52,28 @@ 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, @@ -73,24 +88,30 @@ 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); } /// 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, @@ -106,17 +127,24 @@ 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); } /// Delete a presence log by its unique ID. - /// - Future delete({required String presenceId}) async { - final String apiPath = - '/presences/{presenceId}'.replaceAll('{presenceId}', presenceId); + Future delete({ + required String presenceId, + }) async { + final String apiPath = '/presences/{presenceId}'.replaceAll( + '{presenceId}', + presenceId, + ); final Map apiParams = {}; @@ -125,8 +153,12 @@ 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 d261ef17..77f156dd 100644 --- a/lib/services/storage.dart +++ b/lib/services/storage.dart @@ -7,13 +7,16 @@ 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, @@ -26,8 +29,12 @@ 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); } @@ -49,16 +56,18 @@ 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, - String? folder, - 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, + String? folder, + Function(UploadProgress)? onProgress, + }) async { + final String apiPath = '/storage/buckets/{bucketId}/files'.replaceAll( + '{bucketId}', + bucketId, + ); final Map apiParams = { 'fileId': fileId, @@ -74,8 +83,8 @@ class Storage extends Service { }; String idParamName = ''; - idParamName = 'fileId'; final paramName = 'file'; + idParamName = 'fileId'; final res = await client.chunkedUpload( path: apiPath, params: apiParams, @@ -90,11 +99,19 @@ 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); + .replaceAll( + '{bucketId}', + bucketId, + ) + .replaceAll( + '{fileId}', + fileId, + ); final Map apiParams = {}; @@ -103,22 +120,33 @@ 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); + .replaceAll( + '{bucketId}', + bucketId, + ) + .replaceAll( + '{fileId}', + fileId, + ); final Map apiParams = { if (name != null) 'name': name, @@ -131,18 +159,31 @@ 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); } /// Delete a file by its unique ID. Only users with write permissions have /// access to delete this resource. - Future deleteFile({required String bucketId, required String fileId}) async { + Future deleteFile({ + required String bucketId, + required String fileId, + }) async { final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}' - .replaceAll('{bucketId}', bucketId) - .replaceAll('{fileId}', fileId); + .replaceAll( + '{bucketId}', + bucketId, + ) + .replaceAll( + '{fileId}', + fileId, + ); final Map apiParams = {}; @@ -151,8 +192,12 @@ 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; } @@ -160,11 +205,20 @@ 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); + .replaceAll( + '{bucketId}', + bucketId, + ) + .replaceAll( + '{fileId}', + fileId, + ); final Map apiParams = { if (token != null) 'token': token, @@ -175,11 +229,13 @@ class Storage extends Service { 'accept': '*/*', }; - final res = await client.call(HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - responseType: ResponseType.bytes); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + responseType: ResponseType.bytes, + ); return res.data; } @@ -188,29 +244,36 @@ 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); + .replaceAll( + '{bucketId}', + bucketId, + ) + .replaceAll( + '{fileId}', + fileId, + ); final Map apiParams = { if (width != null) 'width': width, if (height != null) 'height': height, - if (gravity != null) 'gravity': gravity.value, + if (gravity != null) 'gravity': gravity?.value, if (quality != null) 'quality': quality, if (borderWidth != null) 'borderWidth': borderWidth, if (borderColor != null) 'borderColor': borderColor, @@ -218,7 +281,7 @@ class Storage extends Service { if (opacity != null) 'opacity': opacity, if (rotation != null) 'rotation': rotation, if (background != null) 'background': background, - if (output != null) 'output': output.value, + if (output != null) 'output': output?.value, if (token != null) 'token': token, }; @@ -227,22 +290,33 @@ class Storage extends Service { 'accept': 'image/*', }; - final res = await client.call(HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - responseType: ResponseType.bytes); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + 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); + .replaceAll( + '{bucketId}', + bucketId, + ) + .replaceAll( + '{fileId}', + fileId, + ); final Map apiParams = { if (token != null) 'token': token, @@ -253,11 +327,13 @@ class Storage extends Service { 'accept': '*/*', }; - final res = await client.call(HttpMethod.get, - path: apiPath, - params: apiParams, - headers: apiHeaders, - responseType: ResponseType.bytes); + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + responseType: ResponseType.bytes, + ); return res.data; } } diff --git a/lib/services/tables_db.dart b/lib/services/tables_db.dart index 45c239e6..246ab939 100644 --- a/lib/services/tables_db.dart +++ b/lib/services/tables_db.dart @@ -7,8 +7,9 @@ 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 = { @@ -20,14 +21,20 @@ 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); } /// Create a new transaction. - Future createTransaction({int? ttl}) async { + Future createTransaction({ + int? ttl, + }) async { final String apiPath = '/tablesdb/transactions'; final Map apiParams = { @@ -40,17 +47,24 @@ 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 = {}; @@ -59,17 +73,26 @@ 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, @@ -82,16 +105,24 @@ 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); + Future deleteTransaction({ + required String transactionId, + }) async { + final String apiPath = '/tablesdb/transactions/{transactionId}'.replaceAll( + '{transactionId}', + transactionId, + ); final Map apiParams = {}; @@ -100,17 +131,26 @@ 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); + .replaceAll( + '{transactionId}', + transactionId, + ); final Map apiParams = { if (operations != null) 'operations': operations, @@ -122,24 +162,35 @@ 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); + .replaceAll( + '{databaseId}', + databaseId, + ) + .replaceAll( + '{tableId}', + tableId, + ); final Map apiParams = { if (queries != null) 'queries': queries, @@ -153,8 +204,12 @@ 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); } @@ -163,16 +218,23 @@ 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); + .replaceAll( + '{databaseId}', + databaseId, + ) + .replaceAll( + '{tableId}', + tableId, + ); final Map apiParams = { 'rowId': rowId, @@ -187,25 +249,39 @@ 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) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); + .replaceAll( + '{databaseId}', + databaseId, + ) + .replaceAll( + '{tableId}', + tableId, + ) + .replaceAll( + '{rowId}', + rowId, + ); final Map apiParams = { if (queries != null) 'queries': queries, @@ -217,8 +293,12 @@ 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); } @@ -227,18 +307,28 @@ 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) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); + .replaceAll( + '{databaseId}', + databaseId, + ) + .replaceAll( + '{tableId}', + tableId, + ) + .replaceAll( + '{rowId}', + rowId, + ); final Map apiParams = { if (data != null) 'data': data, @@ -252,26 +342,40 @@ 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) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId); + .replaceAll( + '{databaseId}', + databaseId, + ) + .replaceAll( + '{tableId}', + tableId, + ) + .replaceAll( + '{rowId}', + rowId, + ); final Map apiParams = { if (data != null) 'data': data, @@ -285,23 +389,37 @@ 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); + .replaceAll( + '{databaseId}', + databaseId, + ) + .replaceAll( + '{tableId}', + tableId, + ) + .replaceAll( + '{rowId}', + rowId, + ); final Map apiParams = { if (transactionId != null) 'transactionId': transactionId, @@ -312,27 +430,44 @@ 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; } /// 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) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId) - .replaceAll('{column}', column); + .replaceAll( + '{databaseId}', + databaseId, + ) + .replaceAll( + '{tableId}', + tableId, + ) + .replaceAll( + '{rowId}', + rowId, + ) + .replaceAll( + '{column}', + column, + ); final Map apiParams = { if (value != null) 'value': value, @@ -346,27 +481,44 @@ 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) - .replaceAll('{tableId}', tableId) - .replaceAll('{rowId}', rowId) - .replaceAll('{column}', column); + .replaceAll( + '{databaseId}', + databaseId, + ) + .replaceAll( + '{tableId}', + tableId, + ) + .replaceAll( + '{rowId}', + rowId, + ) + .replaceAll( + '{column}', + column, + ); final Map apiParams = { if (value != null) 'value': value, @@ -380,8 +532,12 @@ 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 c9b7b646..99190fc1 100644 --- a/lib/services/teams.dart +++ b/lib/services/teams.dart @@ -8,8 +8,11 @@ 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 = { @@ -23,8 +26,12 @@ 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); } @@ -32,10 +39,11 @@ 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 = { @@ -50,15 +58,24 @@ 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); } /// Get a team by its ID. All team members have read access for this resource. - Future get({required String teamId}) async { - final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); + Future get({ + required String teamId, + }) async { + final String apiPath = '/teams/{teamId}'.replaceAll( + '{teamId}', + teamId, + ); final Map apiParams = {}; @@ -67,16 +84,25 @@ 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 { - final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); + Future updateName({ + required String teamId, + required String name, + }) async { + final String apiPath = '/teams/{teamId}'.replaceAll( + '{teamId}', + teamId, + ); final Map apiParams = { 'name': name, @@ -88,16 +114,25 @@ 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); } /// Delete a team using its ID. Only team members with the owner role can /// delete the team. - Future delete({required String teamId}) async { - final String apiPath = '/teams/{teamId}'.replaceAll('{teamId}', teamId); + Future delete({ + required String teamId, + }) async { + final String apiPath = '/teams/{teamId}'.replaceAll( + '{teamId}', + teamId, + ); final Map apiParams = {}; @@ -106,17 +141,26 @@ 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; } /// List app installations on a team. Any team member can read installations. - Future listInstallations( - {required String teamId, List? queries, bool? total}) async { - final String apiPath = - '/teams/{teamId}/installations'.replaceAll('{teamId}', teamId); + Future listInstallations({ + required String teamId, + List? queries, + bool? total, + }) async { + final String apiPath = '/teams/{teamId}/installations'.replaceAll( + '{teamId}', + teamId, + ); final Map apiParams = { if (queries != null) 'queries': queries, @@ -128,8 +172,12 @@ 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.AppInstallationList.fromMap(res.data); } @@ -138,12 +186,15 @@ class Teams extends Service { /// with the owner role can install apps. Requests using an API key or in admin /// mode can install apps on any team. The installation is granted the scopes /// the app currently requests. - Future createInstallation( - {required String teamId, - required String appId, - String? authorizationDetails}) async { - final String apiPath = - '/teams/{teamId}/installations'.replaceAll('{teamId}', teamId); + Future createInstallation({ + required String teamId, + required String appId, + String? authorizationDetails, + }) async { + final String apiPath = '/teams/{teamId}/installations'.replaceAll( + '{teamId}', + teamId, + ); final Map apiParams = { 'appId': appId, @@ -157,19 +208,31 @@ 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.AppInstallation.fromMap(res.data); } /// Get an app installation on a team by its unique ID. Any team member can /// read installations. - Future getInstallation( - {required String teamId, required String installationId}) async { + Future getInstallation({ + required String teamId, + required String installationId, + }) async { final String apiPath = '/teams/{teamId}/installations/{installationId}' - .replaceAll('{teamId}', teamId) - .replaceAll('{installationId}', installationId); + .replaceAll( + '{teamId}', + teamId, + ) + .replaceAll( + '{installationId}', + installationId, + ); final Map apiParams = {}; @@ -178,8 +241,12 @@ 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.AppInstallation.fromMap(res.data); } @@ -188,13 +255,20 @@ class Teams extends Service { /// can update installations. The installation's granted scopes are refreshed /// to the scopes the app currently requests; previously issued installation /// access tokens are revoked. - Future updateInstallation( - {required String teamId, - required String installationId, - String? authorizationDetails}) async { + Future updateInstallation({ + required String teamId, + required String installationId, + String? authorizationDetails, + }) async { final String apiPath = '/teams/{teamId}/installations/{installationId}' - .replaceAll('{teamId}', teamId) - .replaceAll('{installationId}', installationId); + .replaceAll( + '{teamId}', + teamId, + ) + .replaceAll( + '{installationId}', + installationId, + ); final Map apiParams = { if (authorizationDetails != null) @@ -207,8 +281,12 @@ 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.AppInstallation.fromMap(res.data); } @@ -216,11 +294,19 @@ class Teams extends Service { /// Uninstall an app from a team by its installation ID. Only team members with /// the owner role can remove installations. Previously issued installation /// access tokens are revoked. - Future deleteInstallation( - {required String teamId, required String installationId}) async { + Future deleteInstallation({ + required String teamId, + required String installationId, + }) async { final String apiPath = '/teams/{teamId}/installations/{installationId}' - .replaceAll('{teamId}', teamId) - .replaceAll('{installationId}', installationId); + .replaceAll( + '{teamId}', + teamId, + ) + .replaceAll( + '{installationId}', + installationId, + ); final Map apiParams = {}; @@ -230,8 +316,12 @@ class Teams extends Service { 'accept': '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; } @@ -239,13 +329,16 @@ 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, @@ -258,8 +351,12 @@ 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); } @@ -284,17 +381,19 @@ class Teams extends Service { /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) /// Appwrite will accept the only redirect URLs under the domains you have /// added as a platform on the Appwrite Console. - /// - Future createMembership( - {required String teamId, - required List roles, - String? email, - String? userId, - String? phone, - String? url, - String? name}) async { - final String apiPath = - '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); + 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, @@ -311,8 +410,12 @@ 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); } @@ -320,11 +423,19 @@ 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); + .replaceAll( + '{teamId}', + teamId, + ) + .replaceAll( + '{membershipId}', + membershipId, + ); final Map apiParams = {}; @@ -333,8 +444,12 @@ 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); } @@ -342,14 +457,20 @@ class Teams extends Service { /// Modify the roles of a team member. Only team members with the owner role /// have access to this endpoint. Learn more about [roles and /// permissions](https://appwrite.io/docs/permissions). - /// - Future updateMembership( - {required String teamId, - required String membershipId, - required List roles}) async { + 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); + .replaceAll( + '{teamId}', + teamId, + ) + .replaceAll( + '{membershipId}', + membershipId, + ); final Map apiParams = { 'roles': roles, @@ -361,8 +482,12 @@ 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); } @@ -370,11 +495,19 @@ 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); + .replaceAll( + '{teamId}', + teamId, + ) + .replaceAll( + '{membershipId}', + membershipId, + ); final Map apiParams = {}; @@ -383,8 +516,12 @@ 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; } @@ -395,15 +532,21 @@ 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); + .replaceAll( + '{teamId}', + teamId, + ) + .replaceAll( + '{membershipId}', + membershipId, + ); final Map apiParams = { 'userId': userId, @@ -416,8 +559,12 @@ 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); } @@ -425,9 +572,13 @@ class Teams extends Service { /// Get the team's shared preferences by its unique ID. If a preference doesn't /// need to be shared by all team members, prefer storing them in [user /// preferences](https://appwrite.io/docs/references/cloud/client-web/account#getPrefs). - Future getPrefs({required String teamId}) async { - final String apiPath = - '/teams/{teamId}/prefs'.replaceAll('{teamId}', teamId); + Future getPrefs({ + required String teamId, + }) async { + final String apiPath = '/teams/{teamId}/prefs'.replaceAll( + '{teamId}', + teamId, + ); final Map apiParams = {}; @@ -436,8 +587,12 @@ 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); } @@ -445,10 +600,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, @@ -460,8 +619,12 @@ 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 dbfe4bdf..6fe9425c 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -27,8 +27,7 @@ abstract class Client { factory Client({ String endPoint = 'https://cloud.appwrite.io/v1', bool selfSigned = false, - }) => - createClient(endPoint: endPoint, selfSigned: selfSigned); + }) => createClient(endPoint: endPoint, selfSigned: selfSigned); /// Handle OAuth2 session creation. Future webAuth(Uri url, {String? callbackUrlScheme}); diff --git a/lib/src/client_browser.dart b/lib/src/client_browser.dart index 47d38062..63a87c51 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.4.0', + 'x-sdk-version': '26.0.0', 'X-Appwrite-Response-Format': '1.9.6', }; @@ -215,7 +215,7 @@ class ClientBrowser extends ClientBase with ClientMixin { var offset = 0; String? uploadId; - if (idParamName.isNotEmpty) { + if (idParamName.isNotEmpty && params[idParamName] != null) { //make a request to check if a file already exists try { res = await call( @@ -236,7 +236,11 @@ 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(); diff --git a/lib/src/client_io.dart b/lib/src/client_io.dart index c675f9e1..ee52e2ea 100644 --- a/lib/src/client_io.dart +++ b/lib/src/client_io.dart @@ -1,3 +1,4 @@ +import 'dart:convert'; import 'dart:io'; import 'dart:math'; import 'package:cookie_jar/cookie_jar.dart'; @@ -46,9 +47,10 @@ class ClientIO extends ClientBase with ClientMixin { String endPoint = 'https://cloud.appwrite.io/v1', this.selfSigned = false, }) : _endPoint = endPoint { - _nativeClient = HttpClient() - ..badCertificateCallback = - ((X509Certificate cert, String host, int port) => selfSigned); + _nativeClient = + HttpClient() + ..badCertificateCallback = + ((X509Certificate cert, String host, int port) => selfSigned); _httpClient = IOClient(_nativeClient); _endPointRealtime = endPoint .replaceFirst('https://', 'wss://') @@ -58,7 +60,7 @@ class ClientIO extends ClientBase with ClientMixin { 'x-sdk-name': 'Flutter', 'x-sdk-platform': 'client', 'x-sdk-language': 'flutter', - 'x-sdk-version': '25.4.0', + 'x-sdk-version': '26.0.0', 'X-Appwrite-Response-Format': '1.9.6', }; @@ -336,7 +338,7 @@ class ClientIO extends ClientBase with ClientMixin { var offset = 0; String? uploadId; - if (idParamName.isNotEmpty) { + if (idParamName.isNotEmpty && params[idParamName] != null) { //make a request to check if a file already exists try { res = await call( @@ -356,8 +358,13 @@ 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(); @@ -481,9 +488,10 @@ class ClientIO extends ClientBase with ClientMixin { Future webAuth(Uri url, {String? callbackUrlScheme}) { return FlutterWebAuth2.authenticate( url: url.toString(), - callbackUrlScheme: callbackUrlScheme != null && _customSchemeAllowed - ? callbackUrlScheme - : "appwrite-callback-${config['project']!}", + callbackUrlScheme: + callbackUrlScheme != null && _customSchemeAllowed + ? callbackUrlScheme + : "appwrite-callback-${config['project']!}", options: const FlutterWebAuth2Options( useWebview: false, ), @@ -492,6 +500,30 @@ class ClientIO extends ClientBase with ClientMixin { final key = url.queryParameters['key']; final secret = url.queryParameters['secret']; if (key == null || secret == null) { + final error = url.queryParameters['error']; + if (error != null && error.isNotEmpty) { + try { + final parsed = jsonDecode(error); + if (parsed is Map) { + final codeValue = parsed['code']; + final int? code = + codeValue is int + ? codeValue + : int.tryParse('${codeValue ?? ''}'); + throw AppwriteException( + parsed['message']?.toString() ?? error, + code, + parsed['type']?.toString(), + error, + ); + } + } on AppwriteException { + rethrow; + } catch (_) { + // Fall through to a plain-string error when JSON is malformed. + } + throw AppwriteException(error); + } throw AppwriteException( "Invalid OAuth2 Response. Key and Secret not available.", 500, diff --git a/lib/src/client_mixin.dart b/lib/src/client_mixin.dart index 89aad359..3ca20708 100644 --- a/lib/src/client_mixin.dart +++ b/lib/src/client_mixin.dart @@ -92,7 +92,12 @@ mixin ClientMixin { } if (res.statusCode >= 400) { - if ((res.headers['content-type'] ?? '').contains('application/json')) { + final isJson = (res.headers['content-type'] ?? '').contains( + 'application/json', + ); + // Empty bodies still arrive with application/json (e.g. truncated + // proxy/edge errors). Avoid FormatException from json.decode(''). + if (isJson && res.body.isNotEmpty) { final response = json.decode(res.body); throw AppwriteException( response['message'], @@ -101,7 +106,14 @@ mixin ClientMixin { res.body, ); } else { - throw AppwriteException(res.body, res.statusCode, '', res.body); + throw AppwriteException( + res.body.isEmpty + ? 'Unexpected empty response with status ${res.statusCode}' + : res.body, + res.statusCode, + '', + res.body, + ); } } dynamic data; @@ -130,10 +142,12 @@ 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 6b1e67cd..05253273 100644 --- a/lib/src/cookie_manager.dart +++ b/lib/src/cookie_manager.dart @@ -17,14 +17,15 @@ class CookieManager extends Interceptor { await cookieJar .loadForRequest(Uri(scheme: request.url.scheme, host: request.url.host)) .then((cookies) { - var cookie = getCookies(cookies); - if (cookie.isNotEmpty) { - request.headers.addAll({HttpHeaders.cookieHeader: cookie}); - } - return request; - }).catchError((e, stackTrace) { - return request; - }); + var cookie = getCookies(cookies); + if (cookie.isNotEmpty) { + request.headers.addAll({HttpHeaders.cookieHeader: cookie}); + } + return request; + }) + .catchError((e, stackTrace) { + return request; + }); return request; } @@ -43,8 +44,9 @@ class CookieManager extends Interceptor { var cookies = cookie.split(exp); await cookieJar.saveFromResponse( Uri( - scheme: response.request!.url.scheme, - host: response.request!.url.host), + scheme: response.request!.url.scheme, + host: response.request!.url.host, + ), cookies.map((str) => Cookie.fromSetCookieValue(str)).toList(), ); } diff --git a/lib/src/enums.dart b/lib/src/enums.dart index 595afdc2..0f250ea3 100644 --- a/lib/src/enums.dart +++ b/lib/src/enums.dart @@ -17,5 +17,5 @@ enum ResponseType { plain, /// Get original bytes, the type of response will be `List` - bytes + bytes, } diff --git a/lib/src/enums/authentication_factor.dart b/lib/src/enums/authentication_factor.dart index 1d5271eb..99019503 100644 --- a/lib/src/enums/authentication_factor.dart +++ b/lib/src/enums/authentication_factor.dart @@ -1,10 +1,11 @@ part of '../../enums.dart'; enum AuthenticationFactor { - email(value: 'email'), - phone(value: 'phone'), - totp(value: 'totp'), - recoverycode(value: 'recoverycode'); + email(value: "email"), + phone(value: "phone"), + totp(value: "totp"), + recoverycode(value: "recoverycode"), + custom(value: "custom"); const AuthenticationFactor({required this.value}); diff --git a/lib/src/enums/authenticator_type.dart b/lib/src/enums/authenticator_type.dart index c1fe8584..c173d98b 100644 --- a/lib/src/enums/authenticator_type.dart +++ b/lib/src/enums/authenticator_type.dart @@ -1,7 +1,7 @@ part of '../../enums.dart'; enum AuthenticatorType { - totp(value: 'totp'); + totp(value: "totp"); const AuthenticatorType({required this.value}); diff --git a/lib/src/enums/browser.dart b/lib/src/enums/browser.dart index 949f4c47..5c31e055 100644 --- a/lib/src/enums/browser.dart +++ b/lib/src/enums/browser.dart @@ -1,20 +1,20 @@ part of '../../enums.dart'; enum Browser { - avantBrowser(value: 'aa'), - androidWebViewBeta(value: 'an'), - googleChrome(value: 'ch'), - googleChromeIOS(value: 'ci'), - googleChromeMobile(value: 'cm'), - chromium(value: 'cr'), - mozillaFirefox(value: 'ff'), - safari(value: 'sf'), - mobileSafari(value: 'mf'), - microsoftEdge(value: 'ps'), - microsoftEdgeIOS(value: 'oi'), - operaMini(value: 'om'), - opera(value: 'op'), - operaNext(value: 'on'); + avantBrowser(value: "aa"), + androidWebViewBeta(value: "an"), + googleChrome(value: "ch"), + googleChromeIOS(value: "ci"), + googleChromeMobile(value: "cm"), + chromium(value: "cr"), + mozillaFirefox(value: "ff"), + safari(value: "sf"), + mobileSafari(value: "mf"), + microsoftEdge(value: "ps"), + microsoftEdgeIOS(value: "oi"), + operaMini(value: "om"), + opera(value: "op"), + operaNext(value: "on"); const Browser({required this.value}); diff --git a/lib/src/enums/browser_permission.dart b/lib/src/enums/browser_permission.dart index fb4983db..6bd74622 100644 --- a/lib/src/enums/browser_permission.dart +++ b/lib/src/enums/browser_permission.dart @@ -1,26 +1,26 @@ part of '../../enums.dart'; enum BrowserPermission { - geolocation(value: 'geolocation'), - camera(value: 'camera'), - microphone(value: 'microphone'), - notifications(value: 'notifications'), - midi(value: 'midi'), - push(value: 'push'), - clipboardRead(value: 'clipboard-read'), - clipboardWrite(value: 'clipboard-write'), - paymentHandler(value: 'payment-handler'), - usb(value: 'usb'), - bluetooth(value: 'bluetooth'), - accelerometer(value: 'accelerometer'), - gyroscope(value: 'gyroscope'), - magnetometer(value: 'magnetometer'), - ambientLightSensor(value: 'ambient-light-sensor'), - backgroundSync(value: 'background-sync'), - persistentStorage(value: 'persistent-storage'), - screenWakeLock(value: 'screen-wake-lock'), - webShare(value: 'web-share'), - xrSpatialTracking(value: 'xr-spatial-tracking'); + geolocation(value: "geolocation"), + camera(value: "camera"), + microphone(value: "microphone"), + notifications(value: "notifications"), + midi(value: "midi"), + push(value: "push"), + clipboardRead(value: "clipboard-read"), + clipboardWrite(value: "clipboard-write"), + paymentHandler(value: "payment-handler"), + usb(value: "usb"), + bluetooth(value: "bluetooth"), + accelerometer(value: "accelerometer"), + gyroscope(value: "gyroscope"), + magnetometer(value: "magnetometer"), + ambientLightSensor(value: "ambient-light-sensor"), + backgroundSync(value: "background-sync"), + persistentStorage(value: "persistent-storage"), + screenWakeLock(value: "screen-wake-lock"), + webShare(value: "web-share"), + xrSpatialTracking(value: "xr-spatial-tracking"); const BrowserPermission({required this.value}); diff --git a/lib/src/enums/browser_theme.dart b/lib/src/enums/browser_theme.dart index 1e059c2c..48a3e464 100644 --- a/lib/src/enums/browser_theme.dart +++ b/lib/src/enums/browser_theme.dart @@ -1,8 +1,8 @@ part of '../../enums.dart'; enum BrowserTheme { - light(value: 'light'), - dark(value: 'dark'); + light(value: "light"), + dark(value: "dark"); const BrowserTheme({required this.value}); diff --git a/lib/src/enums/credit_card.dart b/lib/src/enums/credit_card.dart index 28c2a1b3..bb40ecae 100644 --- a/lib/src/enums/credit_card.dart +++ b/lib/src/enums/credit_card.dart @@ -1,23 +1,23 @@ part of '../../enums.dart'; enum CreditCard { - americanExpress(value: 'amex'), - argencard(value: 'argencard'), - cabal(value: 'cabal'), - cencosud(value: 'cencosud'), - dinersClub(value: 'diners'), - discover(value: 'discover'), - elo(value: 'elo'), - hipercard(value: 'hipercard'), - jCB(value: 'jcb'), - mastercard(value: 'mastercard'), - naranja(value: 'naranja'), - tarjetaShopping(value: 'targeta-shopping'), - unionPay(value: 'unionpay'), - visa(value: 'visa'), - mIR(value: 'mir'), - maestro(value: 'maestro'), - rupay(value: 'rupay'); + americanExpress(value: "amex"), + argencard(value: "argencard"), + cabal(value: "cabal"), + cencosud(value: "cencosud"), + dinersClub(value: "diners"), + discover(value: "discover"), + elo(value: "elo"), + hipercard(value: "hipercard"), + jCB(value: "jcb"), + mastercard(value: "mastercard"), + naranja(value: "naranja"), + tarjetaShopping(value: "targeta-shopping"), + unionPay(value: "unionpay"), + visa(value: "visa"), + mIR(value: "mir"), + maestro(value: "maestro"), + rupay(value: "rupay"); const CreditCard({required this.value}); diff --git a/lib/src/enums/execution_method.dart b/lib/src/enums/execution_method.dart index 44de4907..80abd2da 100644 --- a/lib/src/enums/execution_method.dart +++ b/lib/src/enums/execution_method.dart @@ -1,13 +1,13 @@ part of '../../enums.dart'; enum ExecutionMethod { - gET(value: 'GET'), - pOST(value: 'POST'), - pUT(value: 'PUT'), - pATCH(value: 'PATCH'), - dELETE(value: 'DELETE'), - oPTIONS(value: 'OPTIONS'), - hEAD(value: 'HEAD'); + gET(value: "GET"), + pOST(value: "POST"), + pUT(value: "PUT"), + pATCH(value: "PATCH"), + dELETE(value: "DELETE"), + oPTIONS(value: "OPTIONS"), + hEAD(value: "HEAD"); const ExecutionMethod({required this.value}); diff --git a/lib/src/enums/execution_resource_type.dart b/lib/src/enums/execution_resource_type.dart new file mode 100644 index 00000000..d59d2a50 --- /dev/null +++ b/lib/src/enums/execution_resource_type.dart @@ -0,0 +1,12 @@ +part of '../../enums.dart'; + +enum ExecutionResourceType { + functions(value: "functions"), + sites(value: "sites"); + + const ExecutionResourceType({required this.value}); + + final String value; + + String toJson() => value; +} diff --git a/lib/src/enums/execution_status.dart b/lib/src/enums/execution_status.dart index 7ea9865e..d65d4981 100644 --- a/lib/src/enums/execution_status.dart +++ b/lib/src/enums/execution_status.dart @@ -1,11 +1,11 @@ part of '../../enums.dart'; enum ExecutionStatus { - waiting(value: 'waiting'), - processing(value: 'processing'), - completed(value: 'completed'), - failed(value: 'failed'), - scheduled(value: 'scheduled'); + waiting(value: "waiting"), + processing(value: "processing"), + completed(value: "completed"), + failed(value: "failed"), + scheduled(value: "scheduled"); const ExecutionStatus({required this.value}); diff --git a/lib/src/enums/execution_trigger.dart b/lib/src/enums/execution_trigger.dart index fb05eb7d..a0816b66 100644 --- a/lib/src/enums/execution_trigger.dart +++ b/lib/src/enums/execution_trigger.dart @@ -1,9 +1,9 @@ part of '../../enums.dart'; enum ExecutionTrigger { - http(value: 'http'), - schedule(value: 'schedule'), - event(value: 'event'); + http(value: "http"), + schedule(value: "schedule"), + event(value: "event"); const ExecutionTrigger({required this.value}); diff --git a/lib/src/enums/flag.dart b/lib/src/enums/flag.dart index a44cb81d..3c6a9695 100644 --- a/lib/src/enums/flag.dart +++ b/lib/src/enums/flag.dart @@ -1,201 +1,201 @@ part of '../../enums.dart'; enum Flag { - afghanistan(value: 'af'), - angola(value: 'ao'), - albania(value: 'al'), - andorra(value: 'ad'), - unitedArabEmirates(value: 'ae'), - argentina(value: 'ar'), - armenia(value: 'am'), - antiguaAndBarbuda(value: 'ag'), - australia(value: 'au'), - austria(value: 'at'), - azerbaijan(value: 'az'), - burundi(value: 'bi'), - belgium(value: 'be'), - benin(value: 'bj'), - burkinaFaso(value: 'bf'), - bangladesh(value: 'bd'), - bulgaria(value: 'bg'), - bahrain(value: 'bh'), - bahamas(value: 'bs'), - bosniaAndHerzegovina(value: 'ba'), - belarus(value: 'by'), - belize(value: 'bz'), - bolivia(value: 'bo'), - brazil(value: 'br'), - barbados(value: 'bb'), - bruneiDarussalam(value: 'bn'), - bhutan(value: 'bt'), - botswana(value: 'bw'), - centralAfricanRepublic(value: 'cf'), - canada(value: 'ca'), - switzerland(value: 'ch'), - chile(value: 'cl'), - china(value: 'cn'), - coteDIvoire(value: 'ci'), - cameroon(value: 'cm'), - democraticRepublicOfTheCongo(value: 'cd'), - republicOfTheCongo(value: 'cg'), - colombia(value: 'co'), - comoros(value: 'km'), - capeVerde(value: 'cv'), - costaRica(value: 'cr'), - cuba(value: 'cu'), - cyprus(value: 'cy'), - czechRepublic(value: 'cz'), - germany(value: 'de'), - djibouti(value: 'dj'), - dominica(value: 'dm'), - denmark(value: 'dk'), - dominicanRepublic(value: 'do'), - algeria(value: 'dz'), - ecuador(value: 'ec'), - egypt(value: 'eg'), - eritrea(value: 'er'), - spain(value: 'es'), - estonia(value: 'ee'), - ethiopia(value: 'et'), - finland(value: 'fi'), - fiji(value: 'fj'), - france(value: 'fr'), - micronesiaFederatedStatesOf(value: 'fm'), - gabon(value: 'ga'), - unitedKingdom(value: 'gb'), - georgia(value: 'ge'), - ghana(value: 'gh'), - guinea(value: 'gn'), - gambia(value: 'gm'), - guineaBissau(value: 'gw'), - equatorialGuinea(value: 'gq'), - greece(value: 'gr'), - grenada(value: 'gd'), - guatemala(value: 'gt'), - guyana(value: 'gy'), - honduras(value: 'hn'), - croatia(value: 'hr'), - haiti(value: 'ht'), - hungary(value: 'hu'), - indonesia(value: 'id'), - india(value: 'in'), - ireland(value: 'ie'), - iranIslamicRepublicOf(value: 'ir'), - iraq(value: 'iq'), - iceland(value: 'is'), - israel(value: 'il'), - italy(value: 'it'), - jamaica(value: 'jm'), - jordan(value: 'jo'), - japan(value: 'jp'), - kazakhstan(value: 'kz'), - kenya(value: 'ke'), - kyrgyzstan(value: 'kg'), - cambodia(value: 'kh'), - kiribati(value: 'ki'), - saintKittsAndNevis(value: 'kn'), - southKorea(value: 'kr'), - kuwait(value: 'kw'), - laoPeopleSDemocraticRepublic(value: 'la'), - lebanon(value: 'lb'), - liberia(value: 'lr'), - libya(value: 'ly'), - saintLucia(value: 'lc'), - liechtenstein(value: 'li'), - sriLanka(value: 'lk'), - lesotho(value: 'ls'), - lithuania(value: 'lt'), - luxembourg(value: 'lu'), - latvia(value: 'lv'), - morocco(value: 'ma'), - monaco(value: 'mc'), - moldova(value: 'md'), - madagascar(value: 'mg'), - maldives(value: 'mv'), - mexico(value: 'mx'), - marshallIslands(value: 'mh'), - northMacedonia(value: 'mk'), - mali(value: 'ml'), - malta(value: 'mt'), - myanmar(value: 'mm'), - montenegro(value: 'me'), - mongolia(value: 'mn'), - mozambique(value: 'mz'), - mauritania(value: 'mr'), - mauritius(value: 'mu'), - malawi(value: 'mw'), - malaysia(value: 'my'), - namibia(value: 'na'), - niger(value: 'ne'), - nigeria(value: 'ng'), - nicaragua(value: 'ni'), - netherlands(value: 'nl'), - norway(value: 'no'), - nepal(value: 'np'), - nauru(value: 'nr'), - newZealand(value: 'nz'), - oman(value: 'om'), - pakistan(value: 'pk'), - panama(value: 'pa'), - peru(value: 'pe'), - philippines(value: 'ph'), - palau(value: 'pw'), - papuaNewGuinea(value: 'pg'), - poland(value: 'pl'), - frenchPolynesia(value: 'pf'), - northKorea(value: 'kp'), - portugal(value: 'pt'), - paraguay(value: 'py'), - qatar(value: 'qa'), - romania(value: 'ro'), - russia(value: 'ru'), - rwanda(value: 'rw'), - saudiArabia(value: 'sa'), - sudan(value: 'sd'), - senegal(value: 'sn'), - singapore(value: 'sg'), - solomonIslands(value: 'sb'), - sierraLeone(value: 'sl'), - elSalvador(value: 'sv'), - sanMarino(value: 'sm'), - somalia(value: 'so'), - serbia(value: 'rs'), - southSudan(value: 'ss'), - saoTomeAndPrincipe(value: 'st'), - suriname(value: 'sr'), - slovakia(value: 'sk'), - slovenia(value: 'si'), - sweden(value: 'se'), - eswatini(value: 'sz'), - seychelles(value: 'sc'), - syria(value: 'sy'), - chad(value: 'td'), - togo(value: 'tg'), - thailand(value: 'th'), - tajikistan(value: 'tj'), - turkmenistan(value: 'tm'), - timorLeste(value: 'tl'), - tonga(value: 'to'), - trinidadAndTobago(value: 'tt'), - tunisia(value: 'tn'), - turkey(value: 'tr'), - tuvalu(value: 'tv'), - tanzania(value: 'tz'), - uganda(value: 'ug'), - ukraine(value: 'ua'), - uruguay(value: 'uy'), - unitedStates(value: 'us'), - uzbekistan(value: 'uz'), - vaticanCity(value: 'va'), - saintVincentAndTheGrenadines(value: 'vc'), - venezuela(value: 've'), - vietnam(value: 'vn'), - vanuatu(value: 'vu'), - samoa(value: 'ws'), - yemen(value: 'ye'), - southAfrica(value: 'za'), - zambia(value: 'zm'), - zimbabwe(value: 'zw'); + afghanistan(value: "af"), + angola(value: "ao"), + albania(value: "al"), + andorra(value: "ad"), + unitedArabEmirates(value: "ae"), + argentina(value: "ar"), + armenia(value: "am"), + antiguaAndBarbuda(value: "ag"), + australia(value: "au"), + austria(value: "at"), + azerbaijan(value: "az"), + burundi(value: "bi"), + belgium(value: "be"), + benin(value: "bj"), + burkinaFaso(value: "bf"), + bangladesh(value: "bd"), + bulgaria(value: "bg"), + bahrain(value: "bh"), + bahamas(value: "bs"), + bosniaAndHerzegovina(value: "ba"), + belarus(value: "by"), + belize(value: "bz"), + bolivia(value: "bo"), + brazil(value: "br"), + barbados(value: "bb"), + bruneiDarussalam(value: "bn"), + bhutan(value: "bt"), + botswana(value: "bw"), + centralAfricanRepublic(value: "cf"), + canada(value: "ca"), + switzerland(value: "ch"), + chile(value: "cl"), + china(value: "cn"), + coteDIvoire(value: "ci"), + cameroon(value: "cm"), + democraticRepublicOfTheCongo(value: "cd"), + republicOfTheCongo(value: "cg"), + colombia(value: "co"), + comoros(value: "km"), + capeVerde(value: "cv"), + costaRica(value: "cr"), + cuba(value: "cu"), + cyprus(value: "cy"), + czechRepublic(value: "cz"), + germany(value: "de"), + djibouti(value: "dj"), + dominica(value: "dm"), + denmark(value: "dk"), + dominicanRepublic(value: "do"), + algeria(value: "dz"), + ecuador(value: "ec"), + egypt(value: "eg"), + eritrea(value: "er"), + spain(value: "es"), + estonia(value: "ee"), + ethiopia(value: "et"), + finland(value: "fi"), + fiji(value: "fj"), + france(value: "fr"), + micronesiaFederatedStatesOf(value: "fm"), + gabon(value: "ga"), + unitedKingdom(value: "gb"), + georgia(value: "ge"), + ghana(value: "gh"), + guinea(value: "gn"), + gambia(value: "gm"), + guineaBissau(value: "gw"), + equatorialGuinea(value: "gq"), + greece(value: "gr"), + grenada(value: "gd"), + guatemala(value: "gt"), + guyana(value: "gy"), + honduras(value: "hn"), + croatia(value: "hr"), + haiti(value: "ht"), + hungary(value: "hu"), + indonesia(value: "id"), + india(value: "in"), + ireland(value: "ie"), + iranIslamicRepublicOf(value: "ir"), + iraq(value: "iq"), + iceland(value: "is"), + israel(value: "il"), + italy(value: "it"), + jamaica(value: "jm"), + jordan(value: "jo"), + japan(value: "jp"), + kazakhstan(value: "kz"), + kenya(value: "ke"), + kyrgyzstan(value: "kg"), + cambodia(value: "kh"), + kiribati(value: "ki"), + saintKittsAndNevis(value: "kn"), + southKorea(value: "kr"), + kuwait(value: "kw"), + laoPeopleSDemocraticRepublic(value: "la"), + lebanon(value: "lb"), + liberia(value: "lr"), + libya(value: "ly"), + saintLucia(value: "lc"), + liechtenstein(value: "li"), + sriLanka(value: "lk"), + lesotho(value: "ls"), + lithuania(value: "lt"), + luxembourg(value: "lu"), + latvia(value: "lv"), + morocco(value: "ma"), + monaco(value: "mc"), + moldova(value: "md"), + madagascar(value: "mg"), + maldives(value: "mv"), + mexico(value: "mx"), + marshallIslands(value: "mh"), + northMacedonia(value: "mk"), + mali(value: "ml"), + malta(value: "mt"), + myanmar(value: "mm"), + montenegro(value: "me"), + mongolia(value: "mn"), + mozambique(value: "mz"), + mauritania(value: "mr"), + mauritius(value: "mu"), + malawi(value: "mw"), + malaysia(value: "my"), + namibia(value: "na"), + niger(value: "ne"), + nigeria(value: "ng"), + nicaragua(value: "ni"), + netherlands(value: "nl"), + norway(value: "no"), + nepal(value: "np"), + nauru(value: "nr"), + newZealand(value: "nz"), + oman(value: "om"), + pakistan(value: "pk"), + panama(value: "pa"), + peru(value: "pe"), + philippines(value: "ph"), + palau(value: "pw"), + papuaNewGuinea(value: "pg"), + poland(value: "pl"), + frenchPolynesia(value: "pf"), + northKorea(value: "kp"), + portugal(value: "pt"), + paraguay(value: "py"), + qatar(value: "qa"), + romania(value: "ro"), + russia(value: "ru"), + rwanda(value: "rw"), + saudiArabia(value: "sa"), + sudan(value: "sd"), + senegal(value: "sn"), + singapore(value: "sg"), + solomonIslands(value: "sb"), + sierraLeone(value: "sl"), + elSalvador(value: "sv"), + sanMarino(value: "sm"), + somalia(value: "so"), + serbia(value: "rs"), + southSudan(value: "ss"), + saoTomeAndPrincipe(value: "st"), + suriname(value: "sr"), + slovakia(value: "sk"), + slovenia(value: "si"), + sweden(value: "se"), + eswatini(value: "sz"), + seychelles(value: "sc"), + syria(value: "sy"), + chad(value: "td"), + togo(value: "tg"), + thailand(value: "th"), + tajikistan(value: "tj"), + turkmenistan(value: "tm"), + timorLeste(value: "tl"), + tonga(value: "to"), + trinidadAndTobago(value: "tt"), + tunisia(value: "tn"), + turkey(value: "tr"), + tuvalu(value: "tv"), + tanzania(value: "tz"), + uganda(value: "ug"), + ukraine(value: "ua"), + uruguay(value: "uy"), + unitedStates(value: "us"), + uzbekistan(value: "uz"), + vaticanCity(value: "va"), + saintVincentAndTheGrenadines(value: "vc"), + venezuela(value: "ve"), + vietnam(value: "vn"), + vanuatu(value: "vu"), + samoa(value: "ws"), + yemen(value: "ye"), + southAfrica(value: "za"), + zambia(value: "zm"), + zimbabwe(value: "zw"); const Flag({required this.value}); diff --git a/lib/src/enums/image_format.dart b/lib/src/enums/image_format.dart index 55f4c5db..aa1e7a92 100644 --- a/lib/src/enums/image_format.dart +++ b/lib/src/enums/image_format.dart @@ -1,13 +1,13 @@ part of '../../enums.dart'; enum ImageFormat { - jpg(value: 'jpg'), - jpeg(value: 'jpeg'), - png(value: 'png'), - webp(value: 'webp'), - heic(value: 'heic'), - avif(value: 'avif'), - gif(value: 'gif'); + jpg(value: "jpg"), + jpeg(value: "jpeg"), + png(value: "png"), + webp(value: "webp"), + heic(value: "heic"), + avif(value: "avif"), + gif(value: "gif"); const ImageFormat({required this.value}); diff --git a/lib/src/enums/image_gravity.dart b/lib/src/enums/image_gravity.dart index 88029044..dbcef202 100644 --- a/lib/src/enums/image_gravity.dart +++ b/lib/src/enums/image_gravity.dart @@ -1,15 +1,15 @@ part of '../../enums.dart'; enum ImageGravity { - center(value: 'center'), - topLeft(value: 'top-left'), - top(value: 'top'), - topRight(value: 'top-right'), - left(value: 'left'), - right(value: 'right'), - bottomLeft(value: 'bottom-left'), - bottom(value: 'bottom'), - bottomRight(value: 'bottom-right'); + center(value: "center"), + topLeft(value: "top-left"), + top(value: "top"), + topRight(value: "top-right"), + left(value: "left"), + right(value: "right"), + bottomLeft(value: "bottom-left"), + bottom(value: "bottom"), + bottomRight(value: "bottom-right"); const ImageGravity({required this.value}); diff --git a/lib/src/enums/o_auth_provider.dart b/lib/src/enums/o_auth_provider.dart index 6c8dbc70..1bd23697 100644 --- a/lib/src/enums/o_auth_provider.dart +++ b/lib/src/enums/o_auth_provider.dart @@ -1,50 +1,51 @@ part of '../../enums.dart'; enum OAuthProvider { - amazon(value: 'amazon'), - apple(value: 'apple'), - appwrite(value: 'appwrite'), - auth0(value: 'auth0'), - authentik(value: 'authentik'), - autodesk(value: 'autodesk'), - bitbucket(value: 'bitbucket'), - bitly(value: 'bitly'), - box(value: 'box'), - dailymotion(value: 'dailymotion'), - discord(value: 'discord'), - disqus(value: 'disqus'), - dropbox(value: 'dropbox'), - etsy(value: 'etsy'), - facebook(value: 'facebook'), - figma(value: 'figma'), - fusionauth(value: 'fusionauth'), - github(value: 'github'), - gitlab(value: 'gitlab'), - google(value: 'google'), - keycloak(value: 'keycloak'), - kick(value: 'kick'), - linkedin(value: 'linkedin'), - microsoft(value: 'microsoft'), - notion(value: 'notion'), - oidc(value: 'oidc'), - okta(value: 'okta'), - paypal(value: 'paypal'), - paypalSandbox(value: 'paypalSandbox'), - podio(value: 'podio'), - salesforce(value: 'salesforce'), - slack(value: 'slack'), - spotify(value: 'spotify'), - stripe(value: 'stripe'), - tradeshift(value: 'tradeshift'), - tradeshiftBox(value: 'tradeshiftBox'), - twitch(value: 'twitch'), - wordpress(value: 'wordpress'), - x(value: 'x'), - yahoo(value: 'yahoo'), - yammer(value: 'yammer'), - yandex(value: 'yandex'), - zoho(value: 'zoho'), - zoom(value: 'zoom'); + amazon(value: "amazon"), + apple(value: "apple"), + appwrite(value: "appwrite"), + auth0(value: "auth0"), + authentik(value: "authentik"), + autodesk(value: "autodesk"), + bitbucket(value: "bitbucket"), + bitly(value: "bitly"), + box(value: "box"), + dailymotion(value: "dailymotion"), + discord(value: "discord"), + disqus(value: "disqus"), + dropbox(value: "dropbox"), + etsy(value: "etsy"), + facebook(value: "facebook"), + figma(value: "figma"), + fusionauth(value: "fusionauth"), + github(value: "github"), + gitlab(value: "gitlab"), + google(value: "google"), + huggingface(value: "huggingface"), + keycloak(value: "keycloak"), + kick(value: "kick"), + linkedin(value: "linkedin"), + microsoft(value: "microsoft"), + notion(value: "notion"), + oidc(value: "oidc"), + okta(value: "okta"), + paypal(value: "paypal"), + paypalSandbox(value: "paypalSandbox"), + podio(value: "podio"), + salesforce(value: "salesforce"), + slack(value: "slack"), + spotify(value: "spotify"), + stripe(value: "stripe"), + tradeshift(value: "tradeshift"), + tradeshiftBox(value: "tradeshiftBox"), + twitch(value: "twitch"), + wordpress(value: "wordpress"), + x(value: "x"), + yahoo(value: "yahoo"), + yammer(value: "yammer"), + yandex(value: "yandex"), + zoho(value: "zoho"), + zoom(value: "zoom"); const OAuthProvider({required this.value}); diff --git a/lib/src/enums/timezone.dart b/lib/src/enums/timezone.dart index d5d8d94a..2f49d305 100644 --- a/lib/src/enums/timezone.dart +++ b/lib/src/enums/timezone.dart @@ -1,425 +1,425 @@ part of '../../enums.dart'; enum Timezone { - africaAbidjan(value: 'africa/abidjan'), - africaAccra(value: 'africa/accra'), - africaAddisAbaba(value: 'africa/addis_ababa'), - africaAlgiers(value: 'africa/algiers'), - africaAsmara(value: 'africa/asmara'), - africaBamako(value: 'africa/bamako'), - africaBangui(value: 'africa/bangui'), - africaBanjul(value: 'africa/banjul'), - africaBissau(value: 'africa/bissau'), - africaBlantyre(value: 'africa/blantyre'), - africaBrazzaville(value: 'africa/brazzaville'), - africaBujumbura(value: 'africa/bujumbura'), - africaCairo(value: 'africa/cairo'), - africaCasablanca(value: 'africa/casablanca'), - africaCeuta(value: 'africa/ceuta'), - africaConakry(value: 'africa/conakry'), - africaDakar(value: 'africa/dakar'), - africaDarEsSalaam(value: 'africa/dar_es_salaam'), - africaDjibouti(value: 'africa/djibouti'), - africaDouala(value: 'africa/douala'), - africaElAaiun(value: 'africa/el_aaiun'), - africaFreetown(value: 'africa/freetown'), - africaGaborone(value: 'africa/gaborone'), - africaHarare(value: 'africa/harare'), - africaJohannesburg(value: 'africa/johannesburg'), - africaJuba(value: 'africa/juba'), - africaKampala(value: 'africa/kampala'), - africaKhartoum(value: 'africa/khartoum'), - africaKigali(value: 'africa/kigali'), - africaKinshasa(value: 'africa/kinshasa'), - africaLagos(value: 'africa/lagos'), - africaLibreville(value: 'africa/libreville'), - africaLome(value: 'africa/lome'), - africaLuanda(value: 'africa/luanda'), - africaLubumbashi(value: 'africa/lubumbashi'), - africaLusaka(value: 'africa/lusaka'), - africaMalabo(value: 'africa/malabo'), - africaMaputo(value: 'africa/maputo'), - africaMaseru(value: 'africa/maseru'), - africaMbabane(value: 'africa/mbabane'), - africaMogadishu(value: 'africa/mogadishu'), - africaMonrovia(value: 'africa/monrovia'), - africaNairobi(value: 'africa/nairobi'), - africaNdjamena(value: 'africa/ndjamena'), - africaNiamey(value: 'africa/niamey'), - africaNouakchott(value: 'africa/nouakchott'), - africaOuagadougou(value: 'africa/ouagadougou'), - africaPortoNovo(value: 'africa/porto-novo'), - africaSaoTome(value: 'africa/sao_tome'), - africaTripoli(value: 'africa/tripoli'), - africaTunis(value: 'africa/tunis'), - africaWindhoek(value: 'africa/windhoek'), - americaAdak(value: 'america/adak'), - americaAnchorage(value: 'america/anchorage'), - americaAnguilla(value: 'america/anguilla'), - americaAntigua(value: 'america/antigua'), - americaAraguaina(value: 'america/araguaina'), - americaArgentinaBuenosAires(value: 'america/argentina/buenos_aires'), - americaArgentinaCatamarca(value: 'america/argentina/catamarca'), - americaArgentinaCordoba(value: 'america/argentina/cordoba'), - americaArgentinaJujuy(value: 'america/argentina/jujuy'), - americaArgentinaLaRioja(value: 'america/argentina/la_rioja'), - americaArgentinaMendoza(value: 'america/argentina/mendoza'), - americaArgentinaRioGallegos(value: 'america/argentina/rio_gallegos'), - americaArgentinaSalta(value: 'america/argentina/salta'), - americaArgentinaSanJuan(value: 'america/argentina/san_juan'), - americaArgentinaSanLuis(value: 'america/argentina/san_luis'), - americaArgentinaTucuman(value: 'america/argentina/tucuman'), - americaArgentinaUshuaia(value: 'america/argentina/ushuaia'), - americaAruba(value: 'america/aruba'), - americaAsuncion(value: 'america/asuncion'), - americaAtikokan(value: 'america/atikokan'), - americaBahia(value: 'america/bahia'), - americaBahiaBanderas(value: 'america/bahia_banderas'), - americaBarbados(value: 'america/barbados'), - americaBelem(value: 'america/belem'), - americaBelize(value: 'america/belize'), - americaBlancSablon(value: 'america/blanc-sablon'), - americaBoaVista(value: 'america/boa_vista'), - americaBogota(value: 'america/bogota'), - americaBoise(value: 'america/boise'), - americaCambridgeBay(value: 'america/cambridge_bay'), - americaCampoGrande(value: 'america/campo_grande'), - americaCancun(value: 'america/cancun'), - americaCaracas(value: 'america/caracas'), - americaCayenne(value: 'america/cayenne'), - americaCayman(value: 'america/cayman'), - americaChicago(value: 'america/chicago'), - americaChihuahua(value: 'america/chihuahua'), - americaCiudadJuarez(value: 'america/ciudad_juarez'), - americaCostaRica(value: 'america/costa_rica'), - americaCoyhaique(value: 'america/coyhaique'), - americaCreston(value: 'america/creston'), - americaCuiaba(value: 'america/cuiaba'), - americaCuracao(value: 'america/curacao'), - americaDanmarkshavn(value: 'america/danmarkshavn'), - americaDawson(value: 'america/dawson'), - americaDawsonCreek(value: 'america/dawson_creek'), - americaDenver(value: 'america/denver'), - americaDetroit(value: 'america/detroit'), - americaDominica(value: 'america/dominica'), - americaEdmonton(value: 'america/edmonton'), - americaEirunepe(value: 'america/eirunepe'), - americaElSalvador(value: 'america/el_salvador'), - americaFortNelson(value: 'america/fort_nelson'), - americaFortaleza(value: 'america/fortaleza'), - americaGlaceBay(value: 'america/glace_bay'), - americaGooseBay(value: 'america/goose_bay'), - americaGrandTurk(value: 'america/grand_turk'), - americaGrenada(value: 'america/grenada'), - americaGuadeloupe(value: 'america/guadeloupe'), - americaGuatemala(value: 'america/guatemala'), - americaGuayaquil(value: 'america/guayaquil'), - americaGuyana(value: 'america/guyana'), - americaHalifax(value: 'america/halifax'), - americaHavana(value: 'america/havana'), - americaHermosillo(value: 'america/hermosillo'), - americaIndianaIndianapolis(value: 'america/indiana/indianapolis'), - americaIndianaKnox(value: 'america/indiana/knox'), - americaIndianaMarengo(value: 'america/indiana/marengo'), - americaIndianaPetersburg(value: 'america/indiana/petersburg'), - americaIndianaTellCity(value: 'america/indiana/tell_city'), - americaIndianaVevay(value: 'america/indiana/vevay'), - americaIndianaVincennes(value: 'america/indiana/vincennes'), - americaIndianaWinamac(value: 'america/indiana/winamac'), - americaInuvik(value: 'america/inuvik'), - americaIqaluit(value: 'america/iqaluit'), - americaJamaica(value: 'america/jamaica'), - americaJuneau(value: 'america/juneau'), - americaKentuckyLouisville(value: 'america/kentucky/louisville'), - americaKentuckyMonticello(value: 'america/kentucky/monticello'), - americaKralendijk(value: 'america/kralendijk'), - americaLaPaz(value: 'america/la_paz'), - americaLima(value: 'america/lima'), - americaLosAngeles(value: 'america/los_angeles'), - americaLowerPrinces(value: 'america/lower_princes'), - americaMaceio(value: 'america/maceio'), - americaManagua(value: 'america/managua'), - americaManaus(value: 'america/manaus'), - americaMarigot(value: 'america/marigot'), - americaMartinique(value: 'america/martinique'), - americaMatamoros(value: 'america/matamoros'), - americaMazatlan(value: 'america/mazatlan'), - americaMenominee(value: 'america/menominee'), - americaMerida(value: 'america/merida'), - americaMetlakatla(value: 'america/metlakatla'), - americaMexicoCity(value: 'america/mexico_city'), - americaMiquelon(value: 'america/miquelon'), - americaMoncton(value: 'america/moncton'), - americaMonterrey(value: 'america/monterrey'), - americaMontevideo(value: 'america/montevideo'), - americaMontserrat(value: 'america/montserrat'), - americaNassau(value: 'america/nassau'), - americaNewYork(value: 'america/new_york'), - americaNome(value: 'america/nome'), - americaNoronha(value: 'america/noronha'), - americaNorthDakotaBeulah(value: 'america/north_dakota/beulah'), - americaNorthDakotaCenter(value: 'america/north_dakota/center'), - americaNorthDakotaNewSalem(value: 'america/north_dakota/new_salem'), - americaNuuk(value: 'america/nuuk'), - americaOjinaga(value: 'america/ojinaga'), - americaPanama(value: 'america/panama'), - americaParamaribo(value: 'america/paramaribo'), - americaPhoenix(value: 'america/phoenix'), - americaPortAuPrince(value: 'america/port-au-prince'), - americaPortOfSpain(value: 'america/port_of_spain'), - americaPortoVelho(value: 'america/porto_velho'), - americaPuertoRico(value: 'america/puerto_rico'), - americaPuntaArenas(value: 'america/punta_arenas'), - americaRankinInlet(value: 'america/rankin_inlet'), - americaRecife(value: 'america/recife'), - americaRegina(value: 'america/regina'), - americaResolute(value: 'america/resolute'), - americaRioBranco(value: 'america/rio_branco'), - americaSantarem(value: 'america/santarem'), - americaSantiago(value: 'america/santiago'), - americaSantoDomingo(value: 'america/santo_domingo'), - americaSaoPaulo(value: 'america/sao_paulo'), - americaScoresbysund(value: 'america/scoresbysund'), - americaSitka(value: 'america/sitka'), - americaStBarthelemy(value: 'america/st_barthelemy'), - americaStJohns(value: 'america/st_johns'), - americaStKitts(value: 'america/st_kitts'), - americaStLucia(value: 'america/st_lucia'), - americaStThomas(value: 'america/st_thomas'), - americaStVincent(value: 'america/st_vincent'), - americaSwiftCurrent(value: 'america/swift_current'), - americaTegucigalpa(value: 'america/tegucigalpa'), - americaThule(value: 'america/thule'), - americaTijuana(value: 'america/tijuana'), - americaToronto(value: 'america/toronto'), - americaTortola(value: 'america/tortola'), - americaVancouver(value: 'america/vancouver'), - americaWhitehorse(value: 'america/whitehorse'), - americaWinnipeg(value: 'america/winnipeg'), - americaYakutat(value: 'america/yakutat'), - antarcticaCasey(value: 'antarctica/casey'), - antarcticaDavis(value: 'antarctica/davis'), - antarcticaDumontdurville(value: 'antarctica/dumontdurville'), - antarcticaMacquarie(value: 'antarctica/macquarie'), - antarcticaMawson(value: 'antarctica/mawson'), - antarcticaMcmurdo(value: 'antarctica/mcmurdo'), - antarcticaPalmer(value: 'antarctica/palmer'), - antarcticaRothera(value: 'antarctica/rothera'), - antarcticaSyowa(value: 'antarctica/syowa'), - antarcticaTroll(value: 'antarctica/troll'), - antarcticaVostok(value: 'antarctica/vostok'), - arcticLongyearbyen(value: 'arctic/longyearbyen'), - asiaAden(value: 'asia/aden'), - asiaAlmaty(value: 'asia/almaty'), - asiaAmman(value: 'asia/amman'), - asiaAnadyr(value: 'asia/anadyr'), - asiaAqtau(value: 'asia/aqtau'), - asiaAqtobe(value: 'asia/aqtobe'), - asiaAshgabat(value: 'asia/ashgabat'), - asiaAtyrau(value: 'asia/atyrau'), - asiaBaghdad(value: 'asia/baghdad'), - asiaBahrain(value: 'asia/bahrain'), - asiaBaku(value: 'asia/baku'), - asiaBangkok(value: 'asia/bangkok'), - asiaBarnaul(value: 'asia/barnaul'), - asiaBeirut(value: 'asia/beirut'), - asiaBishkek(value: 'asia/bishkek'), - asiaBrunei(value: 'asia/brunei'), - asiaChita(value: 'asia/chita'), - asiaColombo(value: 'asia/colombo'), - asiaDamascus(value: 'asia/damascus'), - asiaDhaka(value: 'asia/dhaka'), - asiaDili(value: 'asia/dili'), - asiaDubai(value: 'asia/dubai'), - asiaDushanbe(value: 'asia/dushanbe'), - asiaFamagusta(value: 'asia/famagusta'), - asiaGaza(value: 'asia/gaza'), - asiaHebron(value: 'asia/hebron'), - asiaHoChiMinh(value: 'asia/ho_chi_minh'), - asiaHongKong(value: 'asia/hong_kong'), - asiaHovd(value: 'asia/hovd'), - asiaIrkutsk(value: 'asia/irkutsk'), - asiaJakarta(value: 'asia/jakarta'), - asiaJayapura(value: 'asia/jayapura'), - asiaJerusalem(value: 'asia/jerusalem'), - asiaKabul(value: 'asia/kabul'), - asiaKamchatka(value: 'asia/kamchatka'), - asiaKarachi(value: 'asia/karachi'), - asiaKathmandu(value: 'asia/kathmandu'), - asiaKhandyga(value: 'asia/khandyga'), - asiaKolkata(value: 'asia/kolkata'), - asiaKrasnoyarsk(value: 'asia/krasnoyarsk'), - asiaKualaLumpur(value: 'asia/kuala_lumpur'), - asiaKuching(value: 'asia/kuching'), - asiaKuwait(value: 'asia/kuwait'), - asiaMacau(value: 'asia/macau'), - asiaMagadan(value: 'asia/magadan'), - asiaMakassar(value: 'asia/makassar'), - asiaManila(value: 'asia/manila'), - asiaMuscat(value: 'asia/muscat'), - asiaNicosia(value: 'asia/nicosia'), - asiaNovokuznetsk(value: 'asia/novokuznetsk'), - asiaNovosibirsk(value: 'asia/novosibirsk'), - asiaOmsk(value: 'asia/omsk'), - asiaOral(value: 'asia/oral'), - asiaPhnomPenh(value: 'asia/phnom_penh'), - asiaPontianak(value: 'asia/pontianak'), - asiaPyongyang(value: 'asia/pyongyang'), - asiaQatar(value: 'asia/qatar'), - asiaQostanay(value: 'asia/qostanay'), - asiaQyzylorda(value: 'asia/qyzylorda'), - asiaRiyadh(value: 'asia/riyadh'), - asiaSakhalin(value: 'asia/sakhalin'), - asiaSamarkand(value: 'asia/samarkand'), - asiaSeoul(value: 'asia/seoul'), - asiaShanghai(value: 'asia/shanghai'), - asiaSingapore(value: 'asia/singapore'), - asiaSrednekolymsk(value: 'asia/srednekolymsk'), - asiaTaipei(value: 'asia/taipei'), - asiaTashkent(value: 'asia/tashkent'), - asiaTbilisi(value: 'asia/tbilisi'), - asiaTehran(value: 'asia/tehran'), - asiaThimphu(value: 'asia/thimphu'), - asiaTokyo(value: 'asia/tokyo'), - asiaTomsk(value: 'asia/tomsk'), - asiaUlaanbaatar(value: 'asia/ulaanbaatar'), - asiaUrumqi(value: 'asia/urumqi'), - asiaUstNera(value: 'asia/ust-nera'), - asiaVientiane(value: 'asia/vientiane'), - asiaVladivostok(value: 'asia/vladivostok'), - asiaYakutsk(value: 'asia/yakutsk'), - asiaYangon(value: 'asia/yangon'), - asiaYekaterinburg(value: 'asia/yekaterinburg'), - asiaYerevan(value: 'asia/yerevan'), - atlanticAzores(value: 'atlantic/azores'), - atlanticBermuda(value: 'atlantic/bermuda'), - atlanticCanary(value: 'atlantic/canary'), - atlanticCapeVerde(value: 'atlantic/cape_verde'), - atlanticFaroe(value: 'atlantic/faroe'), - atlanticMadeira(value: 'atlantic/madeira'), - atlanticReykjavik(value: 'atlantic/reykjavik'), - atlanticSouthGeorgia(value: 'atlantic/south_georgia'), - atlanticStHelena(value: 'atlantic/st_helena'), - atlanticStanley(value: 'atlantic/stanley'), - australiaAdelaide(value: 'australia/adelaide'), - australiaBrisbane(value: 'australia/brisbane'), - australiaBrokenHill(value: 'australia/broken_hill'), - australiaDarwin(value: 'australia/darwin'), - australiaEucla(value: 'australia/eucla'), - australiaHobart(value: 'australia/hobart'), - australiaLindeman(value: 'australia/lindeman'), - australiaLordHowe(value: 'australia/lord_howe'), - australiaMelbourne(value: 'australia/melbourne'), - australiaPerth(value: 'australia/perth'), - australiaSydney(value: 'australia/sydney'), - europeAmsterdam(value: 'europe/amsterdam'), - europeAndorra(value: 'europe/andorra'), - europeAstrakhan(value: 'europe/astrakhan'), - europeAthens(value: 'europe/athens'), - europeBelgrade(value: 'europe/belgrade'), - europeBerlin(value: 'europe/berlin'), - europeBratislava(value: 'europe/bratislava'), - europeBrussels(value: 'europe/brussels'), - europeBucharest(value: 'europe/bucharest'), - europeBudapest(value: 'europe/budapest'), - europeBusingen(value: 'europe/busingen'), - europeChisinau(value: 'europe/chisinau'), - europeCopenhagen(value: 'europe/copenhagen'), - europeDublin(value: 'europe/dublin'), - europeGibraltar(value: 'europe/gibraltar'), - europeGuernsey(value: 'europe/guernsey'), - europeHelsinki(value: 'europe/helsinki'), - europeIsleOfMan(value: 'europe/isle_of_man'), - europeIstanbul(value: 'europe/istanbul'), - europeJersey(value: 'europe/jersey'), - europeKaliningrad(value: 'europe/kaliningrad'), - europeKirov(value: 'europe/kirov'), - europeKyiv(value: 'europe/kyiv'), - europeLisbon(value: 'europe/lisbon'), - europeLjubljana(value: 'europe/ljubljana'), - europeLondon(value: 'europe/london'), - europeLuxembourg(value: 'europe/luxembourg'), - europeMadrid(value: 'europe/madrid'), - europeMalta(value: 'europe/malta'), - europeMariehamn(value: 'europe/mariehamn'), - europeMinsk(value: 'europe/minsk'), - europeMonaco(value: 'europe/monaco'), - europeMoscow(value: 'europe/moscow'), - europeOslo(value: 'europe/oslo'), - europeParis(value: 'europe/paris'), - europePodgorica(value: 'europe/podgorica'), - europePrague(value: 'europe/prague'), - europeRiga(value: 'europe/riga'), - europeRome(value: 'europe/rome'), - europeSamara(value: 'europe/samara'), - europeSanMarino(value: 'europe/san_marino'), - europeSarajevo(value: 'europe/sarajevo'), - europeSaratov(value: 'europe/saratov'), - europeSimferopol(value: 'europe/simferopol'), - europeSkopje(value: 'europe/skopje'), - europeSofia(value: 'europe/sofia'), - europeStockholm(value: 'europe/stockholm'), - europeTallinn(value: 'europe/tallinn'), - europeTirane(value: 'europe/tirane'), - europeUlyanovsk(value: 'europe/ulyanovsk'), - europeVaduz(value: 'europe/vaduz'), - europeVatican(value: 'europe/vatican'), - europeVienna(value: 'europe/vienna'), - europeVilnius(value: 'europe/vilnius'), - europeVolgograd(value: 'europe/volgograd'), - europeWarsaw(value: 'europe/warsaw'), - europeZagreb(value: 'europe/zagreb'), - europeZurich(value: 'europe/zurich'), - indianAntananarivo(value: 'indian/antananarivo'), - indianChagos(value: 'indian/chagos'), - indianChristmas(value: 'indian/christmas'), - indianCocos(value: 'indian/cocos'), - indianComoro(value: 'indian/comoro'), - indianKerguelen(value: 'indian/kerguelen'), - indianMahe(value: 'indian/mahe'), - indianMaldives(value: 'indian/maldives'), - indianMauritius(value: 'indian/mauritius'), - indianMayotte(value: 'indian/mayotte'), - indianReunion(value: 'indian/reunion'), - pacificApia(value: 'pacific/apia'), - pacificAuckland(value: 'pacific/auckland'), - pacificBougainville(value: 'pacific/bougainville'), - pacificChatham(value: 'pacific/chatham'), - pacificChuuk(value: 'pacific/chuuk'), - pacificEaster(value: 'pacific/easter'), - pacificEfate(value: 'pacific/efate'), - pacificFakaofo(value: 'pacific/fakaofo'), - pacificFiji(value: 'pacific/fiji'), - pacificFunafuti(value: 'pacific/funafuti'), - pacificGalapagos(value: 'pacific/galapagos'), - pacificGambier(value: 'pacific/gambier'), - pacificGuadalcanal(value: 'pacific/guadalcanal'), - pacificGuam(value: 'pacific/guam'), - pacificHonolulu(value: 'pacific/honolulu'), - pacificKanton(value: 'pacific/kanton'), - pacificKiritimati(value: 'pacific/kiritimati'), - pacificKosrae(value: 'pacific/kosrae'), - pacificKwajalein(value: 'pacific/kwajalein'), - pacificMajuro(value: 'pacific/majuro'), - pacificMarquesas(value: 'pacific/marquesas'), - pacificMidway(value: 'pacific/midway'), - pacificNauru(value: 'pacific/nauru'), - pacificNiue(value: 'pacific/niue'), - pacificNorfolk(value: 'pacific/norfolk'), - pacificNoumea(value: 'pacific/noumea'), - pacificPagoPago(value: 'pacific/pago_pago'), - pacificPalau(value: 'pacific/palau'), - pacificPitcairn(value: 'pacific/pitcairn'), - pacificPohnpei(value: 'pacific/pohnpei'), - pacificPortMoresby(value: 'pacific/port_moresby'), - pacificRarotonga(value: 'pacific/rarotonga'), - pacificSaipan(value: 'pacific/saipan'), - pacificTahiti(value: 'pacific/tahiti'), - pacificTarawa(value: 'pacific/tarawa'), - pacificTongatapu(value: 'pacific/tongatapu'), - pacificWake(value: 'pacific/wake'), - pacificWallis(value: 'pacific/wallis'), - utc(value: 'utc'); + africaAbidjan(value: "africa/abidjan"), + africaAccra(value: "africa/accra"), + africaAddisAbaba(value: "africa/addis_ababa"), + africaAlgiers(value: "africa/algiers"), + africaAsmara(value: "africa/asmara"), + africaBamako(value: "africa/bamako"), + africaBangui(value: "africa/bangui"), + africaBanjul(value: "africa/banjul"), + africaBissau(value: "africa/bissau"), + africaBlantyre(value: "africa/blantyre"), + africaBrazzaville(value: "africa/brazzaville"), + africaBujumbura(value: "africa/bujumbura"), + africaCairo(value: "africa/cairo"), + africaCasablanca(value: "africa/casablanca"), + africaCeuta(value: "africa/ceuta"), + africaConakry(value: "africa/conakry"), + africaDakar(value: "africa/dakar"), + africaDarEsSalaam(value: "africa/dar_es_salaam"), + africaDjibouti(value: "africa/djibouti"), + africaDouala(value: "africa/douala"), + africaElAaiun(value: "africa/el_aaiun"), + africaFreetown(value: "africa/freetown"), + africaGaborone(value: "africa/gaborone"), + africaHarare(value: "africa/harare"), + africaJohannesburg(value: "africa/johannesburg"), + africaJuba(value: "africa/juba"), + africaKampala(value: "africa/kampala"), + africaKhartoum(value: "africa/khartoum"), + africaKigali(value: "africa/kigali"), + africaKinshasa(value: "africa/kinshasa"), + africaLagos(value: "africa/lagos"), + africaLibreville(value: "africa/libreville"), + africaLome(value: "africa/lome"), + africaLuanda(value: "africa/luanda"), + africaLubumbashi(value: "africa/lubumbashi"), + africaLusaka(value: "africa/lusaka"), + africaMalabo(value: "africa/malabo"), + africaMaputo(value: "africa/maputo"), + africaMaseru(value: "africa/maseru"), + africaMbabane(value: "africa/mbabane"), + africaMogadishu(value: "africa/mogadishu"), + africaMonrovia(value: "africa/monrovia"), + africaNairobi(value: "africa/nairobi"), + africaNdjamena(value: "africa/ndjamena"), + africaNiamey(value: "africa/niamey"), + africaNouakchott(value: "africa/nouakchott"), + africaOuagadougou(value: "africa/ouagadougou"), + africaPortoNovo(value: "africa/porto-novo"), + africaSaoTome(value: "africa/sao_tome"), + africaTripoli(value: "africa/tripoli"), + africaTunis(value: "africa/tunis"), + africaWindhoek(value: "africa/windhoek"), + americaAdak(value: "america/adak"), + americaAnchorage(value: "america/anchorage"), + americaAnguilla(value: "america/anguilla"), + americaAntigua(value: "america/antigua"), + americaAraguaina(value: "america/araguaina"), + americaArgentinaBuenosAires(value: "america/argentina/buenos_aires"), + americaArgentinaCatamarca(value: "america/argentina/catamarca"), + americaArgentinaCordoba(value: "america/argentina/cordoba"), + americaArgentinaJujuy(value: "america/argentina/jujuy"), + americaArgentinaLaRioja(value: "america/argentina/la_rioja"), + americaArgentinaMendoza(value: "america/argentina/mendoza"), + americaArgentinaRioGallegos(value: "america/argentina/rio_gallegos"), + americaArgentinaSalta(value: "america/argentina/salta"), + americaArgentinaSanJuan(value: "america/argentina/san_juan"), + americaArgentinaSanLuis(value: "america/argentina/san_luis"), + americaArgentinaTucuman(value: "america/argentina/tucuman"), + americaArgentinaUshuaia(value: "america/argentina/ushuaia"), + americaAruba(value: "america/aruba"), + americaAsuncion(value: "america/asuncion"), + americaAtikokan(value: "america/atikokan"), + americaBahia(value: "america/bahia"), + americaBahiaBanderas(value: "america/bahia_banderas"), + americaBarbados(value: "america/barbados"), + americaBelem(value: "america/belem"), + americaBelize(value: "america/belize"), + americaBlancSablon(value: "america/blanc-sablon"), + americaBoaVista(value: "america/boa_vista"), + americaBogota(value: "america/bogota"), + americaBoise(value: "america/boise"), + americaCambridgeBay(value: "america/cambridge_bay"), + americaCampoGrande(value: "america/campo_grande"), + americaCancun(value: "america/cancun"), + americaCaracas(value: "america/caracas"), + americaCayenne(value: "america/cayenne"), + americaCayman(value: "america/cayman"), + americaChicago(value: "america/chicago"), + americaChihuahua(value: "america/chihuahua"), + americaCiudadJuarez(value: "america/ciudad_juarez"), + americaCostaRica(value: "america/costa_rica"), + americaCoyhaique(value: "america/coyhaique"), + americaCreston(value: "america/creston"), + americaCuiaba(value: "america/cuiaba"), + americaCuracao(value: "america/curacao"), + americaDanmarkshavn(value: "america/danmarkshavn"), + americaDawson(value: "america/dawson"), + americaDawsonCreek(value: "america/dawson_creek"), + americaDenver(value: "america/denver"), + americaDetroit(value: "america/detroit"), + americaDominica(value: "america/dominica"), + americaEdmonton(value: "america/edmonton"), + americaEirunepe(value: "america/eirunepe"), + americaElSalvador(value: "america/el_salvador"), + americaFortNelson(value: "america/fort_nelson"), + americaFortaleza(value: "america/fortaleza"), + americaGlaceBay(value: "america/glace_bay"), + americaGooseBay(value: "america/goose_bay"), + americaGrandTurk(value: "america/grand_turk"), + americaGrenada(value: "america/grenada"), + americaGuadeloupe(value: "america/guadeloupe"), + americaGuatemala(value: "america/guatemala"), + americaGuayaquil(value: "america/guayaquil"), + americaGuyana(value: "america/guyana"), + americaHalifax(value: "america/halifax"), + americaHavana(value: "america/havana"), + americaHermosillo(value: "america/hermosillo"), + americaIndianaIndianapolis(value: "america/indiana/indianapolis"), + americaIndianaKnox(value: "america/indiana/knox"), + americaIndianaMarengo(value: "america/indiana/marengo"), + americaIndianaPetersburg(value: "america/indiana/petersburg"), + americaIndianaTellCity(value: "america/indiana/tell_city"), + americaIndianaVevay(value: "america/indiana/vevay"), + americaIndianaVincennes(value: "america/indiana/vincennes"), + americaIndianaWinamac(value: "america/indiana/winamac"), + americaInuvik(value: "america/inuvik"), + americaIqaluit(value: "america/iqaluit"), + americaJamaica(value: "america/jamaica"), + americaJuneau(value: "america/juneau"), + americaKentuckyLouisville(value: "america/kentucky/louisville"), + americaKentuckyMonticello(value: "america/kentucky/monticello"), + americaKralendijk(value: "america/kralendijk"), + americaLaPaz(value: "america/la_paz"), + americaLima(value: "america/lima"), + americaLosAngeles(value: "america/los_angeles"), + americaLowerPrinces(value: "america/lower_princes"), + americaMaceio(value: "america/maceio"), + americaManagua(value: "america/managua"), + americaManaus(value: "america/manaus"), + americaMarigot(value: "america/marigot"), + americaMartinique(value: "america/martinique"), + americaMatamoros(value: "america/matamoros"), + americaMazatlan(value: "america/mazatlan"), + americaMenominee(value: "america/menominee"), + americaMerida(value: "america/merida"), + americaMetlakatla(value: "america/metlakatla"), + americaMexicoCity(value: "america/mexico_city"), + americaMiquelon(value: "america/miquelon"), + americaMoncton(value: "america/moncton"), + americaMonterrey(value: "america/monterrey"), + americaMontevideo(value: "america/montevideo"), + americaMontserrat(value: "america/montserrat"), + americaNassau(value: "america/nassau"), + americaNewYork(value: "america/new_york"), + americaNome(value: "america/nome"), + americaNoronha(value: "america/noronha"), + americaNorthDakotaBeulah(value: "america/north_dakota/beulah"), + americaNorthDakotaCenter(value: "america/north_dakota/center"), + americaNorthDakotaNewSalem(value: "america/north_dakota/new_salem"), + americaNuuk(value: "america/nuuk"), + americaOjinaga(value: "america/ojinaga"), + americaPanama(value: "america/panama"), + americaParamaribo(value: "america/paramaribo"), + americaPhoenix(value: "america/phoenix"), + americaPortAuPrince(value: "america/port-au-prince"), + americaPortOfSpain(value: "america/port_of_spain"), + americaPortoVelho(value: "america/porto_velho"), + americaPuertoRico(value: "america/puerto_rico"), + americaPuntaArenas(value: "america/punta_arenas"), + americaRankinInlet(value: "america/rankin_inlet"), + americaRecife(value: "america/recife"), + americaRegina(value: "america/regina"), + americaResolute(value: "america/resolute"), + americaRioBranco(value: "america/rio_branco"), + americaSantarem(value: "america/santarem"), + americaSantiago(value: "america/santiago"), + americaSantoDomingo(value: "america/santo_domingo"), + americaSaoPaulo(value: "america/sao_paulo"), + americaScoresbysund(value: "america/scoresbysund"), + americaSitka(value: "america/sitka"), + americaStBarthelemy(value: "america/st_barthelemy"), + americaStJohns(value: "america/st_johns"), + americaStKitts(value: "america/st_kitts"), + americaStLucia(value: "america/st_lucia"), + americaStThomas(value: "america/st_thomas"), + americaStVincent(value: "america/st_vincent"), + americaSwiftCurrent(value: "america/swift_current"), + americaTegucigalpa(value: "america/tegucigalpa"), + americaThule(value: "america/thule"), + americaTijuana(value: "america/tijuana"), + americaToronto(value: "america/toronto"), + americaTortola(value: "america/tortola"), + americaVancouver(value: "america/vancouver"), + americaWhitehorse(value: "america/whitehorse"), + americaWinnipeg(value: "america/winnipeg"), + americaYakutat(value: "america/yakutat"), + antarcticaCasey(value: "antarctica/casey"), + antarcticaDavis(value: "antarctica/davis"), + antarcticaDumontdurville(value: "antarctica/dumontdurville"), + antarcticaMacquarie(value: "antarctica/macquarie"), + antarcticaMawson(value: "antarctica/mawson"), + antarcticaMcmurdo(value: "antarctica/mcmurdo"), + antarcticaPalmer(value: "antarctica/palmer"), + antarcticaRothera(value: "antarctica/rothera"), + antarcticaSyowa(value: "antarctica/syowa"), + antarcticaTroll(value: "antarctica/troll"), + antarcticaVostok(value: "antarctica/vostok"), + arcticLongyearbyen(value: "arctic/longyearbyen"), + asiaAden(value: "asia/aden"), + asiaAlmaty(value: "asia/almaty"), + asiaAmman(value: "asia/amman"), + asiaAnadyr(value: "asia/anadyr"), + asiaAqtau(value: "asia/aqtau"), + asiaAqtobe(value: "asia/aqtobe"), + asiaAshgabat(value: "asia/ashgabat"), + asiaAtyrau(value: "asia/atyrau"), + asiaBaghdad(value: "asia/baghdad"), + asiaBahrain(value: "asia/bahrain"), + asiaBaku(value: "asia/baku"), + asiaBangkok(value: "asia/bangkok"), + asiaBarnaul(value: "asia/barnaul"), + asiaBeirut(value: "asia/beirut"), + asiaBishkek(value: "asia/bishkek"), + asiaBrunei(value: "asia/brunei"), + asiaChita(value: "asia/chita"), + asiaColombo(value: "asia/colombo"), + asiaDamascus(value: "asia/damascus"), + asiaDhaka(value: "asia/dhaka"), + asiaDili(value: "asia/dili"), + asiaDubai(value: "asia/dubai"), + asiaDushanbe(value: "asia/dushanbe"), + asiaFamagusta(value: "asia/famagusta"), + asiaGaza(value: "asia/gaza"), + asiaHebron(value: "asia/hebron"), + asiaHoChiMinh(value: "asia/ho_chi_minh"), + asiaHongKong(value: "asia/hong_kong"), + asiaHovd(value: "asia/hovd"), + asiaIrkutsk(value: "asia/irkutsk"), + asiaJakarta(value: "asia/jakarta"), + asiaJayapura(value: "asia/jayapura"), + asiaJerusalem(value: "asia/jerusalem"), + asiaKabul(value: "asia/kabul"), + asiaKamchatka(value: "asia/kamchatka"), + asiaKarachi(value: "asia/karachi"), + asiaKathmandu(value: "asia/kathmandu"), + asiaKhandyga(value: "asia/khandyga"), + asiaKolkata(value: "asia/kolkata"), + asiaKrasnoyarsk(value: "asia/krasnoyarsk"), + asiaKualaLumpur(value: "asia/kuala_lumpur"), + asiaKuching(value: "asia/kuching"), + asiaKuwait(value: "asia/kuwait"), + asiaMacau(value: "asia/macau"), + asiaMagadan(value: "asia/magadan"), + asiaMakassar(value: "asia/makassar"), + asiaManila(value: "asia/manila"), + asiaMuscat(value: "asia/muscat"), + asiaNicosia(value: "asia/nicosia"), + asiaNovokuznetsk(value: "asia/novokuznetsk"), + asiaNovosibirsk(value: "asia/novosibirsk"), + asiaOmsk(value: "asia/omsk"), + asiaOral(value: "asia/oral"), + asiaPhnomPenh(value: "asia/phnom_penh"), + asiaPontianak(value: "asia/pontianak"), + asiaPyongyang(value: "asia/pyongyang"), + asiaQatar(value: "asia/qatar"), + asiaQostanay(value: "asia/qostanay"), + asiaQyzylorda(value: "asia/qyzylorda"), + asiaRiyadh(value: "asia/riyadh"), + asiaSakhalin(value: "asia/sakhalin"), + asiaSamarkand(value: "asia/samarkand"), + asiaSeoul(value: "asia/seoul"), + asiaShanghai(value: "asia/shanghai"), + asiaSingapore(value: "asia/singapore"), + asiaSrednekolymsk(value: "asia/srednekolymsk"), + asiaTaipei(value: "asia/taipei"), + asiaTashkent(value: "asia/tashkent"), + asiaTbilisi(value: "asia/tbilisi"), + asiaTehran(value: "asia/tehran"), + asiaThimphu(value: "asia/thimphu"), + asiaTokyo(value: "asia/tokyo"), + asiaTomsk(value: "asia/tomsk"), + asiaUlaanbaatar(value: "asia/ulaanbaatar"), + asiaUrumqi(value: "asia/urumqi"), + asiaUstNera(value: "asia/ust-nera"), + asiaVientiane(value: "asia/vientiane"), + asiaVladivostok(value: "asia/vladivostok"), + asiaYakutsk(value: "asia/yakutsk"), + asiaYangon(value: "asia/yangon"), + asiaYekaterinburg(value: "asia/yekaterinburg"), + asiaYerevan(value: "asia/yerevan"), + atlanticAzores(value: "atlantic/azores"), + atlanticBermuda(value: "atlantic/bermuda"), + atlanticCanary(value: "atlantic/canary"), + atlanticCapeVerde(value: "atlantic/cape_verde"), + atlanticFaroe(value: "atlantic/faroe"), + atlanticMadeira(value: "atlantic/madeira"), + atlanticReykjavik(value: "atlantic/reykjavik"), + atlanticSouthGeorgia(value: "atlantic/south_georgia"), + atlanticStHelena(value: "atlantic/st_helena"), + atlanticStanley(value: "atlantic/stanley"), + australiaAdelaide(value: "australia/adelaide"), + australiaBrisbane(value: "australia/brisbane"), + australiaBrokenHill(value: "australia/broken_hill"), + australiaDarwin(value: "australia/darwin"), + australiaEucla(value: "australia/eucla"), + australiaHobart(value: "australia/hobart"), + australiaLindeman(value: "australia/lindeman"), + australiaLordHowe(value: "australia/lord_howe"), + australiaMelbourne(value: "australia/melbourne"), + australiaPerth(value: "australia/perth"), + australiaSydney(value: "australia/sydney"), + europeAmsterdam(value: "europe/amsterdam"), + europeAndorra(value: "europe/andorra"), + europeAstrakhan(value: "europe/astrakhan"), + europeAthens(value: "europe/athens"), + europeBelgrade(value: "europe/belgrade"), + europeBerlin(value: "europe/berlin"), + europeBratislava(value: "europe/bratislava"), + europeBrussels(value: "europe/brussels"), + europeBucharest(value: "europe/bucharest"), + europeBudapest(value: "europe/budapest"), + europeBusingen(value: "europe/busingen"), + europeChisinau(value: "europe/chisinau"), + europeCopenhagen(value: "europe/copenhagen"), + europeDublin(value: "europe/dublin"), + europeGibraltar(value: "europe/gibraltar"), + europeGuernsey(value: "europe/guernsey"), + europeHelsinki(value: "europe/helsinki"), + europeIsleOfMan(value: "europe/isle_of_man"), + europeIstanbul(value: "europe/istanbul"), + europeJersey(value: "europe/jersey"), + europeKaliningrad(value: "europe/kaliningrad"), + europeKirov(value: "europe/kirov"), + europeKyiv(value: "europe/kyiv"), + europeLisbon(value: "europe/lisbon"), + europeLjubljana(value: "europe/ljubljana"), + europeLondon(value: "europe/london"), + europeLuxembourg(value: "europe/luxembourg"), + europeMadrid(value: "europe/madrid"), + europeMalta(value: "europe/malta"), + europeMariehamn(value: "europe/mariehamn"), + europeMinsk(value: "europe/minsk"), + europeMonaco(value: "europe/monaco"), + europeMoscow(value: "europe/moscow"), + europeOslo(value: "europe/oslo"), + europeParis(value: "europe/paris"), + europePodgorica(value: "europe/podgorica"), + europePrague(value: "europe/prague"), + europeRiga(value: "europe/riga"), + europeRome(value: "europe/rome"), + europeSamara(value: "europe/samara"), + europeSanMarino(value: "europe/san_marino"), + europeSarajevo(value: "europe/sarajevo"), + europeSaratov(value: "europe/saratov"), + europeSimferopol(value: "europe/simferopol"), + europeSkopje(value: "europe/skopje"), + europeSofia(value: "europe/sofia"), + europeStockholm(value: "europe/stockholm"), + europeTallinn(value: "europe/tallinn"), + europeTirane(value: "europe/tirane"), + europeUlyanovsk(value: "europe/ulyanovsk"), + europeVaduz(value: "europe/vaduz"), + europeVatican(value: "europe/vatican"), + europeVienna(value: "europe/vienna"), + europeVilnius(value: "europe/vilnius"), + europeVolgograd(value: "europe/volgograd"), + europeWarsaw(value: "europe/warsaw"), + europeZagreb(value: "europe/zagreb"), + europeZurich(value: "europe/zurich"), + indianAntananarivo(value: "indian/antananarivo"), + indianChagos(value: "indian/chagos"), + indianChristmas(value: "indian/christmas"), + indianCocos(value: "indian/cocos"), + indianComoro(value: "indian/comoro"), + indianKerguelen(value: "indian/kerguelen"), + indianMahe(value: "indian/mahe"), + indianMaldives(value: "indian/maldives"), + indianMauritius(value: "indian/mauritius"), + indianMayotte(value: "indian/mayotte"), + indianReunion(value: "indian/reunion"), + pacificApia(value: "pacific/apia"), + pacificAuckland(value: "pacific/auckland"), + pacificBougainville(value: "pacific/bougainville"), + pacificChatham(value: "pacific/chatham"), + pacificChuuk(value: "pacific/chuuk"), + pacificEaster(value: "pacific/easter"), + pacificEfate(value: "pacific/efate"), + pacificFakaofo(value: "pacific/fakaofo"), + pacificFiji(value: "pacific/fiji"), + pacificFunafuti(value: "pacific/funafuti"), + pacificGalapagos(value: "pacific/galapagos"), + pacificGambier(value: "pacific/gambier"), + pacificGuadalcanal(value: "pacific/guadalcanal"), + pacificGuam(value: "pacific/guam"), + pacificHonolulu(value: "pacific/honolulu"), + pacificKanton(value: "pacific/kanton"), + pacificKiritimati(value: "pacific/kiritimati"), + pacificKosrae(value: "pacific/kosrae"), + pacificKwajalein(value: "pacific/kwajalein"), + pacificMajuro(value: "pacific/majuro"), + pacificMarquesas(value: "pacific/marquesas"), + pacificMidway(value: "pacific/midway"), + pacificNauru(value: "pacific/nauru"), + pacificNiue(value: "pacific/niue"), + pacificNorfolk(value: "pacific/norfolk"), + pacificNoumea(value: "pacific/noumea"), + pacificPagoPago(value: "pacific/pago_pago"), + pacificPalau(value: "pacific/palau"), + pacificPitcairn(value: "pacific/pitcairn"), + pacificPohnpei(value: "pacific/pohnpei"), + pacificPortMoresby(value: "pacific/port_moresby"), + pacificRarotonga(value: "pacific/rarotonga"), + pacificSaipan(value: "pacific/saipan"), + pacificTahiti(value: "pacific/tahiti"), + pacificTarawa(value: "pacific/tarawa"), + pacificTongatapu(value: "pacific/tongatapu"), + pacificWake(value: "pacific/wake"), + pacificWallis(value: "pacific/wallis"), + utc(value: "utc"); const Timezone({required this.value}); diff --git a/lib/src/models/algo_argon2.dart b/lib/src/models/algo_argon2.dart index 344a8770..e1274375 100644 --- a/lib/src/models/algo_argon2.dart +++ b/lib/src/models/algo_argon2.dart @@ -20,8 +20,9 @@ class AlgoArgon2 implements Model { required this.timeCost, required this.threads, }); - - factory AlgoArgon2.fromMap(Map map) { + factory AlgoArgon2.fromMap( + Map map, + ) { return AlgoArgon2( type: map['type'].toString(), memoryCost: map['memoryCost'], diff --git a/lib/src/models/algo_bcrypt.dart b/lib/src/models/algo_bcrypt.dart index 9909265e..27992237 100644 --- a/lib/src/models/algo_bcrypt.dart +++ b/lib/src/models/algo_bcrypt.dart @@ -8,8 +8,9 @@ class AlgoBcrypt implements Model { AlgoBcrypt({ required this.type, }); - - factory AlgoBcrypt.fromMap(Map map) { + factory AlgoBcrypt.fromMap( + Map map, + ) { return AlgoBcrypt( type: map['type'].toString(), ); diff --git a/lib/src/models/algo_md5.dart b/lib/src/models/algo_md5.dart index 746fbd52..de131b77 100644 --- a/lib/src/models/algo_md5.dart +++ b/lib/src/models/algo_md5.dart @@ -8,8 +8,9 @@ class AlgoMd5 implements Model { AlgoMd5({ required this.type, }); - - factory AlgoMd5.fromMap(Map map) { + factory AlgoMd5.fromMap( + Map map, + ) { return AlgoMd5( type: map['type'].toString(), ); diff --git a/lib/src/models/algo_phpass.dart b/lib/src/models/algo_phpass.dart index cab45e49..f189e140 100644 --- a/lib/src/models/algo_phpass.dart +++ b/lib/src/models/algo_phpass.dart @@ -8,8 +8,9 @@ class AlgoPhpass implements Model { AlgoPhpass({ required this.type, }); - - factory AlgoPhpass.fromMap(Map map) { + factory AlgoPhpass.fromMap( + Map map, + ) { return AlgoPhpass( type: map['type'].toString(), ); diff --git a/lib/src/models/algo_scrypt.dart b/lib/src/models/algo_scrypt.dart index a1648843..b62a31f6 100644 --- a/lib/src/models/algo_scrypt.dart +++ b/lib/src/models/algo_scrypt.dart @@ -24,8 +24,9 @@ class AlgoScrypt implements Model { required this.costParallel, required this.length, }); - - factory AlgoScrypt.fromMap(Map map) { + factory AlgoScrypt.fromMap( + Map map, + ) { return AlgoScrypt( type: map['type'].toString(), costCpu: map['costCpu'], diff --git a/lib/src/models/algo_scrypt_modified.dart b/lib/src/models/algo_scrypt_modified.dart index 33ef4a6f..0fa9ae47 100644 --- a/lib/src/models/algo_scrypt_modified.dart +++ b/lib/src/models/algo_scrypt_modified.dart @@ -20,8 +20,9 @@ class AlgoScryptModified implements Model { required this.saltSeparator, required this.signerKey, }); - - factory AlgoScryptModified.fromMap(Map map) { + factory AlgoScryptModified.fromMap( + Map map, + ) { return AlgoScryptModified( type: map['type'].toString(), salt: map['salt'].toString(), diff --git a/lib/src/models/algo_sha.dart b/lib/src/models/algo_sha.dart index 4984df75..b1cb54cc 100644 --- a/lib/src/models/algo_sha.dart +++ b/lib/src/models/algo_sha.dart @@ -8,8 +8,9 @@ class AlgoSha implements Model { AlgoSha({ required this.type, }); - - factory AlgoSha.fromMap(Map map) { + factory AlgoSha.fromMap( + Map map, + ) { return AlgoSha( type: map['type'].toString(), ); diff --git a/lib/src/models/app_installation.dart b/lib/src/models/app_installation.dart index 3ed121ec..47c742ab 100644 --- a/lib/src/models/app_installation.dart +++ b/lib/src/models/app_installation.dart @@ -21,7 +21,7 @@ class AppInstallation implements Model { final List scopes; /// Authorization details granted to the application. Rich authorization request (RFC 9396) style entries; the Appwrite Console stores authorized project IDs here. - final Map authorizationDetails; + final List authorizationDetails; /// ID of the user who created the installation. final String createdById; @@ -44,8 +44,9 @@ class AppInstallation implements Model { required this.createdByName, this.lastAccessedAt, }); - - factory AppInstallation.fromMap(Map map) { + factory AppInstallation.fromMap( + Map map, + ) { return AppInstallation( $id: map['\$id'].toString(), $createdAt: map['\$createdAt'].toString(), @@ -53,7 +54,7 @@ class AppInstallation implements Model { appId: map['appId'].toString(), teamId: map['teamId'].toString(), scopes: List.from(map['scopes'] ?? []), - authorizationDetails: map['authorizationDetails'], + authorizationDetails: List.from(map['authorizationDetails'] ?? []), createdById: map['createdById'].toString(), createdByName: map['createdByName'].toString(), lastAccessedAt: map['lastAccessedAt']?.toString(), diff --git a/lib/src/models/app_installation_list.dart b/lib/src/models/app_installation_list.dart index c55f831f..2902bf06 100644 --- a/lib/src/models/app_installation_list.dart +++ b/lib/src/models/app_installation_list.dart @@ -12,12 +12,14 @@ class AppInstallationList implements Model { required this.total, required this.installations, }); - - factory AppInstallationList.fromMap(Map map) { + factory AppInstallationList.fromMap( + Map map, + ) { return AppInstallationList( total: map['total'], installations: List.from( - map['installations'].map((p) => AppInstallation.fromMap(p))), + map['installations'].map((p) => AppInstallation.fromMap(p)), + ), ); } diff --git a/lib/src/models/continent.dart b/lib/src/models/continent.dart index ec3c41be..5696d1aa 100644 --- a/lib/src/models/continent.dart +++ b/lib/src/models/continent.dart @@ -12,8 +12,9 @@ class Continent implements Model { required this.name, required this.code, }); - - factory Continent.fromMap(Map map) { + factory Continent.fromMap( + Map map, + ) { return Continent( name: map['name'].toString(), code: map['code'].toString(), diff --git a/lib/src/models/continent_list.dart b/lib/src/models/continent_list.dart index df28f04b..ca2cbcfe 100644 --- a/lib/src/models/continent_list.dart +++ b/lib/src/models/continent_list.dart @@ -12,12 +12,14 @@ class ContinentList implements Model { required this.total, required this.continents, }); - - factory ContinentList.fromMap(Map map) { + 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 3bcbb76d..5a2aaa1a 100644 --- a/lib/src/models/country.dart +++ b/lib/src/models/country.dart @@ -12,8 +12,9 @@ class Country implements Model { required this.name, required this.code, }); - - factory Country.fromMap(Map map) { + factory Country.fromMap( + Map map, + ) { return Country( name: map['name'].toString(), code: map['code'].toString(), diff --git a/lib/src/models/country_list.dart b/lib/src/models/country_list.dart index 79cb1256..9c1b4f7b 100644 --- a/lib/src/models/country_list.dart +++ b/lib/src/models/country_list.dart @@ -12,12 +12,14 @@ class CountryList implements Model { required this.total, required this.countries, }); - - factory CountryList.fromMap(Map map) { + 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.dart b/lib/src/models/currency.dart index f2b18093..1b6362a0 100644 --- a/lib/src/models/currency.dart +++ b/lib/src/models/currency.dart @@ -32,8 +32,9 @@ class Currency implements Model { required this.code, required this.namePlural, }); - - factory Currency.fromMap(Map map) { + factory Currency.fromMap( + Map map, + ) { return Currency( symbol: map['symbol'].toString(), name: map['name'].toString(), diff --git a/lib/src/models/currency_list.dart b/lib/src/models/currency_list.dart index 6c39ae2e..beb1abc1 100644 --- a/lib/src/models/currency_list.dart +++ b/lib/src/models/currency_list.dart @@ -12,12 +12,14 @@ class CurrencyList implements Model { required this.total, required this.currencies, }); - - factory CurrencyList.fromMap(Map map) { + 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.dart b/lib/src/models/document.dart index be08d599..6886acd0 100644 --- a/lib/src/models/document.dart +++ b/lib/src/models/document.dart @@ -35,8 +35,9 @@ class Document implements Model { required this.$permissions, required this.data, }); - - factory Document.fromMap(Map map) { + factory Document.fromMap( + Map map, + ) { return Document( $id: map['\$id'].toString(), $sequence: map['\$sequence'].toString(), diff --git a/lib/src/models/document_list.dart b/lib/src/models/document_list.dart index 76a07309..c9e020a4 100644 --- a/lib/src/models/document_list.dart +++ b/lib/src/models/document_list.dart @@ -12,12 +12,14 @@ class DocumentList implements Model { required this.total, required this.documents, }); - - factory DocumentList.fromMap(Map map) { + 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 3629e1d6..2b07213b 100644 --- a/lib/src/models/execution.dart +++ b/lib/src/models/execution.dart @@ -14,16 +14,19 @@ class Execution implements Model { /// Execution roles. final List $permissions; - /// Function ID. - final String functionId; + /// Function or site ID. + final String resourceId; - /// Function's deployment ID used to create the execution. + /// Execution resource type. + final enums.ExecutionResourceType resourceType; + + /// Deployment ID used to create the execution. final String deploymentId; - /// The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. + /// The trigger that caused the resource to execute. Possible values can be: `http`, `schedule`, or `event`. final enums.ExecutionTrigger trigger; - /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, `failed`, or `scheduled`. + /// The status of the resource execution. Possible values can be: `waiting`, `processing`, `completed`, `failed`, or `scheduled`. final enums.ExecutionStatus status; /// HTTP request method type. @@ -44,10 +47,10 @@ class Execution implements Model { /// HTTP response headers as a key-value object. This will return only whitelisted headers. All headers are returned if execution is created as synchronous. final List responseHeaders; - /// Function logs. Includes the last 4,000 characters. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. + /// Resource logs. Includes the last 4,000 characters. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. final String logs; - /// Function errors. Includes the last 4,000 characters. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. + /// Resource errors. Includes the last 4,000 characters. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. final String errors; /// Resource(function/site) execution duration in seconds. @@ -61,7 +64,8 @@ class Execution implements Model { required this.$createdAt, required this.$updatedAt, required this.$permissions, - required this.functionId, + required this.resourceId, + required this.resourceType, required this.deploymentId, required this.trigger, required this.status, @@ -76,27 +80,35 @@ class Execution implements Model { required this.duration, this.scheduledAt, }); - - factory Execution.fromMap(Map map) { + factory Execution.fromMap( + Map map, + ) { return Execution( $id: map['\$id'].toString(), $createdAt: map['\$createdAt'].toString(), $updatedAt: map['\$updatedAt'].toString(), $permissions: List.from(map['\$permissions'] ?? []), - functionId: map['functionId'].toString(), + resourceId: map['resourceId'].toString(), + resourceType: enums.ExecutionResourceType.values.firstWhere( + (e) => e.value == map['resourceType'], + ), 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(), @@ -111,7 +123,8 @@ class Execution implements Model { "\$createdAt": $createdAt, "\$updatedAt": $updatedAt, "\$permissions": $permissions, - "functionId": functionId, + "resourceId": resourceId, + "resourceType": resourceType.value, "deploymentId": deploymentId, "trigger": trigger.value, "status": status.value, diff --git a/lib/src/models/execution_list.dart b/lib/src/models/execution_list.dart index 63c2ad7e..c1d911ef 100644 --- a/lib/src/models/execution_list.dart +++ b/lib/src/models/execution_list.dart @@ -12,12 +12,14 @@ class ExecutionList implements Model { required this.total, required this.executions, }); - - factory ExecutionList.fromMap(Map map) { + 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.dart b/lib/src/models/file.dart index 91c5e945..393c91a6 100644 --- a/lib/src/models/file.dart +++ b/lib/src/models/file.dart @@ -68,8 +68,9 @@ class File implements Model { required this.encryption, required this.compression, }); - - factory File.fromMap(Map map) { + factory File.fromMap( + Map map, + ) { return File( $id: map['\$id'].toString(), bucketId: map['bucketId'].toString(), diff --git a/lib/src/models/file_list.dart b/lib/src/models/file_list.dart index 1157554a..7df9e94e 100644 --- a/lib/src/models/file_list.dart +++ b/lib/src/models/file_list.dart @@ -12,11 +12,14 @@ class FileList implements Model { required this.total, required this.files, }); - - factory FileList.fromMap(Map map) { + factory FileList.fromMap( + Map map, + ) { return FileList( total: map['total'], - files: List.from(map['files'].map((p) => File.fromMap(p))), + files: List.from( + map['files'].map((p) => File.fromMap(p)), + ), ); } diff --git a/lib/src/models/headers.dart b/lib/src/models/headers.dart index fa054420..4993b177 100644 --- a/lib/src/models/headers.dart +++ b/lib/src/models/headers.dart @@ -12,8 +12,9 @@ class Headers implements Model { required this.name, required this.value, }); - - factory Headers.fromMap(Map map) { + factory Headers.fromMap( + Map map, + ) { return Headers( name: map['name'].toString(), value: map['value'].toString(), diff --git a/lib/src/models/identity.dart b/lib/src/models/identity.dart index cc659043..2f32c7f9 100644 --- a/lib/src/models/identity.dart +++ b/lib/src/models/identity.dart @@ -44,8 +44,9 @@ class Identity implements Model { required this.providerAccessTokenExpiry, required this.providerRefreshToken, }); - - factory Identity.fromMap(Map map) { + factory Identity.fromMap( + Map map, + ) { return Identity( $id: map['\$id'].toString(), $createdAt: map['\$createdAt'].toString(), diff --git a/lib/src/models/identity_list.dart b/lib/src/models/identity_list.dart index a5d39ea0..81442c4e 100644 --- a/lib/src/models/identity_list.dart +++ b/lib/src/models/identity_list.dart @@ -12,12 +12,14 @@ class IdentityList implements Model { required this.total, required this.identities, }); - - factory IdentityList.fromMap(Map map) { + 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 cda66c70..a7c8e671 100644 --- a/lib/src/models/jwt.dart +++ b/lib/src/models/jwt.dart @@ -8,8 +8,9 @@ class Jwt implements Model { Jwt({ required this.jwt, }); - - factory Jwt.fromMap(Map map) { + factory Jwt.fromMap( + Map map, + ) { return Jwt( jwt: map['jwt'].toString(), ); diff --git a/lib/src/models/language.dart b/lib/src/models/language.dart index 87dc3606..d4bc2020 100644 --- a/lib/src/models/language.dart +++ b/lib/src/models/language.dart @@ -16,8 +16,9 @@ class Language implements Model { required this.code, required this.nativeName, }); - - factory Language.fromMap(Map map) { + factory Language.fromMap( + Map map, + ) { return Language( name: map['name'].toString(), code: map['code'].toString(), diff --git a/lib/src/models/language_list.dart b/lib/src/models/language_list.dart index 6198d61e..c25345b9 100644 --- a/lib/src/models/language_list.dart +++ b/lib/src/models/language_list.dart @@ -12,12 +12,14 @@ class LanguageList implements Model { required this.total, required this.languages, }); - - factory LanguageList.fromMap(Map map) { + 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.dart b/lib/src/models/locale.dart index c29b9e25..8bb3715a 100644 --- a/lib/src/models/locale.dart +++ b/lib/src/models/locale.dart @@ -76,8 +76,9 @@ class Locale implements Model { this.connectionUsageType, this.connectionOrganization, }); - - factory Locale.fromMap(Map map) { + factory Locale.fromMap( + Map map, + ) { return Locale( ip: map['ip'].toString(), countryCode: map['countryCode'].toString(), diff --git a/lib/src/models/locale_code.dart b/lib/src/models/locale_code.dart index 21405aff..6f1cbe09 100644 --- a/lib/src/models/locale_code.dart +++ b/lib/src/models/locale_code.dart @@ -12,8 +12,9 @@ class LocaleCode implements Model { required this.code, required this.name, }); - - factory LocaleCode.fromMap(Map map) { + factory LocaleCode.fromMap( + Map map, + ) { return LocaleCode( code: map['code'].toString(), name: map['name'].toString(), diff --git a/lib/src/models/locale_code_list.dart b/lib/src/models/locale_code_list.dart index 202355a4..4a5606b9 100644 --- a/lib/src/models/locale_code_list.dart +++ b/lib/src/models/locale_code_list.dart @@ -12,12 +12,14 @@ class LocaleCodeList implements Model { required this.total, required this.localeCodes, }); - - factory LocaleCodeList.fromMap(Map map) { + 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.dart b/lib/src/models/log.dart index d754130d..296fe5f8 100644 --- a/lib/src/models/log.dart +++ b/lib/src/models/log.dart @@ -92,8 +92,9 @@ class Log implements Model { required this.countryCode, required this.countryName, }); - - factory Log.fromMap(Map map) { + factory Log.fromMap( + Map map, + ) { return Log( event: map['event'].toString(), userId: map['userId'].toString(), diff --git a/lib/src/models/log_list.dart b/lib/src/models/log_list.dart index 3494b111..07828c75 100644 --- a/lib/src/models/log_list.dart +++ b/lib/src/models/log_list.dart @@ -12,11 +12,14 @@ class LogList implements Model { required this.total, required this.logs, }); - - factory LogList.fromMap(Map map) { + factory LogList.fromMap( + Map map, + ) { return LogList( total: map['total'], - logs: List.from(map['logs'].map((p) => Log.fromMap(p))), + logs: List.from( + map['logs'].map((p) => Log.fromMap(p)), + ), ); } diff --git a/lib/src/models/membership.dart b/lib/src/models/membership.dart index 4d8a2f9b..e34a2320 100644 --- a/lib/src/models/membership.dart +++ b/lib/src/models/membership.dart @@ -64,8 +64,9 @@ class Membership implements Model { required this.userAccessedAt, required this.roles, }); - - factory Membership.fromMap(Map map) { + factory Membership.fromMap( + Map map, + ) { return Membership( $id: map['\$id'].toString(), $createdAt: map['\$createdAt'].toString(), diff --git a/lib/src/models/membership_list.dart b/lib/src/models/membership_list.dart index cc664c9f..4a1c4e0e 100644 --- a/lib/src/models/membership_list.dart +++ b/lib/src/models/membership_list.dart @@ -12,12 +12,14 @@ class MembershipList implements Model { required this.total, required this.memberships, }); - - factory MembershipList.fromMap(Map map) { + 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_challenge.dart b/lib/src/models/mfa_challenge.dart index fa385541..3c4f7ac7 100644 --- a/lib/src/models/mfa_challenge.dart +++ b/lib/src/models/mfa_challenge.dart @@ -20,8 +20,9 @@ class MfaChallenge implements Model { required this.userId, required this.expire, }); - - factory MfaChallenge.fromMap(Map map) { + factory MfaChallenge.fromMap( + Map map, + ) { return MfaChallenge( $id: map['\$id'].toString(), $createdAt: map['\$createdAt'].toString(), diff --git a/lib/src/models/mfa_factors.dart b/lib/src/models/mfa_factors.dart index 2777de7f..9344e198 100644 --- a/lib/src/models/mfa_factors.dart +++ b/lib/src/models/mfa_factors.dart @@ -14,19 +14,25 @@ class MfaFactors implements Model { /// Can recovery code be used for MFA challenge for this account. final bool recoveryCode; + /// Can custom factor be used for MFA challenge for this account. + final bool custom; + MfaFactors({ required this.totp, required this.phone, required this.email, required this.recoveryCode, + required this.custom, }); - - factory MfaFactors.fromMap(Map map) { + factory MfaFactors.fromMap( + Map map, + ) { return MfaFactors( totp: map['totp'], phone: map['phone'], email: map['email'], recoveryCode: map['recoveryCode'], + custom: map['custom'], ); } @@ -37,6 +43,7 @@ class MfaFactors implements Model { "phone": phone, "email": email, "recoveryCode": recoveryCode, + "custom": custom, }; } } diff --git a/lib/src/models/mfa_recovery_codes.dart b/lib/src/models/mfa_recovery_codes.dart index 864a5db8..3693487f 100644 --- a/lib/src/models/mfa_recovery_codes.dart +++ b/lib/src/models/mfa_recovery_codes.dart @@ -8,8 +8,9 @@ class MfaRecoveryCodes implements Model { MfaRecoveryCodes({ required this.recoveryCodes, }); - - factory MfaRecoveryCodes.fromMap(Map map) { + factory MfaRecoveryCodes.fromMap( + Map map, + ) { return MfaRecoveryCodes( recoveryCodes: List.from(map['recoveryCodes'] ?? []), ); diff --git a/lib/src/models/mfa_type.dart b/lib/src/models/mfa_type.dart index fe5327fc..2901f8b4 100644 --- a/lib/src/models/mfa_type.dart +++ b/lib/src/models/mfa_type.dart @@ -12,8 +12,9 @@ class MfaType implements Model { required this.secret, required this.uri, }); - - factory MfaType.fromMap(Map map) { + factory MfaType.fromMap( + Map map, + ) { return MfaType( secret: map['secret'].toString(), uri: map['uri'].toString(), diff --git a/lib/src/models/oauth2_consent.dart b/lib/src/models/oauth2_consent.dart index 0f71fac2..409f872c 100644 --- a/lib/src/models/oauth2_consent.dart +++ b/lib/src/models/oauth2_consent.dart @@ -44,8 +44,9 @@ class Oauth2Consent implements Model { required this.authorizationDetails, required this.expire, }); - - factory Oauth2Consent.fromMap(Map map) { + factory Oauth2Consent.fromMap( + Map map, + ) { return Oauth2Consent( $id: map['\$id'].toString(), $createdAt: map['\$createdAt'].toString(), diff --git a/lib/src/models/oauth2_consent_list.dart b/lib/src/models/oauth2_consent_list.dart index a5f355e1..852174f0 100644 --- a/lib/src/models/oauth2_consent_list.dart +++ b/lib/src/models/oauth2_consent_list.dart @@ -12,12 +12,14 @@ class Oauth2ConsentList implements Model { required this.total, required this.consents, }); - - factory Oauth2ConsentList.fromMap(Map map) { + factory Oauth2ConsentList.fromMap( + Map map, + ) { return Oauth2ConsentList( total: map['total'], consents: List.from( - map['consents'].map((p) => Oauth2Consent.fromMap(p))), + map['consents'].map((p) => Oauth2Consent.fromMap(p)), + ), ); } diff --git a/lib/src/models/oauth2_consent_token.dart b/lib/src/models/oauth2_consent_token.dart index adbee89f..86d935e5 100644 --- a/lib/src/models/oauth2_consent_token.dart +++ b/lib/src/models/oauth2_consent_token.dart @@ -48,8 +48,9 @@ class Oauth2ConsentToken implements Model { required this.authorizationDetails, required this.expire, }); - - factory Oauth2ConsentToken.fromMap(Map map) { + factory Oauth2ConsentToken.fromMap( + Map map, + ) { return Oauth2ConsentToken( $id: map['\$id'].toString(), $createdAt: map['\$createdAt'].toString(), diff --git a/lib/src/models/oauth2_consent_token_list.dart b/lib/src/models/oauth2_consent_token_list.dart index cc5cdc16..a64e80b0 100644 --- a/lib/src/models/oauth2_consent_token_list.dart +++ b/lib/src/models/oauth2_consent_token_list.dart @@ -12,12 +12,14 @@ class Oauth2ConsentTokenList implements Model { required this.total, required this.tokens, }); - - factory Oauth2ConsentTokenList.fromMap(Map map) { + factory Oauth2ConsentTokenList.fromMap( + Map map, + ) { return Oauth2ConsentTokenList( total: map['total'], tokens: List.from( - map['tokens'].map((p) => Oauth2ConsentToken.fromMap(p))), + map['tokens'].map((p) => Oauth2ConsentToken.fromMap(p)), + ), ); } diff --git a/lib/src/models/phone.dart b/lib/src/models/phone.dart index 60e2abd9..27c2f62d 100644 --- a/lib/src/models/phone.dart +++ b/lib/src/models/phone.dart @@ -16,8 +16,9 @@ class Phone implements Model { required this.countryCode, required this.countryName, }); - - factory Phone.fromMap(Map map) { + factory Phone.fromMap( + Map map, + ) { return Phone( code: map['code'].toString(), countryCode: map['countryCode'].toString(), diff --git a/lib/src/models/phone_list.dart b/lib/src/models/phone_list.dart index 1a197fc7..0e0e8ae0 100644 --- a/lib/src/models/phone_list.dart +++ b/lib/src/models/phone_list.dart @@ -12,11 +12,14 @@ class PhoneList implements Model { required this.total, required this.phones, }); - - factory PhoneList.fromMap(Map map) { + factory PhoneList.fromMap( + Map map, + ) { return PhoneList( total: map['total'], - phones: List.from(map['phones'].map((p) => Phone.fromMap(p))), + phones: List.from( + map['phones'].map((p) => Phone.fromMap(p)), + ), ); } diff --git a/lib/src/models/preferences.dart b/lib/src/models/preferences.dart index 3ca04118..992e6f92 100644 --- a/lib/src/models/preferences.dart +++ b/lib/src/models/preferences.dart @@ -7,8 +7,9 @@ class Preferences implements Model { Preferences({ required this.data, }); - - factory Preferences.fromMap(Map map) { + factory Preferences.fromMap( + Map map, + ) { return Preferences( data: map["data"] ?? map, ); diff --git a/lib/src/models/presence.dart b/lib/src/models/presence.dart index d31911de..4c1ac972 100644 --- a/lib/src/models/presence.dart +++ b/lib/src/models/presence.dart @@ -40,8 +40,9 @@ class Presence implements Model { this.expiresAt, this.metadata, }); - - factory Presence.fromMap(Map map) { + factory Presence.fromMap( + Map map, + ) { return Presence( $id: map['\$id'].toString(), $createdAt: map['\$createdAt'].toString(), diff --git a/lib/src/models/presence_list.dart b/lib/src/models/presence_list.dart index 3d010b1c..fe011b7b 100644 --- a/lib/src/models/presence_list.dart +++ b/lib/src/models/presence_list.dart @@ -12,12 +12,14 @@ class PresenceList implements Model { required this.total, required this.presences, }); - - factory PresenceList.fromMap(Map map) { + 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.dart b/lib/src/models/row.dart index a825eab0..bbf94f42 100644 --- a/lib/src/models/row.dart +++ b/lib/src/models/row.dart @@ -35,8 +35,9 @@ class Row implements Model { required this.$permissions, required this.data, }); - - factory Row.fromMap(Map map) { + factory Row.fromMap( + Map map, + ) { return Row( $id: map['\$id'].toString(), $sequence: map['\$sequence'].toString(), diff --git a/lib/src/models/row_list.dart b/lib/src/models/row_list.dart index 5023c633..ca3c9f8c 100644 --- a/lib/src/models/row_list.dart +++ b/lib/src/models/row_list.dart @@ -12,11 +12,14 @@ class RowList implements Model { required this.total, required this.rows, }); - - factory RowList.fromMap(Map map) { + factory RowList.fromMap( + Map map, + ) { return RowList( total: map['total'], - rows: List.from(map['rows'].map((p) => Row.fromMap(p))), + rows: List.from( + map['rows'].map((p) => Row.fromMap(p)), + ), ); } diff --git a/lib/src/models/session.dart b/lib/src/models/session.dart index 92e4034e..821f1fe0 100644 --- a/lib/src/models/session.dart +++ b/lib/src/models/session.dart @@ -120,8 +120,9 @@ class Session implements Model { required this.secret, required this.mfaUpdatedAt, }); - - factory Session.fromMap(Map map) { + factory Session.fromMap( + Map map, + ) { return Session( $id: map['\$id'].toString(), $createdAt: map['\$createdAt'].toString(), diff --git a/lib/src/models/session_list.dart b/lib/src/models/session_list.dart index 4ea12394..e1650b89 100644 --- a/lib/src/models/session_list.dart +++ b/lib/src/models/session_list.dart @@ -12,12 +12,14 @@ class SessionList implements Model { required this.total, required this.sessions, }); - - factory SessionList.fromMap(Map map) { + 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/subscriber.dart b/lib/src/models/subscriber.dart index 450aafd1..377ada24 100644 --- a/lib/src/models/subscriber.dart +++ b/lib/src/models/subscriber.dart @@ -40,14 +40,17 @@ class Subscriber implements Model { required this.topicId, required this.providerType, }); - - factory Subscriber.fromMap(Map map) { + factory Subscriber.fromMap( + Map map, + ) { return Subscriber( $id: map['\$id'].toString(), $createdAt: map['\$createdAt'].toString(), $updatedAt: map['\$updatedAt'].toString(), targetId: map['targetId'].toString(), - target: Target.fromMap(map['target']), + target: Target.fromMap( + map['target'], + ), userId: map['userId'].toString(), userName: map['userName'].toString(), topicId: map['topicId'].toString(), diff --git a/lib/src/models/target.dart b/lib/src/models/target.dart index c2e8c4dc..9b2b9cd2 100644 --- a/lib/src/models/target.dart +++ b/lib/src/models/target.dart @@ -40,8 +40,9 @@ class Target implements Model { required this.identifier, required this.expired, }); - - factory Target.fromMap(Map map) { + factory Target.fromMap( + Map map, + ) { return Target( $id: map['\$id'].toString(), $createdAt: map['\$createdAt'].toString(), diff --git a/lib/src/models/team.dart b/lib/src/models/team.dart index 91b888b9..59647c35 100644 --- a/lib/src/models/team.dart +++ b/lib/src/models/team.dart @@ -28,15 +28,18 @@ class Team implements Model { required this.total, required this.prefs, }); - - factory Team.fromMap(Map map) { + factory Team.fromMap( + Map map, + ) { return Team( $id: map['\$id'].toString(), $createdAt: map['\$createdAt'].toString(), $updatedAt: map['\$updatedAt'].toString(), name: map['name'].toString(), total: map['total'], - prefs: Preferences.fromMap(map['prefs']), + prefs: Preferences.fromMap( + map['prefs'], + ), ); } diff --git a/lib/src/models/team_list.dart b/lib/src/models/team_list.dart index e8f1c621..2a6a60a2 100644 --- a/lib/src/models/team_list.dart +++ b/lib/src/models/team_list.dart @@ -12,11 +12,14 @@ class TeamList implements Model { required this.total, required this.teams, }); - - factory TeamList.fromMap(Map map) { + factory TeamList.fromMap( + Map map, + ) { return TeamList( total: map['total'], - teams: List.from(map['teams'].map((p) => Team.fromMap(p))), + teams: List.from( + map['teams'].map((p) => Team.fromMap(p)), + ), ); } diff --git a/lib/src/models/token.dart b/lib/src/models/token.dart index b5ea87c8..fb75327f 100644 --- a/lib/src/models/token.dart +++ b/lib/src/models/token.dart @@ -28,8 +28,9 @@ class Token implements Model { required this.expire, required this.phrase, }); - - factory Token.fromMap(Map map) { + factory Token.fromMap( + Map map, + ) { return Token( $id: map['\$id'].toString(), $createdAt: map['\$createdAt'].toString(), diff --git a/lib/src/models/transaction.dart b/lib/src/models/transaction.dart index b0606dd8..9e3c1099 100644 --- a/lib/src/models/transaction.dart +++ b/lib/src/models/transaction.dart @@ -28,8 +28,9 @@ class Transaction implements Model { required this.operations, required this.expiresAt, }); - - factory Transaction.fromMap(Map map) { + factory Transaction.fromMap( + Map map, + ) { return Transaction( $id: map['\$id'].toString(), $createdAt: map['\$createdAt'].toString(), diff --git a/lib/src/models/transaction_list.dart b/lib/src/models/transaction_list.dart index 7f321175..6e92d163 100644 --- a/lib/src/models/transaction_list.dart +++ b/lib/src/models/transaction_list.dart @@ -12,12 +12,14 @@ class TransactionList implements Model { required this.total, required this.transactions, }); - - factory TransactionList.fromMap(Map map) { + 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/models/user.dart b/lib/src/models/user.dart index 5a6cad30..8650dfd5 100644 --- a/lib/src/models/user.dart +++ b/lib/src/models/user.dart @@ -108,8 +108,9 @@ class User implements Model { this.impersonator, this.impersonatorUserId, }); - - factory User.fromMap(Map map) { + factory User.fromMap( + Map map, + ) { return User( $id: map['\$id'].toString(), $createdAt: map['\$createdAt'].toString(), @@ -132,8 +133,12 @@ class User implements Model { emailIsCanonical: map['emailIsCanonical'], phoneVerification: map['phoneVerification'], mfa: map['mfa'], - prefs: Preferences.fromMap(map['prefs']), - targets: List.from(map['targets'].map((p) => Target.fromMap(p))), + prefs: Preferences.fromMap( + map['prefs'], + ), + targets: List.from( + map['targets'].map((p) => Target.fromMap(p)), + ), accessedAt: map['accessedAt'].toString(), impersonator: map['impersonator'], impersonatorUserId: map['impersonatorUserId']?.toString(), diff --git a/lib/src/realtime_browser.dart b/lib/src/realtime_browser.dart index a0f4193a..e56b7ddd 100644 --- a/lib/src/realtime_browser.dart +++ b/lib/src/realtime_browser.dart @@ -25,10 +25,12 @@ class RealtimeBrowser extends RealtimeBase with RealtimeMixin { final jwt = client.config['jwt']; if (jwt != null && jwt.isNotEmpty) { - uri = uri.replace(queryParameters: { - ...uri.queryParameters, - 'jwt': jwt, - }); + 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 0ed367a6..ab1c3b42 100644 --- a/lib/src/realtime_io.dart +++ b/lib/src/realtime_io.dart @@ -37,9 +37,11 @@ class RealtimeIO extends RealtimeBase with RealtimeMixin { headers['x-appwrite-jwt'] = jwt; } - final websok = IOWebSocketChannel((client as ClientIO).selfSigned - ? await _connectForSelfSignedCert(uri, headers) - : await WebSocket.connect(uri.toString(), headers: headers)); + final websok = IOWebSocketChannel( + (client as ClientIO).selfSigned + ? await _connectForSelfSignedCert(uri, headers) + : await WebSocket.connect(uri.toString(), headers: headers), + ); return websok; } @@ -73,13 +75,18 @@ class RealtimeIO extends RealtimeBase with RealtimeMixin { // https://github.com/jonataslaw/getsocket/blob/f25b3a264d8cc6f82458c949b86d286cd0343792/lib/src/io.dart#L104 // and from official dart sdk websocket_impl.dart connect method Future _connectForSelfSignedCert( - Uri uri, Map headers) async { + Uri uri, + Map headers, + ) async { try { var r = Random(); var key = base64.encode(List.generate(16, (_) => r.nextInt(255))); var client = HttpClient(context: SecurityContext()); - client.badCertificateCallback = - (X509Certificate cert, String host, int port) { + client.badCertificateCallback = ( + X509Certificate cert, + String host, + int port, + ) { return true; }; diff --git a/lib/src/realtime_mixin.dart b/lib/src/realtime_mixin.dart index 72edf5ee..639f2795 100644 --- a/lib/src/realtime_mixin.dart +++ b/lib/src/realtime_mixin.dart @@ -100,74 +100,80 @@ 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, - }, - })); + _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, + }; } - } - 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) { + _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; + } - 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; @@ -197,27 +203,30 @@ mixin RealtimeMixin { return _retries < 5 ? 1 : _retries < 15 - ? 5 - : _retries < 100 - ? 10 - : 60; + ? 5 + : _retries < 100 + ? 10 + : 60; } Uri _prepareUri() { if (client.endPointRealtime == null) { throw AppwriteException( - "Please set endPointRealtime to connect to realtime server"); + "Please set endPointRealtime to connect to realtime server", + ); } var uri = Uri.parse(client.endPointRealtime!); var queryParams = "project=${Uri.encodeComponent(client.config['project']!)}"; - final portPart = (uri.hasPort && uri.port != 80 && uri.port != 443) - ? ':${uri.port}' - : ''; + final portPart = + (uri.hasPort && uri.port != 80 && uri.port != 443) + ? ':${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) { @@ -227,10 +236,12 @@ 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() { @@ -292,10 +303,12 @@ 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() { @@ -312,8 +325,10 @@ 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(); diff --git a/lib/src/realtime_response.dart b/lib/src/realtime_response.dart index b0356111..e444cd0b 100644 --- a/lib/src/realtime_response.dart +++ b/lib/src/realtime_response.dart @@ -4,26 +4,14 @@ import 'package:flutter/foundation.dart'; class RealtimeResponse { final String type; // error, event, connected, response final Map data; - RealtimeResponse({ - required this.type, - required this.data, - }); - - RealtimeResponse copyWith({ - String? type, - Map? data, - }) { - return RealtimeResponse( - type: type ?? this.type, - data: data ?? this.data, - ); + RealtimeResponse({required this.type, required this.data}); + + RealtimeResponse copyWith({String? type, Map? data}) { + return RealtimeResponse(type: type ?? this.type, data: data ?? this.data); } Map toMap() { - return { - 'type': type, - 'data': data, - }; + return {'type': type, 'data': data}; } factory RealtimeResponse.fromMap(Map map) { diff --git a/lib/src/realtime_stub.dart b/lib/src/realtime_stub.dart index 3aab4e03..631afe31 100644 --- a/lib/src/realtime_stub.dart +++ b/lib/src/realtime_stub.dart @@ -2,6 +2,7 @@ import 'realtime_base.dart'; import 'client.dart'; /// Implemented in `realtime_browser.dart` and `realtime_io.dart`. -RealtimeBase createRealtime(Client client) => throw UnsupportedError( +RealtimeBase createRealtime(Client client) => + throw UnsupportedError( 'Cannot create a client without dart:html or dart:io.', ); diff --git a/lib/src/realtime_subscription.dart b/lib/src/realtime_subscription.dart index e572b519..6461e344 100644 --- a/lib/src/realtime_subscription.dart +++ b/lib/src/realtime_subscription.dart @@ -21,7 +21,7 @@ class RealtimeSubscription { /// Replace the channels and/or queries on this subscription without recreating it. final Future Function({List? channels, List? queries}) - update; + update; /// Alias of [unsubscribe] that also closes the socket when this was the last active /// subscription. Prefer [unsubscribe] plus [Realtime.disconnect] for explicit control. diff --git a/pubspec.yaml b/pubspec.yaml index 98866f5c..ee9ee40c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: appwrite -version: 25.4.0 +version: 26.0.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 @@ -13,16 +13,17 @@ platforms: web: windows: environment: - sdk: '>=2.17.0 <4.0.0' + sdk: '>=3.7.0 <4.0.0' + flutter: '>=3.29.0' dependencies: flutter: sdk: flutter cookie_jar: ^4.0.8 - device_info_plus: '>=11.5.0 <13.0.0' + device_info_plus: '>=11.5.0 <14.0.0' flutter_web_auth_2: ^5.0.0 http: '>=0.13.6 <2.0.0' - package_info_plus: '>=8.0.2 <10.0.0' + package_info_plus: '>=8.0.2 <11.0.0' path_provider: ^2.1.4 web_socket_channel: ^3.0.1 web: ^1.0.0 diff --git a/test/channel_test.dart b/test/channel_test.dart index 9e0e11d3..5ed52b81 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,18 +39,17 @@ 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', + ); }); }); @@ -67,12 +66,16 @@ 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', + ); }); }); @@ -116,13 +119,17 @@ 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', + ); }); }); @@ -140,23 +147,31 @@ 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/services/account_test.dart b/test/services/account_test.dart index 2752044f..00c1e68e 100644 --- a/test/services/account_test.dart +++ b/test/services/account_test.dart @@ -10,6 +10,7 @@ import 'package:appwrite/appwrite.dart'; class MockClient extends Mock implements Client { Map config = {'project': 'testproject'}; String endPoint = 'https://localhost/v1'; + @override Future call( HttpMethod? method, { @@ -18,17 +19,18 @@ class MockClient extends Mock implements Client { Map params = const {}, ResponseType? responseType, }) async { - return super.noSuchMethod(Invocation.method(#call, [method]), - returnValue: Response()); + return super.noSuchMethod( + Invocation.method(#call, [method]), + returnValue: Response(), + ); } @override - Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Future webAuth(Uri? url, {String? callbackUrlScheme}) async { + return super.noSuchMethod( + Invocation.method(#webAuth, [url]), + returnValue: 'done', + ); } @override @@ -41,9 +43,15 @@ 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: {}), + ); } } @@ -59,27 +67,27 @@ void main() { test('test method get()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "John Doe", + 'registration': "2020-10-15T06:38:00.000+00:00", 'status': true, 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', + 'passwordUpdate': "2020-10-15T06:38:00.000+00:00", + 'email': "john@appwrite.io", + 'phone': "+4930901820", 'emailVerification': true, 'phoneVerification': true, 'mfa': true, 'prefs': {}, 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', + '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()); @@ -87,32 +95,32 @@ void main() { test('test method create()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "John Doe", + 'registration': "2020-10-15T06:38:00.000+00:00", 'status': true, 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', + 'passwordUpdate': "2020-10-15T06:38:00.000+00:00", + 'email': "john@appwrite.io", + 'phone': "+4930901820", 'emailVerification': true, 'phoneVerification': true, 'mfa': true, 'prefs': {}, 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', + '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', + userId: "", + email: "email@example.com", + password: "password", ); expect(response, isA()); }); @@ -123,9 +131,9 @@ void main() { 'consents': [], }; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.get), + ).thenAnswer((_) async => Response(data: data)); final response = await account.listConsents(); expect(response, isA()); @@ -133,25 +141,25 @@ void main() { test('test method getConsent()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'appId': '5e5ea5c16897e', - 'cimdUrl': 'https://example.com/.well-known/client-metadata.json', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'userId': "5e5ea5c16897e", + 'appId': "5e5ea5c16897e", + 'cimdUrl': "https://example.com/.well-known/client-metadata.json", 'scopes': [], 'resources': [], 'authorizationDetails': - '[{\"type\":\"calendar\",\"identifier\":\"primary\",\"actions\":[\"read_events\",\"create_event\"]}]', - 'expire': '2020-10-15T06:38:00.000+00:00', + "[{\"type\":\"calendar\",\"identifier\":\"primary\",\"actions\":[\"read_events\",\"create_event\"]}]", + 'expire': "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.getConsent( - consentId: '', + consentId: "", ); expect(response, isA()); }); @@ -159,12 +167,12 @@ void main() { test('test method deleteConsent()', () 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.deleteConsent( - consentId: '', + consentId: "", ); }); @@ -174,39 +182,39 @@ void main() { 'tokens': [], }; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.get), + ).thenAnswer((_) async => Response(data: data)); final response = await account.listConsentTokens( - consentId: '', + consentId: "", ); expect(response, isA()); }); test('test method getConsentToken()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'consentId': '5e5ea5c16897e', - 'userId': '5e5ea5c16897e', - 'appId': '5e5ea5c16897e', - 'cimdUrl': 'https://example.com/.well-known/client-metadata.json', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'consentId': "5e5ea5c16897e", + 'userId': "5e5ea5c16897e", + 'appId': "5e5ea5c16897e", + 'cimdUrl': "https://example.com/.well-known/client-metadata.json", 'scopes': [], 'resources': [], 'authorizationDetails': - '[{\"type\":\"calendar\",\"identifier\":\"primary\",\"actions\":[\"read_events\",\"create_event\"]}]', - 'expire': '2020-10-15T06:38:00.000+00:00', + "[{\"type\":\"calendar\",\"identifier\":\"primary\",\"actions\":[\"read_events\",\"create_event\"]}]", + 'expire': "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.getConsentToken( - consentId: '', - tokenId: '', + consentId: "", + tokenId: "", ); expect(response, isA()); }); @@ -214,43 +222,43 @@ void main() { test('test method deleteConsentToken()', () 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.deleteConsentToken( - consentId: '', - tokenId: '', + consentId: "", + tokenId: "", ); }); test('test method updateEmail()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "John Doe", + 'registration': "2020-10-15T06:38:00.000+00:00", 'status': true, 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', + 'passwordUpdate': "2020-10-15T06:38:00.000+00:00", + 'email': "john@appwrite.io", + 'phone': "+4930901820", 'emailVerification': true, 'phoneVerification': true, 'mfa': true, 'prefs': {}, 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', + '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', - password: 'password', + email: "email@example.com", + password: "password", ); expect(response, isA()); }); @@ -261,9 +269,9 @@ void main() { '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()); @@ -272,24 +280,24 @@ 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: '', + identityId: "", ); }); test('test method createJWT()', () async { final Map data = { 'jwt': - 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', + "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()); @@ -301,9 +309,9 @@ void main() { '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()); @@ -311,27 +319,27 @@ void main() { test('test method updateMFA()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "John Doe", + 'registration': "2020-10-15T06:38:00.000+00:00", 'status': true, 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', + 'passwordUpdate': "2020-10-15T06:38:00.000+00:00", + 'email': "john@appwrite.io", + 'phone': "+4930901820", 'emailVerification': true, 'phoneVerification': true, 'mfa': true, 'prefs': {}, 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', + '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, @@ -341,14 +349,14 @@ void main() { test('test method createMfaAuthenticator()', () async { final Map data = { - 'secret': '[SHARED_SECRET]', + 'secret': "[SHARED_SECRET]", 'uri': - 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', + "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, @@ -358,14 +366,14 @@ void main() { test('test method createMFAAuthenticator()', () async { final Map data = { - 'secret': '[SHARED_SECRET]', + 'secret': "[SHARED_SECRET]", 'uri': - 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', + "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, @@ -375,62 +383,62 @@ void main() { test('test method updateMfaAuthenticator()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "John Doe", + 'registration': "2020-10-15T06:38:00.000+00:00", 'status': true, 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', + 'passwordUpdate': "2020-10-15T06:38:00.000+00:00", + 'email': "john@appwrite.io", + 'phone': "+4930901820", 'emailVerification': true, 'phoneVerification': true, 'mfa': true, 'prefs': {}, 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', + '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, - otp: '', + otp: "", ); expect(response, isA()); }); test('test method updateMFAAuthenticator()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "John Doe", + 'registration': "2020-10-15T06:38:00.000+00:00", 'status': true, 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', + 'passwordUpdate': "2020-10-15T06:38:00.000+00:00", + 'email': "john@appwrite.io", + 'phone': "+4930901820", 'emailVerification': true, 'phoneVerification': true, 'mfa': true, 'prefs': {}, 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', + '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, - otp: '', + otp: "", ); expect(response, isA()); }); @@ -438,9 +446,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, @@ -450,9 +458,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, @@ -461,15 +469,15 @@ void main() { test('test method createMfaChallenge()', () async { final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'expire': '2020-10-15T06:38:00.000+00:00', + '\$id': "bb8ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + 'userId': "5e5ea5c168bb8", + 'expire': "2020-10-15T06:38:00.000+00:00", }; - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); final response = await account.createMfaChallenge( factor: enums.AuthenticationFactor.email, @@ -479,15 +487,15 @@ void main() { test('test method createMFAChallenge()', () async { final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'expire': '2020-10-15T06:38:00.000+00:00', + '\$id': "bb8ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + 'userId': "5e5ea5c168bb8", + 'expire': "2020-10-15T06:38:00.000+00:00", }; - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); final response = await account.createMFAChallenge( factor: enums.AuthenticationFactor.email, @@ -497,88 +505,88 @@ void main() { test('test method updateMfaChallenge()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'userId': "5e5bb8c16897e", + 'expire': "2020-10-15T06:38:00.000+00:00", + 'provider': "email", + 'providerUid': "user@example.com", + 'providerAccessToken': "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + 'providerAccessTokenExpiry': "2020-10-15T06:38:00.000+00:00", + 'providerRefreshToken': "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + 'ip': "127.0.0.1", + 'osCode': "Mac", + 'osName': "Mac", + 'osVersion': "Mac", + 'clientType': "browser", + 'clientCode': "CM", + 'clientName': "Chrome Mobile iOS", + 'clientVersion': "84.0", + 'clientEngine': "WebKit", + 'clientEngineVersion': "605.1.15", + 'deviceName': "smartphone", + 'deviceBrand': "Google", + 'deviceModel': "Nexus 5", + 'countryCode': "US", + 'countryName': "United States", 'current': true, 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + 'secret': "5e5bb8c16897e", + '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: '', - otp: '', + challengeId: "", + otp: "", ); expect(response, isA()); }); test('test method updateMFAChallenge()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'userId': "5e5bb8c16897e", + 'expire': "2020-10-15T06:38:00.000+00:00", + 'provider': "email", + 'providerUid': "user@example.com", + 'providerAccessToken': "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + 'providerAccessTokenExpiry': "2020-10-15T06:38:00.000+00:00", + 'providerRefreshToken': "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + 'ip': "127.0.0.1", + 'osCode': "Mac", + 'osName': "Mac", + 'osVersion': "Mac", + 'clientType': "browser", + 'clientCode': "CM", + 'clientName': "Chrome Mobile iOS", + 'clientVersion': "84.0", + 'clientEngine': "WebKit", + 'clientEngineVersion': "605.1.15", + 'deviceName': "smartphone", + 'deviceBrand': "Google", + 'deviceModel': "Nexus 5", + 'countryCode': "US", + 'countryName': "United States", 'current': true, 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + 'secret': "5e5bb8c16897e", + '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: '', - otp: '', + challengeId: "", + otp: "", ); expect(response, isA()); }); @@ -589,11 +597,12 @@ void main() { 'phone': true, 'email': true, 'recoveryCode': true, + 'custom': 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()); @@ -605,11 +614,12 @@ void main() { 'phone': true, 'email': true, 'recoveryCode': true, + 'custom': 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()); @@ -620,9 +630,9 @@ void main() { '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()); @@ -633,9 +643,9 @@ void main() { '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()); @@ -646,9 +656,9 @@ void main() { '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()); @@ -659,9 +669,9 @@ void main() { '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()); @@ -672,9 +682,9 @@ void main() { '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()); @@ -685,9 +695,9 @@ void main() { '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()); @@ -695,91 +705,91 @@ void main() { test('test method updateName()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "John Doe", + 'registration': "2020-10-15T06:38:00.000+00:00", 'status': true, 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', + 'passwordUpdate': "2020-10-15T06:38:00.000+00:00", + 'email': "john@appwrite.io", + 'phone': "+4930901820", 'emailVerification': true, 'phoneVerification': true, 'mfa': true, 'prefs': {}, 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', + '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: '', + name: "", ); expect(response, isA()); }); test('test method updatePassword()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "John Doe", + 'registration': "2020-10-15T06:38:00.000+00:00", 'status': true, 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', + 'passwordUpdate': "2020-10-15T06:38:00.000+00:00", + 'email': "john@appwrite.io", + 'phone': "+4930901820", 'emailVerification': true, 'phoneVerification': true, 'mfa': true, 'prefs': {}, 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', + '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: 'password', + password: "password", ); expect(response, isA()); }); test('test method updatePhone()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "John Doe", + 'registration': "2020-10-15T06:38:00.000+00:00", 'status': true, 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', + 'passwordUpdate': "2020-10-15T06:38:00.000+00:00", + 'email': "john@appwrite.io", + 'phone': "+4930901820", 'emailVerification': true, 'phoneVerification': true, 'mfa': true, 'prefs': {}, 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', + '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', - password: 'password', + phone: "+12065550100", + password: "password", ); expect(response, isA()); }); @@ -787,9 +797,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()); @@ -797,27 +807,27 @@ void main() { test('test method updatePrefs()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "John Doe", + 'registration': "2020-10-15T06:38:00.000+00:00", 'status': true, 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', + 'passwordUpdate': "2020-10-15T06:38:00.000+00:00", + 'email': "john@appwrite.io", + 'phone': "+4930901820", 'emailVerification': true, 'phoneVerification': true, 'mfa': true, 'prefs': {}, 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', + '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: {}, @@ -827,43 +837,43 @@ void main() { test('test method createRecovery()', () async { final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', + '\$id': "bb8ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + 'userId': "5e5ea5c168bb8", + 'secret': "", + 'expire': "2020-10-15T06:38:00.000+00:00", + 'phrase': "Golden Fox", }; - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); final response = await account.createRecovery( - email: 'email@example.com', - url: 'https://example.com', + email: "email@example.com", + url: "https://example.com", ); expect(response, isA()); }); test('test method updateRecovery()', () async { final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', + '\$id': "bb8ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + 'userId': "5e5ea5c168bb8", + 'secret': "", + 'expire': "2020-10-15T06:38:00.000+00:00", + 'phrase': "Golden Fox", }; - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.put), + ).thenAnswer((_) async => Response(data: data)); final response = await account.updateRecovery( - userId: '', - secret: '', - password: 'password', + userId: "", + secret: "", + password: "password", ); expect(response, isA()); }); @@ -874,9 +884,9 @@ void main() { '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()); @@ -885,49 +895,49 @@ 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(); }); test('test method createAnonymousSession()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'userId': "5e5bb8c16897e", + 'expire': "2020-10-15T06:38:00.000+00:00", + 'provider': "email", + 'providerUid': "user@example.com", + 'providerAccessToken': "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + 'providerAccessTokenExpiry': "2020-10-15T06:38:00.000+00:00", + 'providerRefreshToken': "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + 'ip': "127.0.0.1", + 'osCode': "Mac", + 'osName': "Mac", + 'osVersion': "Mac", + 'clientType': "browser", + 'clientCode': "CM", + 'clientName': "Chrome Mobile iOS", + 'clientVersion': "84.0", + 'clientEngine': "WebKit", + 'clientEngineVersion': "605.1.15", + 'deviceName': "smartphone", + 'deviceBrand': "Google", + 'deviceModel': "Nexus 5", + 'countryCode': "US", + 'countryName': "United States", 'current': true, 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + 'secret': "5e5bb8c16897e", + '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()); @@ -935,96 +945,96 @@ void main() { test('test method createEmailPasswordSession()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'userId': "5e5bb8c16897e", + 'expire': "2020-10-15T06:38:00.000+00:00", + 'provider': "email", + 'providerUid': "user@example.com", + 'providerAccessToken': "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + 'providerAccessTokenExpiry': "2020-10-15T06:38:00.000+00:00", + 'providerRefreshToken': "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + 'ip': "127.0.0.1", + 'osCode': "Mac", + 'osName': "Mac", + 'osVersion': "Mac", + 'clientType': "browser", + 'clientCode': "CM", + 'clientName': "Chrome Mobile iOS", + 'clientVersion': "84.0", + 'clientEngine': "WebKit", + 'clientEngineVersion': "605.1.15", + 'deviceName': "smartphone", + 'deviceBrand': "Google", + 'deviceModel': "Nexus 5", + 'countryCode': "US", + 'countryName': "United States", 'current': true, 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + 'secret': "5e5bb8c16897e", + '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', - password: 'password', + email: "email@example.com", + password: "password", ); expect(response, isA()); }); test('test method updateMagicURLSession()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'userId': "5e5bb8c16897e", + 'expire': "2020-10-15T06:38:00.000+00:00", + 'provider': "email", + 'providerUid': "user@example.com", + 'providerAccessToken': "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + 'providerAccessTokenExpiry': "2020-10-15T06:38:00.000+00:00", + 'providerRefreshToken': "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + 'ip': "127.0.0.1", + 'osCode': "Mac", + 'osName': "Mac", + 'osVersion': "Mac", + 'clientType': "browser", + 'clientCode': "CM", + 'clientName': "Chrome Mobile iOS", + 'clientVersion': "84.0", + 'clientEngine': "WebKit", + 'clientEngineVersion': "605.1.15", + 'deviceName': "smartphone", + 'deviceBrand': "Google", + 'deviceModel': "Nexus 5", + 'countryCode': "US", + 'countryName': "United States", 'current': true, 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + 'secret': "5e5bb8c16897e", + '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: '', - secret: '', + userId: "", + secret: "", ); expect(response, isA()); }); test('test method createOAuth2Session()', () async { - when(client.webAuth( - argThat(isNotNull), - )).thenAnswer((_) async => 'done'); + final data = ''; + + when(client.webAuth(argThat(isNotNull))).thenAnswer((_) async => 'done'); final response = await account.createOAuth2Session( provider: enums.OAuthProvider.amazon, @@ -1034,174 +1044,174 @@ void main() { test('test method updatePhoneSession()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'userId': "5e5bb8c16897e", + 'expire': "2020-10-15T06:38:00.000+00:00", + 'provider': "email", + 'providerUid': "user@example.com", + 'providerAccessToken': "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + 'providerAccessTokenExpiry': "2020-10-15T06:38:00.000+00:00", + 'providerRefreshToken': "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + 'ip': "127.0.0.1", + 'osCode': "Mac", + 'osName': "Mac", + 'osVersion': "Mac", + 'clientType': "browser", + 'clientCode': "CM", + 'clientName': "Chrome Mobile iOS", + 'clientVersion': "84.0", + 'clientEngine': "WebKit", + 'clientEngineVersion': "605.1.15", + 'deviceName': "smartphone", + 'deviceBrand': "Google", + 'deviceModel': "Nexus 5", + 'countryCode': "US", + 'countryName': "United States", 'current': true, 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + 'secret': "5e5bb8c16897e", + '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: '', - secret: '', + userId: "", + secret: "", ); expect(response, isA()); }); test('test method createSession()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'userId': "5e5bb8c16897e", + 'expire': "2020-10-15T06:38:00.000+00:00", + 'provider': "email", + 'providerUid': "user@example.com", + 'providerAccessToken': "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + 'providerAccessTokenExpiry': "2020-10-15T06:38:00.000+00:00", + 'providerRefreshToken': "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + 'ip': "127.0.0.1", + 'osCode': "Mac", + 'osName': "Mac", + 'osVersion': "Mac", + 'clientType': "browser", + 'clientCode': "CM", + 'clientName': "Chrome Mobile iOS", + 'clientVersion': "84.0", + 'clientEngine': "WebKit", + 'clientEngineVersion': "605.1.15", + 'deviceName': "smartphone", + 'deviceBrand': "Google", + 'deviceModel': "Nexus 5", + 'countryCode': "US", + 'countryName': "United States", 'current': true, 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + 'secret': "5e5bb8c16897e", + '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: '', - secret: '', + userId: "", + secret: "", ); expect(response, isA()); }); test('test method getSession()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'userId': "5e5bb8c16897e", + 'expire': "2020-10-15T06:38:00.000+00:00", + 'provider': "email", + 'providerUid': "user@example.com", + 'providerAccessToken': "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + 'providerAccessTokenExpiry': "2020-10-15T06:38:00.000+00:00", + 'providerRefreshToken': "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + 'ip': "127.0.0.1", + 'osCode': "Mac", + 'osName': "Mac", + 'osVersion': "Mac", + 'clientType': "browser", + 'clientCode': "CM", + 'clientName': "Chrome Mobile iOS", + 'clientVersion': "84.0", + 'clientEngine': "WebKit", + 'clientEngineVersion': "605.1.15", + 'deviceName': "smartphone", + 'deviceBrand': "Google", + 'deviceModel': "Nexus 5", + 'countryCode': "US", + 'countryName': "United States", 'current': true, 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + 'secret': "5e5bb8c16897e", + '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: '', + sessionId: "", ); expect(response, isA()); }); test('test method updateSession()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5bb8c16897e', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'provider': 'email', - 'providerUid': 'user@example.com', - 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', - 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - 'ip': '127.0.0.1', - 'osCode': 'Mac', - 'osName': 'Mac', - 'osVersion': 'Mac', - 'clientType': 'browser', - 'clientCode': 'CM', - 'clientName': 'Chrome Mobile iOS', - 'clientVersion': '84.0', - 'clientEngine': 'WebKit', - 'clientEngineVersion': '605.1.15', - 'deviceName': 'smartphone', - 'deviceBrand': 'Google', - 'deviceModel': 'Nexus 5', - 'countryCode': 'US', - 'countryName': 'United States', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'userId': "5e5bb8c16897e", + 'expire': "2020-10-15T06:38:00.000+00:00", + 'provider': "email", + 'providerUid': "user@example.com", + 'providerAccessToken': "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + 'providerAccessTokenExpiry': "2020-10-15T06:38:00.000+00:00", + 'providerRefreshToken': "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + 'ip': "127.0.0.1", + 'osCode': "Mac", + 'osName': "Mac", + 'osVersion': "Mac", + 'clientType': "browser", + 'clientCode': "CM", + 'clientName': "Chrome Mobile iOS", + 'clientVersion': "84.0", + 'clientEngine': "WebKit", + 'clientEngineVersion': "605.1.15", + 'deviceName': "smartphone", + 'deviceBrand': "Google", + 'deviceModel': "Nexus 5", + 'countryCode': "US", + 'countryName': "United States", 'current': true, 'factors': [], - 'secret': '5e5bb8c16897e', - 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00', + 'secret': "5e5bb8c16897e", + '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: '', + sessionId: "", ); expect(response, isA()); }); @@ -1209,38 +1219,38 @@ void main() { 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: '', + sessionId: "", ); }); test('test method updateStatus()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'John Doe', - 'registration': '2020-10-15T06:38:00.000+00:00', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "John Doe", + 'registration': "2020-10-15T06:38:00.000+00:00", 'status': true, 'labels': [], - 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', - 'email': 'john@appwrite.io', - 'phone': '+4930901820', + 'passwordUpdate': "2020-10-15T06:38:00.000+00:00", + 'email': "john@appwrite.io", + 'phone': "+4930901820", 'emailVerification': true, 'phoneVerification': true, 'mfa': true, 'prefs': {}, 'targets': [], - 'accessedAt': '2020-10-15T06:38:00.000+00:00', + '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()); @@ -1248,46 +1258,46 @@ void main() { test('test method createPushTarget()', () async { final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'Apple iPhone 12', - 'userId': '259125845563242502', - 'providerType': 'email', - 'identifier': 'token', + '\$id': "259125845563242502", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "Apple iPhone 12", + 'userId': "259125845563242502", + 'providerType': "email", + 'identifier': "token", 'expired': true, }; - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); final response = await account.createPushTarget( - targetId: '', - identifier: '', + targetId: "", + identifier: "", ); expect(response, isA()); }); test('test method updatePushTarget()', () async { final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'Apple iPhone 12', - 'userId': '259125845563242502', - 'providerType': 'email', - 'identifier': 'token', + '\$id': "259125845563242502", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "Apple iPhone 12", + 'userId': "259125845563242502", + 'providerType': "email", + 'identifier': "token", 'expired': true, }; - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.put), + ).thenAnswer((_) async => Response(data: data)); final response = await account.updatePushTarget( - targetId: '', - identifier: '', + targetId: "", + identifier: "", ); expect(response, isA()); }); @@ -1295,61 +1305,61 @@ 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: '', + targetId: "", ); }); test('test method createEmailToken()', () async { final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', + '\$id': "bb8ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + 'userId': "5e5ea5c168bb8", + 'secret': "", + 'expire': "2020-10-15T06:38:00.000+00:00", + 'phrase': "Golden Fox", }; - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); final response = await account.createEmailToken( - userId: '', - email: 'email@example.com', + userId: "", + email: "email@example.com", ); expect(response, isA()); }); test('test method createMagicURLToken()', () async { final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', + '\$id': "bb8ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + 'userId': "5e5ea5c168bb8", + 'secret': "", + 'expire': "2020-10-15T06:38:00.000+00:00", + 'phrase': "Golden Fox", }; - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); final response = await account.createMagicURLToken( - userId: '', - email: 'email@example.com', + userId: "", + email: "email@example.com", ); expect(response, isA()); }); test('test method createOAuth2Token()', () async { - when(client.webAuth( - argThat(isNotNull), - )).thenAnswer((_) async => 'done'); + final data = ''; + + when(client.webAuth(argThat(isNotNull))).thenAnswer((_) async => 'done'); final response = await account.createOAuth2Token( provider: enums.OAuthProvider.amazon, @@ -1359,120 +1369,120 @@ void main() { test('test method createPhoneToken()', () async { final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', + '\$id': "bb8ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + 'userId': "5e5ea5c168bb8", + 'secret': "", + 'expire': "2020-10-15T06:38:00.000+00:00", + 'phrase': "Golden Fox", }; - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); final response = await account.createPhoneToken( - userId: '', - phone: '+12065550100', + userId: "", + phone: "+12065550100", ); expect(response, isA()); }); test('test method createEmailVerification()', () async { final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', + '\$id': "bb8ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + 'userId': "5e5ea5c168bb8", + 'secret': "", + 'expire': "2020-10-15T06:38:00.000+00:00", + 'phrase': "Golden Fox", }; - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); final response = await account.createEmailVerification( - url: 'https://example.com', + url: "https://example.com", ); expect(response, isA()); }); test('test method createVerification()', () async { final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', + '\$id': "bb8ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + 'userId': "5e5ea5c168bb8", + 'secret': "", + 'expire': "2020-10-15T06:38:00.000+00:00", + 'phrase': "Golden Fox", }; - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); final response = await account.createVerification( - url: 'https://example.com', + url: "https://example.com", ); expect(response, isA()); }); test('test method updateEmailVerification()', () async { final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', + '\$id': "bb8ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + 'userId': "5e5ea5c168bb8", + 'secret': "", + 'expire': "2020-10-15T06:38:00.000+00:00", + 'phrase': "Golden Fox", }; - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.put), + ).thenAnswer((_) async => Response(data: data)); final response = await account.updateEmailVerification( - userId: '', - secret: '', + userId: "", + secret: "", ); expect(response, isA()); }); test('test method updateVerification()', () async { final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', + '\$id': "bb8ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + 'userId': "5e5ea5c168bb8", + 'secret': "", + 'expire': "2020-10-15T06:38:00.000+00:00", + 'phrase': "Golden Fox", }; - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.put), + ).thenAnswer((_) async => Response(data: data)); final response = await account.updateVerification( - userId: '', - secret: '', + userId: "", + secret: "", ); expect(response, isA()); }); test('test method createPhoneVerification()', () async { final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', + '\$id': "bb8ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + 'userId': "5e5ea5c168bb8", + 'secret': "", + 'expire': "2020-10-15T06:38:00.000+00:00", + 'phrase': "Golden Fox", }; - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); final response = await account.createPhoneVerification(); expect(response, isA()); @@ -1480,21 +1490,21 @@ void main() { test('test method updatePhoneVerification()', () async { final Map data = { - '\$id': 'bb8ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c168bb8', - 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00', - 'phrase': 'Golden Fox', + '\$id': "bb8ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + 'userId': "5e5ea5c168bb8", + 'secret': "", + 'expire': "2020-10-15T06:38:00.000+00:00", + 'phrase': "Golden Fox", }; - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.put), + ).thenAnswer((_) async => Response(data: data)); final response = await account.updatePhoneVerification( - userId: '', - secret: '', + userId: "", + secret: "", ); expect(response, isA()); }); diff --git a/test/services/avatars_test.dart b/test/services/avatars_test.dart index 8d2c48fb..835e2951 100644 --- a/test/services/avatars_test.dart +++ b/test/services/avatars_test.dart @@ -10,6 +10,7 @@ import 'package:appwrite/appwrite.dart'; class MockClient extends Mock implements Client { Map config = {'project': 'testproject'}; String endPoint = 'https://localhost/v1'; + @override Future call( HttpMethod? method, { @@ -18,17 +19,18 @@ class MockClient extends Mock implements Client { Map params = const {}, ResponseType? responseType, }) async { - return super.noSuchMethod(Invocation.method(#call, [method]), - returnValue: Response()); + return super.noSuchMethod( + Invocation.method(#call, [method]), + returnValue: Response(), + ); } @override - Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Future webAuth(Uri? url, {String? callbackUrlScheme}) async { + return super.noSuchMethod( + Invocation.method(#webAuth, [url]), + returnValue: 'done', + ); } @override @@ -41,9 +43,15 @@ 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: {}), + ); } } @@ -60,9 +68,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, @@ -73,9 +81,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, @@ -86,12 +94,12 @@ 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', + url: "https://example.com", ); expect(response, isA()); }); @@ -99,9 +107,9 @@ void main() { 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, @@ -112,12 +120,12 @@ void main() { 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', + url: "https://example.com", ); expect(response, isA()); }); @@ -125,23 +133,34 @@ void main() { 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()); }); + test('test method getPhoto()', () async { + final Uint8List data = Uint8List.fromList([]); + + when( + client.call(HttpMethod.get), + ).thenAnswer((_) async => Response(data: data)); + + final response = await avatars.getPhoto(); + expect(response, isA()); + }); + 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: '', + text: "", ); expect(response, isA()); }); @@ -149,12 +168,12 @@ void main() { 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', + url: "https://example.com", ); expect(response, isA()); }); diff --git a/test/services/databases_test.dart b/test/services/databases_test.dart index a3807093..d55be0c4 100644 --- a/test/services/databases_test.dart +++ b/test/services/databases_test.dart @@ -10,6 +10,7 @@ import 'package:appwrite/appwrite.dart'; class MockClient extends Mock implements Client { Map config = {'project': 'testproject'}; String endPoint = 'https://localhost/v1'; + @override Future call( HttpMethod? method, { @@ -18,17 +19,18 @@ class MockClient extends Mock implements Client { Map params = const {}, ResponseType? responseType, }) async { - return super.noSuchMethod(Invocation.method(#call, [method]), - returnValue: Response()); + return super.noSuchMethod( + Invocation.method(#call, [method]), + returnValue: Response(), + ); } @override - Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Future webAuth(Uri? url, {String? callbackUrlScheme}) async { + return super.noSuchMethod( + Invocation.method(#webAuth, [url]), + returnValue: 'done', + ); } @override @@ -41,9 +43,15 @@ 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: {}), + ); } } @@ -63,9 +71,9 @@ void main() { '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()); @@ -73,17 +81,17 @@ void main() { test('test method createTransaction()', () async { final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', + '\$id': "259125845563242502", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'status': "pending", 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', + '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()); @@ -91,40 +99,40 @@ void main() { test('test method getTransaction()', () async { final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', + '\$id': "259125845563242502", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'status': "pending", 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', + '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: '', + transactionId: "", ); expect(response, isA()); }); test('test method updateTransaction()', () async { final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', + '\$id': "259125845563242502", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'status': "pending", 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', + '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: '', + transactionId: "", ); expect(response, isA()); }); @@ -132,31 +140,31 @@ 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: '', + transactionId: "", ); }); test('test method createOperations()', () async { final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', + '\$id': "259125845563242502", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'status': "pending", 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', + '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: '', + transactionId: "", ); expect(response, isA()); }); @@ -167,36 +175,36 @@ void main() { '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: '', - collectionId: '', + databaseId: "", + collectionId: "", ); expect(response, isA()); }); test('test method createDocument()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$id': "5e5ea5c16897e", + '\$sequence': "1", + '\$collectionId': "5e5ea5c15117e", + '\$databaseId': "5e5ea5c15117e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", '\$permissions': [], }; - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); final response = await databases.createDocument( - databaseId: '', - collectionId: '', - documentId: '', + databaseId: "", + collectionId: "", + documentId: "", data: {}, ); expect(response, isA()); @@ -204,69 +212,69 @@ void main() { test('test method getDocument()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$id': "5e5ea5c16897e", + '\$sequence': "1", + '\$collectionId': "5e5ea5c15117e", + '\$databaseId': "5e5ea5c15117e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", '\$permissions': [], }; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.get), + ).thenAnswer((_) async => Response(data: data)); final response = await databases.getDocument( - databaseId: '', - collectionId: '', - documentId: '', + databaseId: "", + collectionId: "", + documentId: "", ); expect(response, isA()); }); test('test method upsertDocument()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$id': "5e5ea5c16897e", + '\$sequence': "1", + '\$collectionId': "5e5ea5c15117e", + '\$databaseId': "5e5ea5c15117e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", '\$permissions': [], }; - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.put), + ).thenAnswer((_) async => Response(data: data)); final response = await databases.upsertDocument( - databaseId: '', - collectionId: '', - documentId: '', + databaseId: "", + collectionId: "", + documentId: "", ); expect(response, isA()); }); test('test method updateDocument()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$id': "5e5ea5c16897e", + '\$sequence': "1", + '\$collectionId': "5e5ea5c15117e", + '\$databaseId': "5e5ea5c15117e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", '\$permissions': [], }; - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.patch), + ).thenAnswer((_) async => Response(data: data)); final response = await databases.updateDocument( - databaseId: '', - collectionId: '', - documentId: '', + databaseId: "", + collectionId: "", + documentId: "", ); expect(response, isA()); }); @@ -274,36 +282,36 @@ 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: '', - collectionId: '', - documentId: '', + databaseId: "", + collectionId: "", + documentId: "", ); }); test('test method decrementDocumentAttribute()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$id': "5e5ea5c16897e", + '\$sequence': "1", + '\$collectionId': "5e5ea5c15117e", + '\$databaseId': "5e5ea5c15117e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", '\$permissions': [], }; - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.patch), + ).thenAnswer((_) async => Response(data: data)); final response = await databases.decrementDocumentAttribute( - databaseId: '', - collectionId: '', - documentId: '', + databaseId: "", + collectionId: "", + documentId: "", attribute: '', ); expect(response, isA()); @@ -311,23 +319,23 @@ void main() { test('test method incrementDocumentAttribute()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$collectionId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$id': "5e5ea5c16897e", + '\$sequence': "1", + '\$collectionId': "5e5ea5c15117e", + '\$databaseId': "5e5ea5c15117e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", '\$permissions': [], }; - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.patch), + ).thenAnswer((_) async => Response(data: data)); final response = await databases.incrementDocumentAttribute( - databaseId: '', - collectionId: '', - documentId: '', + databaseId: "", + collectionId: "", + documentId: "", attribute: '', ); expect(response, isA()); diff --git a/test/services/functions_test.dart b/test/services/functions_test.dart index c6e50a50..aae489d9 100644 --- a/test/services/functions_test.dart +++ b/test/services/functions_test.dart @@ -10,6 +10,7 @@ import 'package:appwrite/appwrite.dart'; class MockClient extends Mock implements Client { Map config = {'project': 'testproject'}; String endPoint = 'https://localhost/v1'; + @override Future call( HttpMethod? method, { @@ -18,17 +19,18 @@ class MockClient extends Mock implements Client { Map params = const {}, ResponseType? responseType, }) async { - return super.noSuchMethod(Invocation.method(#call, [method]), - returnValue: Response()); + return super.noSuchMethod( + Invocation.method(#call, [method]), + returnValue: Response(), + ); } @override - Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Future webAuth(Uri? url, {String? callbackUrlScheme}) async { + return super.noSuchMethod( + Invocation.method(#webAuth, [url]), + returnValue: 'done', + ); } @override @@ -41,9 +43,15 @@ 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: {}), + ); } } @@ -63,75 +71,77 @@ void main() { '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: '', + functionId: "", ); expect(response, isA()); }); test('test method createExecution()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", '\$permissions': [], - 'functionId': '5e5ea6g16897e', - 'deploymentId': '5e5ea5c16897e', - 'trigger': 'http', - 'status': 'processing', - 'requestMethod': 'GET', - 'requestPath': '/articles?id=5', + 'resourceId': "5e5ea6g16897e", + 'resourceType': "functions", + 'deploymentId': "5e5ea5c16897e", + 'trigger': "http", + 'status': "processing", + 'requestMethod': "GET", + 'requestPath': "/articles?id=5", 'requestHeaders': [], 'responseStatusCode': 200, - 'responseBody': '', + 'responseBody': "", 'responseHeaders': [], - 'logs': '', - 'errors': '', + 'logs': "", + 'errors': "", '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: '', + functionId: "", ); expect(response, isA()); }); test('test method getExecution()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", '\$permissions': [], - 'functionId': '5e5ea6g16897e', - 'deploymentId': '5e5ea5c16897e', - 'trigger': 'http', - 'status': 'processing', - 'requestMethod': 'GET', - 'requestPath': '/articles?id=5', + 'resourceId': "5e5ea6g16897e", + 'resourceType': "functions", + 'deploymentId': "5e5ea5c16897e", + 'trigger': "http", + 'status': "processing", + 'requestMethod': "GET", + 'requestPath': "/articles?id=5", 'requestHeaders': [], 'responseStatusCode': 200, - 'responseBody': '', + 'responseBody': "", 'responseHeaders': [], - 'logs': '', - 'errors': '', + 'logs': "", + 'errors': "", '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: '', - executionId: '', + functionId: "", + executionId: "", ); expect(response, isA()); }); diff --git a/test/services/graphql_test.dart b/test/services/graphql_test.dart index 84b7de1c..779767e3 100644 --- a/test/services/graphql_test.dart +++ b/test/services/graphql_test.dart @@ -10,6 +10,7 @@ import 'package:appwrite/appwrite.dart'; class MockClient extends Mock implements Client { Map config = {'project': 'testproject'}; String endPoint = 'https://localhost/v1'; + @override Future call( HttpMethod? method, { @@ -18,17 +19,18 @@ class MockClient extends Mock implements Client { Map params = const {}, ResponseType? responseType, }) async { - return super.noSuchMethod(Invocation.method(#call, [method]), - returnValue: Response()); + return super.noSuchMethod( + Invocation.method(#call, [method]), + returnValue: Response(), + ); } @override - Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Future webAuth(Uri? url, {String? callbackUrlScheme}) async { + return super.noSuchMethod( + Invocation.method(#webAuth, [url]), + returnValue: 'done', + ); } @override @@ -41,9 +43,15 @@ 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: {}), + ); } } @@ -60,9 +68,9 @@ 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: {}, @@ -72,9 +80,9 @@ void main() { 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: {}, diff --git a/test/services/locale_test.dart b/test/services/locale_test.dart index f9f6489d..c9bb5236 100644 --- a/test/services/locale_test.dart +++ b/test/services/locale_test.dart @@ -10,6 +10,7 @@ import 'package:appwrite/appwrite.dart'; class MockClient extends Mock implements Client { Map config = {'project': 'testproject'}; String endPoint = 'https://localhost/v1'; + @override Future call( HttpMethod? method, { @@ -18,17 +19,18 @@ class MockClient extends Mock implements Client { Map params = const {}, ResponseType? responseType, }) async { - return super.noSuchMethod(Invocation.method(#call, [method]), - returnValue: Response()); + return super.noSuchMethod( + Invocation.method(#call, [method]), + returnValue: Response(), + ); } @override - Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Future webAuth(Uri? url, {String? callbackUrlScheme}) async { + return super.noSuchMethod( + Invocation.method(#webAuth, [url]), + returnValue: 'done', + ); } @override @@ -41,9 +43,15 @@ 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: {}), + ); } } @@ -59,18 +67,18 @@ void main() { test('test method get()', () async { final Map data = { - 'ip': '127.0.0.1', - 'countryCode': 'US', - 'country': 'United States', - 'continentCode': 'NA', - 'continent': 'North America', + 'ip': "127.0.0.1", + 'countryCode': "US", + 'country': "United States", + 'continentCode': "NA", + 'continent': "North America", 'eu': true, - 'currency': 'USD', + '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()); @@ -82,9 +90,9 @@ void main() { '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()); @@ -96,9 +104,9 @@ void main() { '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()); @@ -110,9 +118,9 @@ void main() { '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()); @@ -124,9 +132,9 @@ void main() { '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()); @@ -138,9 +146,9 @@ void main() { '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()); @@ -152,9 +160,9 @@ void main() { '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()); @@ -166,9 +174,9 @@ void main() { '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 0c938eff..823af01e 100644 --- a/test/services/messaging_test.dart +++ b/test/services/messaging_test.dart @@ -10,6 +10,7 @@ import 'package:appwrite/appwrite.dart'; class MockClient extends Mock implements Client { Map config = {'project': 'testproject'}; String endPoint = 'https://localhost/v1'; + @override Future call( HttpMethod? method, { @@ -18,17 +19,18 @@ class MockClient extends Mock implements Client { Map params = const {}, ResponseType? responseType, }) async { - return super.noSuchMethod(Invocation.method(#call, [method]), - returnValue: Response()); + return super.noSuchMethod( + Invocation.method(#call, [method]), + returnValue: Response(), + ); } @override - Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Future webAuth(Uri? url, {String? callbackUrlScheme}) async { + return super.noSuchMethod( + Invocation.method(#webAuth, [url]), + returnValue: 'done', + ); } @override @@ -41,9 +43,15 @@ 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: {}), + ); } } @@ -59,34 +67,34 @@ void main() { test('test method createSubscriber()', () async { final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'targetId': '259125845563242502', + '\$id': "259125845563242502", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'targetId': "259125845563242502", 'target': { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'Apple iPhone 12', - 'userId': '259125845563242502', - 'providerType': 'email', - 'identifier': 'token', + '\$id': "259125845563242502", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "Apple iPhone 12", + 'userId': "259125845563242502", + 'providerType': "email", + 'identifier': "token", 'expired': true, }, - 'userId': '5e5ea5c16897e', - 'userName': 'Aegon Targaryen', - 'topicId': '259125845563242502', - 'providerType': 'email', + 'userId': "5e5ea5c16897e", + 'userName': "Aegon Targaryen", + 'topicId': "259125845563242502", + '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: '', - subscriberId: '', - targetId: '', + topicId: "", + subscriberId: "", + targetId: "", ); expect(response, isA()); }); @@ -94,13 +102,13 @@ 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: '', - subscriberId: '', + topicId: "", + subscriberId: "", ); }); }); diff --git a/test/services/organization_test.dart b/test/services/organization_test.dart index 00455d84..a6ea2c70 100644 --- a/test/services/organization_test.dart +++ b/test/services/organization_test.dart @@ -10,6 +10,7 @@ import 'package:appwrite/appwrite.dart'; class MockClient extends Mock implements Client { Map config = {'project': 'testproject'}; String endPoint = 'https://localhost/v1'; + @override Future call( HttpMethod? method, { @@ -18,17 +19,18 @@ class MockClient extends Mock implements Client { Map params = const {}, ResponseType? responseType, }) async { - return super.noSuchMethod(Invocation.method(#call, [method]), - returnValue: Response()); + return super.noSuchMethod( + Invocation.method(#call, [method]), + returnValue: Response(), + ); } @override - Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Future webAuth(Uri? url, {String? callbackUrlScheme}) async { + return super.noSuchMethod( + Invocation.method(#webAuth, [url]), + returnValue: 'done', + ); } @override @@ -41,9 +43,15 @@ 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: {}), + ); } } @@ -63,9 +71,9 @@ void main() { 'installations': [], }; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.get), + ).thenAnswer((_) async => Response(data: data)); final response = await organization.listInstallations(); expect(response, isA()); @@ -73,69 +81,69 @@ void main() { test('test method createInstallation()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'appId': '5e5ea5c16897e', - 'teamId': '5e5ea5c16897e', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'appId': "5e5ea5c16897e", + 'teamId': "5e5ea5c16897e", 'scopes': [], - 'authorizationDetails': {}, - 'createdById': '5e5ea5c16897e', - 'createdByName': 'Walter White', + 'authorizationDetails': [], + 'createdById': "5e5ea5c16897e", + 'createdByName': "Walter White", }; - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); final response = await organization.createInstallation( - appId: '', + appId: "", ); expect(response, isA()); }); test('test method getInstallation()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'appId': '5e5ea5c16897e', - 'teamId': '5e5ea5c16897e', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'appId': "5e5ea5c16897e", + 'teamId': "5e5ea5c16897e", 'scopes': [], - 'authorizationDetails': {}, - 'createdById': '5e5ea5c16897e', - 'createdByName': 'Walter White', + 'authorizationDetails': [], + 'createdById': "5e5ea5c16897e", + 'createdByName': "Walter White", }; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.get), + ).thenAnswer((_) async => Response(data: data)); final response = await organization.getInstallation( - installationId: '', + installationId: "", ); expect(response, isA()); }); test('test method updateInstallation()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'appId': '5e5ea5c16897e', - 'teamId': '5e5ea5c16897e', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'appId': "5e5ea5c16897e", + 'teamId': "5e5ea5c16897e", 'scopes': [], - 'authorizationDetails': {}, - 'createdById': '5e5ea5c16897e', - 'createdByName': 'Walter White', + 'authorizationDetails': [], + 'createdById': "5e5ea5c16897e", + 'createdByName': "Walter White", }; - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.put), + ).thenAnswer((_) async => Response(data: data)); final response = await organization.updateInstallation( - installationId: '', + installationId: "", ); expect(response, isA()); }); @@ -143,12 +151,12 @@ void main() { test('test method deleteInstallation()', () 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 organization.deleteInstallation( - installationId: '', + installationId: "", ); }); }); diff --git a/test/services/presences_test.dart b/test/services/presences_test.dart index 7fed0439..9de09725 100644 --- a/test/services/presences_test.dart +++ b/test/services/presences_test.dart @@ -10,6 +10,7 @@ import 'package:appwrite/appwrite.dart'; class MockClient extends Mock implements Client { Map config = {'project': 'testproject'}; String endPoint = 'https://localhost/v1'; + @override Future call( HttpMethod? method, { @@ -18,17 +19,18 @@ class MockClient extends Mock implements Client { Map params = const {}, ResponseType? responseType, }) async { - return super.noSuchMethod(Invocation.method(#call, [method]), - returnValue: Response()); + return super.noSuchMethod( + Invocation.method(#call, [method]), + returnValue: Response(), + ); } @override - Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Future webAuth(Uri? url, {String? callbackUrlScheme}) async { + return super.noSuchMethod( + Invocation.method(#webAuth, [url]), + returnValue: 'done', + ); } @override @@ -41,9 +43,15 @@ 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: {}), + ); } } @@ -63,9 +71,9 @@ void main() { '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()); @@ -73,61 +81,61 @@ void main() { test('test method get()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", '\$permissions': [], - 'userId': '674af8f3e12a5f9ac0be', - 'source': 'HTTP', + 'userId': "674af8f3e12a5f9ac0be", + '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: '', + presenceId: "", ); expect(response, isA()); }); test('test method upsert()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", '\$permissions': [], - 'userId': '674af8f3e12a5f9ac0be', - 'source': 'HTTP', + 'userId': "674af8f3e12a5f9ac0be", + '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: '', - status: '', + presenceId: "", + status: "", ); expect(response, isA()); }); test('test method update()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", '\$permissions': [], - 'userId': '674af8f3e12a5f9ac0be', - 'source': 'HTTP', + 'userId': "674af8f3e12a5f9ac0be", + '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: '', + presenceId: "", ); expect(response, isA()); }); @@ -135,12 +143,12 @@ 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 presences.delete( - presenceId: '', + presenceId: "", ); }); }); diff --git a/test/services/storage_test.dart b/test/services/storage_test.dart index 9ee2b2c2..92d858ee 100644 --- a/test/services/storage_test.dart +++ b/test/services/storage_test.dart @@ -10,6 +10,7 @@ import 'package:appwrite/appwrite.dart'; class MockClient extends Mock implements Client { Map config = {'project': 'testproject'}; String endPoint = 'https://localhost/v1'; + @override Future call( HttpMethod? method, { @@ -18,17 +19,18 @@ class MockClient extends Mock implements Client { Map params = const {}, ResponseType? responseType, }) async { - return super.noSuchMethod(Invocation.method(#call, [method]), - returnValue: Response()); + return super.noSuchMethod( + Invocation.method(#call, [method]), + returnValue: Response(), + ); } @override - Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Future webAuth(Uri? url, {String? callbackUrlScheme}) async { + return super.noSuchMethod( + Invocation.method(#webAuth, [url]), + returnValue: 'done', + ); } @override @@ -41,9 +43,15 @@ 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: {}), + ); } } @@ -63,47 +71,49 @@ void main() { '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: '', + bucketId: "", ); expect(response, isA()); }); test('test method createFile()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - 'bucketId': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$id': "5e5ea5c16897e", + 'bucketId': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", '\$permissions': [], - 'name': 'Pink.png', - 'folder': 'photos/2026/', - 'key': 'photos/2026/Pink.png', - 'signature': '5d529fd02b544198ae075bd57c1762bb', - 'mimeType': 'image/png', + 'name': "Pink.png", + 'folder': "photos/2026/", + 'key': "photos/2026/Pink.png", + 'signature': "5d529fd02b544198ae075bd57c1762bb", + 'mimeType': "image/png", 'sizeOriginal': 17890, 'sizeActual': 12345, 'chunksTotal': 17890, 'chunksUploaded': 17890, 'encryption': true, - 'compression': 'gzip', + '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: '', - fileId: '', + bucketId: "", + fileId: "", file: InputFile.fromPath(path: './image.png'), ); expect(response, isA()); @@ -111,62 +121,62 @@ void main() { test('test method getFile()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - 'bucketId': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$id': "5e5ea5c16897e", + 'bucketId': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", '\$permissions': [], - 'name': 'Pink.png', - 'folder': 'photos/2026/', - 'key': 'photos/2026/Pink.png', - 'signature': '5d529fd02b544198ae075bd57c1762bb', - 'mimeType': 'image/png', + 'name': "Pink.png", + 'folder': "photos/2026/", + 'key': "photos/2026/Pink.png", + 'signature': "5d529fd02b544198ae075bd57c1762bb", + 'mimeType': "image/png", 'sizeOriginal': 17890, 'sizeActual': 12345, 'chunksTotal': 17890, 'chunksUploaded': 17890, 'encryption': true, - 'compression': 'gzip', + '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: '', - fileId: '', + bucketId: "", + fileId: "", ); expect(response, isA()); }); test('test method updateFile()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - 'bucketId': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$id': "5e5ea5c16897e", + 'bucketId': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", '\$permissions': [], - 'name': 'Pink.png', - 'folder': 'photos/2026/', - 'key': 'photos/2026/Pink.png', - 'signature': '5d529fd02b544198ae075bd57c1762bb', - 'mimeType': 'image/png', + 'name': "Pink.png", + 'folder': "photos/2026/", + 'key': "photos/2026/Pink.png", + 'signature': "5d529fd02b544198ae075bd57c1762bb", + 'mimeType': "image/png", 'sizeOriginal': 17890, 'sizeActual': 12345, 'chunksTotal': 17890, 'chunksUploaded': 17890, 'encryption': true, - 'compression': 'gzip', + '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: '', - fileId: '', + bucketId: "", + fileId: "", ); expect(response, isA()); }); @@ -174,26 +184,26 @@ 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: '', - fileId: '', + bucketId: "", + fileId: "", ); }); 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: '', - fileId: '', + bucketId: "", + fileId: "", ); expect(response, isA()); }); @@ -201,13 +211,13 @@ 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: '', - fileId: '', + bucketId: "", + fileId: "", ); expect(response, isA()); }); @@ -215,13 +225,13 @@ 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: '', - fileId: '', + bucketId: "", + fileId: "", ); expect(response, isA()); }); diff --git a/test/services/tables_db_test.dart b/test/services/tables_db_test.dart index f318cad2..9cf7d024 100644 --- a/test/services/tables_db_test.dart +++ b/test/services/tables_db_test.dart @@ -10,6 +10,7 @@ import 'package:appwrite/appwrite.dart'; class MockClient extends Mock implements Client { Map config = {'project': 'testproject'}; String endPoint = 'https://localhost/v1'; + @override Future call( HttpMethod? method, { @@ -18,17 +19,18 @@ class MockClient extends Mock implements Client { Map params = const {}, ResponseType? responseType, }) async { - return super.noSuchMethod(Invocation.method(#call, [method]), - returnValue: Response()); + return super.noSuchMethod( + Invocation.method(#call, [method]), + returnValue: Response(), + ); } @override - Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Future webAuth(Uri? url, {String? callbackUrlScheme}) async { + return super.noSuchMethod( + Invocation.method(#webAuth, [url]), + returnValue: 'done', + ); } @override @@ -41,9 +43,15 @@ 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: {}), + ); } } @@ -63,9 +71,9 @@ void main() { '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()); @@ -73,17 +81,17 @@ void main() { test('test method createTransaction()', () async { final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', + '\$id': "259125845563242502", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'status': "pending", 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', + '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()); @@ -91,40 +99,40 @@ void main() { test('test method getTransaction()', () async { final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', + '\$id': "259125845563242502", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'status': "pending", 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', + '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: '', + transactionId: "", ); expect(response, isA()); }); test('test method updateTransaction()', () async { final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', + '\$id': "259125845563242502", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'status': "pending", 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', + '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: '', + transactionId: "", ); expect(response, isA()); }); @@ -132,31 +140,31 @@ 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: '', + transactionId: "", ); }); test('test method createOperations()', () async { final Map data = { - '\$id': '259125845563242502', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'status': 'pending', + '\$id': "259125845563242502", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'status': "pending", 'operations': 5, - 'expiresAt': '2020-10-15T06:38:00.000+00:00', + '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: '', + transactionId: "", ); expect(response, isA()); }); @@ -167,36 +175,36 @@ void main() { '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: '', - tableId: '', + databaseId: "", + tableId: "", ); expect(response, isA()); }); test('test method createRow()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$id': "5e5ea5c16897e", + '\$sequence': "1", + '\$tableId': "5e5ea5c15117e", + '\$databaseId': "5e5ea5c15117e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", '\$permissions': [], }; - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); final response = await tablesDB.createRow( - databaseId: '', - tableId: '', - rowId: '', + databaseId: "", + tableId: "", + rowId: "", data: {}, ); expect(response, isA()); @@ -204,69 +212,69 @@ void main() { test('test method getRow()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$id': "5e5ea5c16897e", + '\$sequence': "1", + '\$tableId': "5e5ea5c15117e", + '\$databaseId': "5e5ea5c15117e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", '\$permissions': [], }; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.get), + ).thenAnswer((_) async => Response(data: data)); final response = await tablesDB.getRow( - databaseId: '', - tableId: '', - rowId: '', + databaseId: "", + tableId: "", + rowId: "", ); expect(response, isA()); }); test('test method upsertRow()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$id': "5e5ea5c16897e", + '\$sequence': "1", + '\$tableId': "5e5ea5c15117e", + '\$databaseId': "5e5ea5c15117e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", '\$permissions': [], }; - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.put), + ).thenAnswer((_) async => Response(data: data)); final response = await tablesDB.upsertRow( - databaseId: '', - tableId: '', - rowId: '', + databaseId: "", + tableId: "", + rowId: "", ); expect(response, isA()); }); test('test method updateRow()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$id': "5e5ea5c16897e", + '\$sequence': "1", + '\$tableId': "5e5ea5c15117e", + '\$databaseId': "5e5ea5c15117e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", '\$permissions': [], }; - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.patch), + ).thenAnswer((_) async => Response(data: data)); final response = await tablesDB.updateRow( - databaseId: '', - tableId: '', - rowId: '', + databaseId: "", + tableId: "", + rowId: "", ); expect(response, isA()); }); @@ -274,36 +282,36 @@ 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: '', - tableId: '', - rowId: '', + databaseId: "", + tableId: "", + rowId: "", ); }); test('test method decrementRowColumn()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$id': "5e5ea5c16897e", + '\$sequence': "1", + '\$tableId': "5e5ea5c15117e", + '\$databaseId': "5e5ea5c15117e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", '\$permissions': [], }; - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.patch), + ).thenAnswer((_) async => Response(data: data)); final response = await tablesDB.decrementRowColumn( - databaseId: '', - tableId: '', - rowId: '', + databaseId: "", + tableId: "", + rowId: "", column: '', ); expect(response, isA()); @@ -311,23 +319,23 @@ void main() { test('test method incrementRowColumn()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$sequence': '1', - '\$tableId': '5e5ea5c15117e', - '\$databaseId': '5e5ea5c15117e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$id': "5e5ea5c16897e", + '\$sequence': "1", + '\$tableId': "5e5ea5c15117e", + '\$databaseId': "5e5ea5c15117e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", '\$permissions': [], }; - when(client.call( - HttpMethod.patch, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.patch), + ).thenAnswer((_) async => Response(data: data)); final response = await tablesDB.incrementRowColumn( - databaseId: '', - tableId: '', - rowId: '', + databaseId: "", + tableId: "", + rowId: "", column: '', ); expect(response, isA()); diff --git a/test/services/teams_test.dart b/test/services/teams_test.dart index d308ebe3..cafe8858 100644 --- a/test/services/teams_test.dart +++ b/test/services/teams_test.dart @@ -10,6 +10,7 @@ import 'package:appwrite/appwrite.dart'; class MockClient extends Mock implements Client { Map config = {'project': 'testproject'}; String endPoint = 'https://localhost/v1'; + @override Future call( HttpMethod? method, { @@ -18,17 +19,18 @@ class MockClient extends Mock implements Client { Map params = const {}, ResponseType? responseType, }) async { - return super.noSuchMethod(Invocation.method(#call, [method]), - returnValue: Response()); + return super.noSuchMethod( + Invocation.method(#call, [method]), + returnValue: Response(), + ); } @override - Future webAuth( - Uri? url, { - String? callbackUrlScheme, - }) async { - return super - .noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + Future webAuth(Uri? url, {String? callbackUrlScheme}) async { + return super.noSuchMethod( + Invocation.method(#webAuth, [url]), + returnValue: 'done', + ); } @override @@ -41,9 +43,15 @@ 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: {}), + ); } } @@ -63,9 +71,9 @@ void main() { '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()); @@ -73,62 +81,62 @@ void main() { test('test method create()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'VIP', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "VIP", 'total': 7, 'prefs': {}, }; - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); final response = await teams.create( - teamId: '', - name: '', + teamId: "", + name: "", ); expect(response, isA()); }); test('test method get()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'VIP', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "VIP", 'total': 7, 'prefs': {}, }; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.get), + ).thenAnswer((_) async => Response(data: data)); final response = await teams.get( - teamId: '', + teamId: "", ); expect(response, isA()); }); test('test method updateName()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'name': 'VIP', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "VIP", 'total': 7, 'prefs': {}, }; - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.put), + ).thenAnswer((_) async => Response(data: data)); final response = await teams.updateName( - teamId: '', - name: '', + teamId: "", + name: "", ); expect(response, isA()); }); @@ -136,12 +144,12 @@ 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: '', + teamId: "", ); }); @@ -151,84 +159,84 @@ void main() { 'installations': [], }; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.get), + ).thenAnswer((_) async => Response(data: data)); final response = await teams.listInstallations( - teamId: '', + teamId: "", ); expect(response, isA()); }); test('test method createInstallation()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'appId': '5e5ea5c16897e', - 'teamId': '5e5ea5c16897e', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'appId': "5e5ea5c16897e", + 'teamId': "5e5ea5c16897e", 'scopes': [], - 'authorizationDetails': {}, - 'createdById': '5e5ea5c16897e', - 'createdByName': 'Walter White', + 'authorizationDetails': [], + 'createdById': "5e5ea5c16897e", + 'createdByName': "Walter White", }; - when(client.call( - HttpMethod.post, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); final response = await teams.createInstallation( - teamId: '', - appId: '', + teamId: "", + appId: "", ); expect(response, isA()); }); test('test method getInstallation()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'appId': '5e5ea5c16897e', - 'teamId': '5e5ea5c16897e', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'appId': "5e5ea5c16897e", + 'teamId': "5e5ea5c16897e", 'scopes': [], - 'authorizationDetails': {}, - 'createdById': '5e5ea5c16897e', - 'createdByName': 'Walter White', + 'authorizationDetails': [], + 'createdById': "5e5ea5c16897e", + 'createdByName': "Walter White", }; - when(client.call( - HttpMethod.get, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.get), + ).thenAnswer((_) async => Response(data: data)); final response = await teams.getInstallation( - teamId: '', - installationId: '', + teamId: "", + installationId: "", ); expect(response, isA()); }); test('test method updateInstallation()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'appId': '5e5ea5c16897e', - 'teamId': '5e5ea5c16897e', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'appId': "5e5ea5c16897e", + 'teamId': "5e5ea5c16897e", 'scopes': [], - 'authorizationDetails': {}, - 'createdById': '5e5ea5c16897e', - 'createdByName': 'Walter White', + 'authorizationDetails': [], + 'createdById': "5e5ea5c16897e", + 'createdByName': "Walter White", }; - when(client.call( - HttpMethod.put, - )).thenAnswer((_) async => Response(data: data)); + when( + client.call(HttpMethod.put), + ).thenAnswer((_) async => Response(data: data)); final response = await teams.updateInstallation( - teamId: '', - installationId: '', + teamId: "", + installationId: "", ); expect(response, isA()); }); @@ -236,13 +244,13 @@ void main() { test('test method deleteInstallation()', () 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.deleteInstallation( - teamId: '', - installationId: '', + teamId: "", + installationId: "", ); }); @@ -252,41 +260,41 @@ void main() { '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: '', + teamId: "", ); expect(response, isA()); }); test('test method createMembership()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'userId': "5e5ea5c16897e", + 'userName': "John Doe", + 'userEmail': "john@appwrite.io", + 'userPhone': "+1 555 555 5555", + 'teamId': "5e5ea5c16897e", + 'teamName': "VIP", + 'invited': "2020-10-15T06:38:00.000+00:00", + 'joined': "2020-10-15T06:38:00.000+00:00", 'confirm': true, 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'userAccessedAt': "2020-10-15T06:38:00.000+00:00", '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: '', + teamId: "", roles: [], ); expect(response, isA()); @@ -294,60 +302,60 @@ void main() { test('test method getMembership()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'userId': "5e5ea5c16897e", + 'userName': "John Doe", + 'userEmail': "john@appwrite.io", + 'userPhone': "+1 555 555 5555", + 'teamId': "5e5ea5c16897e", + 'teamName': "VIP", + 'invited': "2020-10-15T06:38:00.000+00:00", + 'joined': "2020-10-15T06:38:00.000+00:00", 'confirm': true, 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'userAccessedAt': "2020-10-15T06:38:00.000+00:00", '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: '', - membershipId: '', + teamId: "", + membershipId: "", ); expect(response, isA()); }); test('test method updateMembership()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'userId': "5e5ea5c16897e", + 'userName': "John Doe", + 'userEmail': "john@appwrite.io", + 'userPhone': "+1 555 555 5555", + 'teamId': "5e5ea5c16897e", + 'teamName': "VIP", + 'invited': "2020-10-15T06:38:00.000+00:00", + 'joined': "2020-10-15T06:38:00.000+00:00", 'confirm': true, 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'userAccessedAt': "2020-10-15T06:38:00.000+00:00", '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: '', - membershipId: '', + teamId: "", + membershipId: "", roles: [], ); expect(response, isA()); @@ -356,44 +364,44 @@ 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: '', - membershipId: '', + teamId: "", + membershipId: "", ); }); test('test method updateMembershipStatus()', () async { final Map data = { - '\$id': '5e5ea5c16897e', - '\$createdAt': '2020-10-15T06:38:00.000+00:00', - '\$updatedAt': '2020-10-15T06:38:00.000+00:00', - 'userId': '5e5ea5c16897e', - 'userName': 'John Doe', - 'userEmail': 'john@appwrite.io', - 'userPhone': '+1 555 555 5555', - 'teamId': '5e5ea5c16897e', - 'teamName': 'VIP', - 'invited': '2020-10-15T06:38:00.000+00:00', - 'joined': '2020-10-15T06:38:00.000+00:00', + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'userId': "5e5ea5c16897e", + 'userName': "John Doe", + 'userEmail': "john@appwrite.io", + 'userPhone': "+1 555 555 5555", + 'teamId': "5e5ea5c16897e", + 'teamName': "VIP", + 'invited': "2020-10-15T06:38:00.000+00:00", + 'joined': "2020-10-15T06:38:00.000+00:00", 'confirm': true, 'mfa': true, - 'userAccessedAt': '2020-10-15T06:38:00.000+00:00', + 'userAccessedAt': "2020-10-15T06:38:00.000+00:00", '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: '', - membershipId: '', - userId: '', - secret: '', + teamId: "", + membershipId: "", + userId: "", + secret: "", ); expect(response, isA()); }); @@ -401,12 +409,12 @@ 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: '', + teamId: "", ); expect(response, isA()); }); @@ -414,12 +422,12 @@ void main() { 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: '', + teamId: "", prefs: {}, ); expect(response, isA()); diff --git a/test/src/input_file_test.dart b/test/src/input_file_test.dart index 3d301a85..046fa07b 100644 --- a/test/src/input_file_test.dart +++ b/test/src/input_file_test.dart @@ -7,22 +7,26 @@ void main() { test('throws exception when neither path nor bytes are provided', () { expect( () => InputFile(), - throwsA(isA().having( - (e) => e.message, - 'message', - 'One of `path` or `bytes` is required', - )), + throwsA( + isA().having( + (e) => e.message, + 'message', + 'One of `path` or `bytes` is required', + ), + ), ); }); test('throws exception when path and bytes are both null', () { expect( () => InputFile(path: null, bytes: null), - throwsA(isA().having( - (e) => e.message, - 'message', - 'One of `path` or `bytes` is required', - )), + throwsA( + isA().having( + (e) => e.message, + 'message', + 'One of `path` or `bytes` is required', + ), + ), ); }); diff --git a/test/src/models/algo_argon2_test.dart b/test/src/models/algo_argon2_test.dart index 261daa46..81f535b4 100644 --- a/test/src/models/algo_argon2_test.dart +++ b/test/src/models/algo_argon2_test.dart @@ -5,7 +5,7 @@ void main() { group('AlgoArgon2', () { test('model', () { final model = AlgoArgon2( - type: 'argon2', + type: "argon2", memoryCost: 65536, timeCost: 4, threads: 3, @@ -14,7 +14,7 @@ void main() { final map = model.toMap(); final result = AlgoArgon2.fromMap(map); - expect(result.type, 'argon2'); + expect(result.type, "argon2"); expect(result.memoryCost, 65536); expect(result.timeCost, 4); expect(result.threads, 3); diff --git a/test/src/models/algo_bcrypt_test.dart b/test/src/models/algo_bcrypt_test.dart index 3da36624..4cb547df 100644 --- a/test/src/models/algo_bcrypt_test.dart +++ b/test/src/models/algo_bcrypt_test.dart @@ -5,13 +5,13 @@ void main() { group('AlgoBcrypt', () { test('model', () { final model = AlgoBcrypt( - type: 'bcrypt', + type: "bcrypt", ); final map = model.toMap(); final result = AlgoBcrypt.fromMap(map); - expect(result.type, 'bcrypt'); + expect(result.type, "bcrypt"); }); }); } diff --git a/test/src/models/algo_md5_test.dart b/test/src/models/algo_md5_test.dart index e58fa5b5..32269c90 100644 --- a/test/src/models/algo_md5_test.dart +++ b/test/src/models/algo_md5_test.dart @@ -5,13 +5,13 @@ void main() { group('AlgoMd5', () { test('model', () { final model = AlgoMd5( - type: 'md5', + type: "md5", ); final map = model.toMap(); final result = AlgoMd5.fromMap(map); - expect(result.type, 'md5'); + expect(result.type, "md5"); }); }); } diff --git a/test/src/models/algo_phpass_test.dart b/test/src/models/algo_phpass_test.dart index 3bcbb488..91f96ed6 100644 --- a/test/src/models/algo_phpass_test.dart +++ b/test/src/models/algo_phpass_test.dart @@ -5,13 +5,13 @@ void main() { group('AlgoPhpass', () { test('model', () { final model = AlgoPhpass( - type: 'phpass', + type: "phpass", ); final map = model.toMap(); final result = AlgoPhpass.fromMap(map); - expect(result.type, 'phpass'); + expect(result.type, "phpass"); }); }); } diff --git a/test/src/models/algo_scrypt_modified_test.dart b/test/src/models/algo_scrypt_modified_test.dart index b2084927..2e705994 100644 --- a/test/src/models/algo_scrypt_modified_test.dart +++ b/test/src/models/algo_scrypt_modified_test.dart @@ -5,21 +5,23 @@ void main() { group('AlgoScryptModified', () { test('model', () { final model = AlgoScryptModified( - type: 'scryptMod', - salt: 'UxLMreBr6tYyjQ==', - saltSeparator: 'Bw==', + type: "scryptMod", + salt: "UxLMreBr6tYyjQ==", + saltSeparator: "Bw==", signerKey: - 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ==', + "XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ==", ); final map = model.toMap(); final result = AlgoScryptModified.fromMap(map); - expect(result.type, 'scryptMod'); - expect(result.salt, 'UxLMreBr6tYyjQ=='); - expect(result.saltSeparator, 'Bw=='); - expect(result.signerKey, - 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ=='); + expect(result.type, "scryptMod"); + expect(result.salt, "UxLMreBr6tYyjQ=="); + expect(result.saltSeparator, "Bw=="); + expect( + result.signerKey, + "XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ==", + ); }); }); } diff --git a/test/src/models/algo_scrypt_test.dart b/test/src/models/algo_scrypt_test.dart index 8c131568..bb3d38b7 100644 --- a/test/src/models/algo_scrypt_test.dart +++ b/test/src/models/algo_scrypt_test.dart @@ -5,7 +5,7 @@ void main() { group('AlgoScrypt', () { test('model', () { final model = AlgoScrypt( - type: 'scrypt', + type: "scrypt", costCpu: 8, costMemory: 14, costParallel: 1, @@ -15,7 +15,7 @@ void main() { final map = model.toMap(); final result = AlgoScrypt.fromMap(map); - expect(result.type, 'scrypt'); + expect(result.type, "scrypt"); expect(result.costCpu, 8); expect(result.costMemory, 14); expect(result.costParallel, 1); diff --git a/test/src/models/algo_sha_test.dart b/test/src/models/algo_sha_test.dart index d080569c..bb795319 100644 --- a/test/src/models/algo_sha_test.dart +++ b/test/src/models/algo_sha_test.dart @@ -5,13 +5,13 @@ void main() { group('AlgoSha', () { test('model', () { final model = AlgoSha( - type: 'sha', + type: "sha", ); final map = model.toMap(); final result = AlgoSha.fromMap(map); - expect(result.type, 'sha'); + expect(result.type, "sha"); }); }); } diff --git a/test/src/models/app_installation_test.dart b/test/src/models/app_installation_test.dart index dc0ec63c..25cf249e 100644 --- a/test/src/models/app_installation_test.dart +++ b/test/src/models/app_installation_test.dart @@ -5,29 +5,29 @@ void main() { group('AppInstallation', () { test('model', () { final model = AppInstallation( - $id: '5e5ea5c16897e', - $createdAt: '2020-10-15T06:38:00.000+00:00', - $updatedAt: '2020-10-15T06:38:00.000+00:00', - appId: '5e5ea5c16897e', - teamId: '5e5ea5c16897e', + $id: "5e5ea5c16897e", + $createdAt: "2020-10-15T06:38:00.000+00:00", + $updatedAt: "2020-10-15T06:38:00.000+00:00", + appId: "5e5ea5c16897e", + teamId: "5e5ea5c16897e", scopes: [], - authorizationDetails: {}, - createdById: '5e5ea5c16897e', - createdByName: 'Walter White', + authorizationDetails: [], + createdById: "5e5ea5c16897e", + createdByName: "Walter White", ); final map = model.toMap(); final result = AppInstallation.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.appId, '5e5ea5c16897e'); - expect(result.teamId, '5e5ea5c16897e'); + expect(result.$id, "5e5ea5c16897e"); + expect(result.$createdAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.$updatedAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.appId, "5e5ea5c16897e"); + expect(result.teamId, "5e5ea5c16897e"); expect(result.scopes, []); - expect(result.authorizationDetails, {}); - expect(result.createdById, '5e5ea5c16897e'); - expect(result.createdByName, 'Walter White'); + expect(result.authorizationDetails, []); + expect(result.createdById, "5e5ea5c16897e"); + expect(result.createdByName, "Walter White"); }); }); } diff --git a/test/src/models/continent_test.dart b/test/src/models/continent_test.dart index 85e559f5..8aa95758 100644 --- a/test/src/models/continent_test.dart +++ b/test/src/models/continent_test.dart @@ -5,15 +5,15 @@ void main() { group('Continent', () { test('model', () { final model = Continent( - name: 'Europe', - code: 'EU', + name: "Europe", + code: "EU", ); final map = model.toMap(); final result = Continent.fromMap(map); - expect(result.name, 'Europe'); - expect(result.code, 'EU'); + expect(result.name, "Europe"); + expect(result.code, "EU"); }); }); } diff --git a/test/src/models/country_test.dart b/test/src/models/country_test.dart index d5404a7f..73617834 100644 --- a/test/src/models/country_test.dart +++ b/test/src/models/country_test.dart @@ -5,15 +5,15 @@ void main() { group('Country', () { test('model', () { final model = Country( - name: 'United States', - code: 'US', + name: "United States", + code: "US", ); final map = model.toMap(); final result = Country.fromMap(map); - expect(result.name, 'United States'); - expect(result.code, 'US'); + expect(result.name, "United States"); + expect(result.code, "US"); }); }); } diff --git a/test/src/models/currency_test.dart b/test/src/models/currency_test.dart index 00e046c7..b7761a5c 100644 --- a/test/src/models/currency_test.dart +++ b/test/src/models/currency_test.dart @@ -5,25 +5,25 @@ void main() { group('Currency', () { test('model', () { final model = Currency( - symbol: '\$', - name: 'US dollar', - symbolNative: '\$', + symbol: "\$", + name: "US dollar", + symbolNative: "\$", decimalDigits: 2, rounding: 0, - code: 'USD', - namePlural: 'US dollars', + code: "USD", + namePlural: "US dollars", ); final map = model.toMap(); final result = Currency.fromMap(map); - expect(result.symbol, '\$'); - expect(result.name, 'US dollar'); - expect(result.symbolNative, '\$'); + expect(result.symbol, "\$"); + expect(result.name, "US dollar"); + expect(result.symbolNative, "\$"); expect(result.decimalDigits, 2); expect(result.rounding, 0); - expect(result.code, 'USD'); - expect(result.namePlural, 'US dollars'); + expect(result.code, "USD"); + expect(result.namePlural, "US dollars"); }); }); } diff --git a/test/src/models/document_test.dart b/test/src/models/document_test.dart index 397b5fab..158af251 100644 --- a/test/src/models/document_test.dart +++ b/test/src/models/document_test.dart @@ -5,12 +5,12 @@ void main() { group('Document', () { test('model', () { final model = Document( - $id: '5e5ea5c16897e', - $sequence: '1', - $collectionId: '5e5ea5c15117e', - $databaseId: '5e5ea5c15117e', - $createdAt: '2020-10-15T06:38:00.000+00:00', - $updatedAt: '2020-10-15T06:38:00.000+00:00', + $id: "5e5ea5c16897e", + $sequence: "1", + $collectionId: "5e5ea5c15117e", + $databaseId: "5e5ea5c15117e", + $createdAt: "2020-10-15T06:38:00.000+00:00", + $updatedAt: "2020-10-15T06:38:00.000+00:00", $permissions: [], data: {}, ); @@ -18,12 +18,12 @@ void main() { final map = model.toMap(); final result = Document.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$sequence, '1'); - expect(result.$collectionId, '5e5ea5c15117e'); - expect(result.$databaseId, '5e5ea5c15117e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$id, "5e5ea5c16897e"); + expect(result.$sequence, "1"); + expect(result.$collectionId, "5e5ea5c15117e"); + expect(result.$databaseId, "5e5ea5c15117e"); + expect(result.$createdAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.$updatedAt, "2020-10-15T06:38:00.000+00:00"); expect(result.$permissions, []); }); }); diff --git a/test/src/models/execution_test.dart b/test/src/models/execution_test.dart index 80ef508a..15955b9a 100644 --- a/test/src/models/execution_test.dart +++ b/test/src/models/execution_test.dart @@ -6,44 +6,46 @@ void main() { group('Execution', () { test('model', () { final model = Execution( - $id: '5e5ea5c16897e', - $createdAt: '2020-10-15T06:38:00.000+00:00', - $updatedAt: '2020-10-15T06:38:00.000+00:00', + $id: "5e5ea5c16897e", + $createdAt: "2020-10-15T06:38:00.000+00:00", + $updatedAt: "2020-10-15T06:38:00.000+00:00", $permissions: [], - functionId: '5e5ea6g16897e', - deploymentId: '5e5ea5c16897e', + resourceId: "5e5ea6g16897e", + resourceType: ExecutionResourceType.functions, + deploymentId: "5e5ea5c16897e", trigger: ExecutionTrigger.http, status: ExecutionStatus.waiting, - requestMethod: 'GET', - requestPath: '/articles?id=5', + requestMethod: "GET", + requestPath: "/articles?id=5", requestHeaders: [], responseStatusCode: 200, - responseBody: '', + responseBody: "", responseHeaders: [], - logs: '', - errors: '', + logs: "", + errors: "", duration: 0.4, ); final map = model.toMap(); final result = Execution.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$id, "5e5ea5c16897e"); + expect(result.$createdAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.$updatedAt, "2020-10-15T06:38:00.000+00:00"); expect(result.$permissions, []); - expect(result.functionId, '5e5ea6g16897e'); - expect(result.deploymentId, '5e5ea5c16897e'); + expect(result.resourceId, "5e5ea6g16897e"); + expect(result.resourceType, ExecutionResourceType.functions); + expect(result.deploymentId, "5e5ea5c16897e"); expect(result.trigger, ExecutionTrigger.http); expect(result.status, ExecutionStatus.waiting); - expect(result.requestMethod, 'GET'); - expect(result.requestPath, '/articles?id=5'); + expect(result.requestMethod, "GET"); + expect(result.requestPath, "/articles?id=5"); expect(result.requestHeaders, []); expect(result.responseStatusCode, 200); - expect(result.responseBody, ''); + expect(result.responseBody, ""); expect(result.responseHeaders, []); - expect(result.logs, ''); - expect(result.errors, ''); + expect(result.logs, ""); + expect(result.errors, ""); expect(result.duration, 0.4); }); }); diff --git a/test/src/models/file_test.dart b/test/src/models/file_test.dart index 7bf20fce..8aec10e5 100644 --- a/test/src/models/file_test.dart +++ b/test/src/models/file_test.dart @@ -5,43 +5,43 @@ void main() { group('File', () { test('model', () { final model = File( - $id: '5e5ea5c16897e', - bucketId: '5e5ea5c16897e', - $createdAt: '2020-10-15T06:38:00.000+00:00', - $updatedAt: '2020-10-15T06:38:00.000+00:00', + $id: "5e5ea5c16897e", + bucketId: "5e5ea5c16897e", + $createdAt: "2020-10-15T06:38:00.000+00:00", + $updatedAt: "2020-10-15T06:38:00.000+00:00", $permissions: [], - name: 'Pink.png', - folder: 'photos/2026/', - key: 'photos/2026/Pink.png', - signature: '5d529fd02b544198ae075bd57c1762bb', - mimeType: 'image/png', + name: "Pink.png", + folder: "photos/2026/", + key: "photos/2026/Pink.png", + signature: "5d529fd02b544198ae075bd57c1762bb", + mimeType: "image/png", sizeOriginal: 17890, sizeActual: 12345, chunksTotal: 17890, chunksUploaded: 17890, encryption: true, - compression: 'gzip', + compression: "gzip", ); final map = model.toMap(); final result = File.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.bucketId, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$id, "5e5ea5c16897e"); + expect(result.bucketId, "5e5ea5c16897e"); + expect(result.$createdAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.$updatedAt, "2020-10-15T06:38:00.000+00:00"); expect(result.$permissions, []); - expect(result.name, 'Pink.png'); - expect(result.folder, 'photos/2026/'); - expect(result.key, 'photos/2026/Pink.png'); - expect(result.signature, '5d529fd02b544198ae075bd57c1762bb'); - expect(result.mimeType, 'image/png'); + expect(result.name, "Pink.png"); + expect(result.folder, "photos/2026/"); + expect(result.key, "photos/2026/Pink.png"); + expect(result.signature, "5d529fd02b544198ae075bd57c1762bb"); + expect(result.mimeType, "image/png"); expect(result.sizeOriginal, 17890); expect(result.sizeActual, 12345); expect(result.chunksTotal, 17890); expect(result.chunksUploaded, 17890); expect(result.encryption, true); - expect(result.compression, 'gzip'); + expect(result.compression, "gzip"); }); }); } diff --git a/test/src/models/headers_test.dart b/test/src/models/headers_test.dart index 9252b469..6be7a356 100644 --- a/test/src/models/headers_test.dart +++ b/test/src/models/headers_test.dart @@ -5,15 +5,15 @@ void main() { group('Headers', () { test('model', () { final model = Headers( - name: 'Content-Type', - value: 'application/json', + name: "Content-Type", + value: "application/json", ); final map = model.toMap(); final result = Headers.fromMap(map); - expect(result.name, 'Content-Type'); - expect(result.value, 'application/json'); + expect(result.name, "Content-Type"); + expect(result.value, "application/json"); }); }); } diff --git a/test/src/models/identity_test.dart b/test/src/models/identity_test.dart index 525af4ea..a88b2dbe 100644 --- a/test/src/models/identity_test.dart +++ b/test/src/models/identity_test.dart @@ -5,31 +5,31 @@ void main() { group('Identity', () { test('model', () { final model = Identity( - $id: '5e5ea5c16897e', - $createdAt: '2020-10-15T06:38:00.000+00:00', - $updatedAt: '2020-10-15T06:38:00.000+00:00', - userId: '5e5bb8c16897e', - provider: 'email', - providerUid: '5e5bb8c16897e', - providerEmail: 'user@example.com', - providerAccessToken: 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - providerAccessTokenExpiry: '2020-10-15T06:38:00.000+00:00', - providerRefreshToken: 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + $id: "5e5ea5c16897e", + $createdAt: "2020-10-15T06:38:00.000+00:00", + $updatedAt: "2020-10-15T06:38:00.000+00:00", + userId: "5e5bb8c16897e", + provider: "email", + providerUid: "5e5bb8c16897e", + providerEmail: "user@example.com", + providerAccessToken: "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + providerAccessTokenExpiry: "2020-10-15T06:38:00.000+00:00", + providerRefreshToken: "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", ); final map = model.toMap(); final result = Identity.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5bb8c16897e'); - expect(result.provider, 'email'); - expect(result.providerUid, '5e5bb8c16897e'); - expect(result.providerEmail, 'user@example.com'); - expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); - expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + expect(result.$id, "5e5ea5c16897e"); + expect(result.$createdAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.$updatedAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.userId, "5e5bb8c16897e"); + expect(result.provider, "email"); + expect(result.providerUid, "5e5bb8c16897e"); + expect(result.providerEmail, "user@example.com"); + expect(result.providerAccessToken, "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3"); + expect(result.providerAccessTokenExpiry, "2020-10-15T06:38:00.000+00:00"); + expect(result.providerRefreshToken, "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3"); }); }); } diff --git a/test/src/models/jwt_test.dart b/test/src/models/jwt_test.dart index 93376af1..f5229e3c 100644 --- a/test/src/models/jwt_test.dart +++ b/test/src/models/jwt_test.dart @@ -6,14 +6,16 @@ void main() { test('model', () { final model = Jwt( jwt: - 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', + "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c", ); final map = model.toMap(); final result = Jwt.fromMap(map); - expect(result.jwt, - 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'); + expect( + result.jwt, + "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c", + ); }); }); } diff --git a/test/src/models/language_test.dart b/test/src/models/language_test.dart index 4a6c96c1..cbf95302 100644 --- a/test/src/models/language_test.dart +++ b/test/src/models/language_test.dart @@ -5,17 +5,17 @@ void main() { group('Language', () { test('model', () { final model = Language( - name: 'Italian', - code: 'it', - nativeName: 'Italiano', + name: "Italian", + code: "it", + nativeName: "Italiano", ); final map = model.toMap(); final result = Language.fromMap(map); - expect(result.name, 'Italian'); - expect(result.code, 'it'); - expect(result.nativeName, 'Italiano'); + expect(result.name, "Italian"); + expect(result.code, "it"); + expect(result.nativeName, "Italiano"); }); }); } diff --git a/test/src/models/locale_code_test.dart b/test/src/models/locale_code_test.dart index 88cf157b..3c238923 100644 --- a/test/src/models/locale_code_test.dart +++ b/test/src/models/locale_code_test.dart @@ -5,15 +5,15 @@ void main() { group('LocaleCode', () { test('model', () { final model = LocaleCode( - code: 'en-us', - name: 'US', + code: "en-us", + name: "US", ); final map = model.toMap(); final result = LocaleCode.fromMap(map); - expect(result.code, 'en-us'); - expect(result.name, 'US'); + expect(result.code, "en-us"); + expect(result.name, "US"); }); }); } diff --git a/test/src/models/locale_test.dart b/test/src/models/locale_test.dart index 49cb1fc9..38557034 100644 --- a/test/src/models/locale_test.dart +++ b/test/src/models/locale_test.dart @@ -5,25 +5,25 @@ void main() { group('Locale', () { test('model', () { final model = Locale( - ip: '127.0.0.1', - countryCode: 'US', - country: 'United States', - continentCode: 'NA', - continent: 'North America', + ip: "127.0.0.1", + countryCode: "US", + country: "United States", + continentCode: "NA", + continent: "North America", eu: true, - currency: 'USD', + currency: "USD", ); final map = model.toMap(); final result = Locale.fromMap(map); - expect(result.ip, '127.0.0.1'); - expect(result.countryCode, 'US'); - expect(result.country, 'United States'); - expect(result.continentCode, 'NA'); - expect(result.continent, 'North America'); + expect(result.ip, "127.0.0.1"); + expect(result.countryCode, "US"); + expect(result.country, "United States"); + expect(result.continentCode, "NA"); + expect(result.continent, "North America"); expect(result.eu, true); - expect(result.currency, 'USD'); + expect(result.currency, "USD"); }); }); } diff --git a/test/src/models/log_test.dart b/test/src/models/log_test.dart index c8211d3b..3b4d95af 100644 --- a/test/src/models/log_test.dart +++ b/test/src/models/log_test.dart @@ -5,55 +5,55 @@ void main() { group('Log', () { test('model', () { final model = Log( - event: 'account.sessions.create', - userId: '610fc2f985ee0', - userEmail: 'john@appwrite.io', - userName: 'John Doe', - mode: 'admin', - userType: 'user', - ip: '127.0.0.1', - time: '2020-10-15T06:38:00.000+00:00', - osCode: 'Mac', - osName: 'Mac', - osVersion: 'Mac', - clientType: 'browser', - clientCode: 'CM', - clientName: 'Chrome Mobile iOS', - clientVersion: '84.0', - clientEngine: 'WebKit', - clientEngineVersion: '605.1.15', - deviceName: 'smartphone', - deviceBrand: 'Google', - deviceModel: 'Nexus 5', - countryCode: 'US', - countryName: 'United States', + event: "account.sessions.create", + userId: "610fc2f985ee0", + userEmail: "john@appwrite.io", + userName: "John Doe", + mode: "admin", + userType: "user", + ip: "127.0.0.1", + time: "2020-10-15T06:38:00.000+00:00", + osCode: "Mac", + osName: "Mac", + osVersion: "Mac", + clientType: "browser", + clientCode: "CM", + clientName: "Chrome Mobile iOS", + clientVersion: "84.0", + clientEngine: "WebKit", + clientEngineVersion: "605.1.15", + deviceName: "smartphone", + deviceBrand: "Google", + deviceModel: "Nexus 5", + countryCode: "US", + countryName: "United States", ); final map = model.toMap(); final result = Log.fromMap(map); - expect(result.event, 'account.sessions.create'); - expect(result.userId, '610fc2f985ee0'); - expect(result.userEmail, 'john@appwrite.io'); - expect(result.userName, 'John Doe'); - expect(result.mode, 'admin'); - expect(result.userType, 'user'); - expect(result.ip, '127.0.0.1'); - expect(result.time, '2020-10-15T06:38:00.000+00:00'); - expect(result.osCode, 'Mac'); - expect(result.osName, 'Mac'); - expect(result.osVersion, 'Mac'); - expect(result.clientType, 'browser'); - expect(result.clientCode, 'CM'); - expect(result.clientName, 'Chrome Mobile iOS'); - expect(result.clientVersion, '84.0'); - expect(result.clientEngine, 'WebKit'); - expect(result.clientEngineVersion, '605.1.15'); - expect(result.deviceName, 'smartphone'); - expect(result.deviceBrand, 'Google'); - expect(result.deviceModel, 'Nexus 5'); - expect(result.countryCode, 'US'); - expect(result.countryName, 'United States'); + expect(result.event, "account.sessions.create"); + expect(result.userId, "610fc2f985ee0"); + expect(result.userEmail, "john@appwrite.io"); + expect(result.userName, "John Doe"); + expect(result.mode, "admin"); + expect(result.userType, "user"); + expect(result.ip, "127.0.0.1"); + expect(result.time, "2020-10-15T06:38:00.000+00:00"); + expect(result.osCode, "Mac"); + expect(result.osName, "Mac"); + expect(result.osVersion, "Mac"); + expect(result.clientType, "browser"); + expect(result.clientCode, "CM"); + expect(result.clientName, "Chrome Mobile iOS"); + expect(result.clientVersion, "84.0"); + expect(result.clientEngine, "WebKit"); + expect(result.clientEngineVersion, "605.1.15"); + expect(result.deviceName, "smartphone"); + expect(result.deviceBrand, "Google"); + expect(result.deviceModel, "Nexus 5"); + expect(result.countryCode, "US"); + expect(result.countryName, "United States"); }); }); } diff --git a/test/src/models/membership_test.dart b/test/src/models/membership_test.dart index b2b8bd3d..2b157ac6 100644 --- a/test/src/models/membership_test.dart +++ b/test/src/models/membership_test.dart @@ -5,40 +5,40 @@ void main() { group('Membership', () { test('model', () { final model = Membership( - $id: '5e5ea5c16897e', - $createdAt: '2020-10-15T06:38:00.000+00:00', - $updatedAt: '2020-10-15T06:38:00.000+00:00', - userId: '5e5ea5c16897e', - userName: 'John Doe', - userEmail: 'john@appwrite.io', - userPhone: '+1 555 555 5555', - teamId: '5e5ea5c16897e', - teamName: 'VIP', - invited: '2020-10-15T06:38:00.000+00:00', - joined: '2020-10-15T06:38:00.000+00:00', + $id: "5e5ea5c16897e", + $createdAt: "2020-10-15T06:38:00.000+00:00", + $updatedAt: "2020-10-15T06:38:00.000+00:00", + userId: "5e5ea5c16897e", + userName: "John Doe", + userEmail: "john@appwrite.io", + userPhone: "+1 555 555 5555", + teamId: "5e5ea5c16897e", + teamName: "VIP", + invited: "2020-10-15T06:38:00.000+00:00", + joined: "2020-10-15T06:38:00.000+00:00", confirm: true, mfa: true, - userAccessedAt: '2020-10-15T06:38:00.000+00:00', + userAccessedAt: "2020-10-15T06:38:00.000+00:00", roles: [], ); final map = model.toMap(); final result = Membership.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5ea5c16897e'); - expect(result.userName, 'John Doe'); - expect(result.userEmail, 'john@appwrite.io'); - expect(result.userPhone, '+1 555 555 5555'); - expect(result.teamId, '5e5ea5c16897e'); - expect(result.teamName, 'VIP'); - expect(result.invited, '2020-10-15T06:38:00.000+00:00'); - expect(result.joined, '2020-10-15T06:38:00.000+00:00'); + expect(result.$id, "5e5ea5c16897e"); + expect(result.$createdAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.$updatedAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.userId, "5e5ea5c16897e"); + expect(result.userName, "John Doe"); + expect(result.userEmail, "john@appwrite.io"); + expect(result.userPhone, "+1 555 555 5555"); + expect(result.teamId, "5e5ea5c16897e"); + expect(result.teamName, "VIP"); + expect(result.invited, "2020-10-15T06:38:00.000+00:00"); + expect(result.joined, "2020-10-15T06:38:00.000+00:00"); expect(result.confirm, true); expect(result.mfa, true); - expect(result.userAccessedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userAccessedAt, "2020-10-15T06:38:00.000+00:00"); expect(result.roles, []); }); }); diff --git a/test/src/models/mfa_challenge_test.dart b/test/src/models/mfa_challenge_test.dart index 5d3febca..227ed694 100644 --- a/test/src/models/mfa_challenge_test.dart +++ b/test/src/models/mfa_challenge_test.dart @@ -5,19 +5,19 @@ void main() { group('MfaChallenge', () { test('model', () { final model = MfaChallenge( - $id: 'bb8ea5c16897e', - $createdAt: '2020-10-15T06:38:00.000+00:00', - userId: '5e5ea5c168bb8', - expire: '2020-10-15T06:38:00.000+00:00', + $id: "bb8ea5c16897e", + $createdAt: "2020-10-15T06:38:00.000+00:00", + userId: "5e5ea5c168bb8", + expire: "2020-10-15T06:38:00.000+00:00", ); final map = model.toMap(); final result = MfaChallenge.fromMap(map); - expect(result.$id, 'bb8ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5ea5c168bb8'); - expect(result.expire, '2020-10-15T06:38:00.000+00:00'); + expect(result.$id, "bb8ea5c16897e"); + expect(result.$createdAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.userId, "5e5ea5c168bb8"); + expect(result.expire, "2020-10-15T06:38:00.000+00:00"); }); }); } diff --git a/test/src/models/mfa_factors_test.dart b/test/src/models/mfa_factors_test.dart index 64cc55e4..03c86145 100644 --- a/test/src/models/mfa_factors_test.dart +++ b/test/src/models/mfa_factors_test.dart @@ -9,6 +9,7 @@ void main() { phone: true, email: true, recoveryCode: true, + custom: true, ); final map = model.toMap(); @@ -18,6 +19,7 @@ void main() { expect(result.phone, true); expect(result.email, true); expect(result.recoveryCode, true); + expect(result.custom, true); }); }); } diff --git a/test/src/models/mfa_type_test.dart b/test/src/models/mfa_type_test.dart index 81657394..8ca0e284 100644 --- a/test/src/models/mfa_type_test.dart +++ b/test/src/models/mfa_type_test.dart @@ -5,17 +5,19 @@ void main() { group('MfaType', () { test('model', () { final model = MfaType( - secret: '[SHARED_SECRET]', + secret: "[SHARED_SECRET]", uri: - 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite', + "otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite", ); final map = model.toMap(); final result = MfaType.fromMap(map); - expect(result.secret, '[SHARED_SECRET]'); - expect(result.uri, - 'otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite'); + expect(result.secret, "[SHARED_SECRET]"); + expect( + result.uri, + "otpauth://totp/appwrite:user@example.com?secret=[SHARED_SECRET]&issuer=appwrite", + ); }); }); } diff --git a/test/src/models/oauth2_consent_test.dart b/test/src/models/oauth2_consent_test.dart index 32456d3c..c80f1d64 100644 --- a/test/src/models/oauth2_consent_test.dart +++ b/test/src/models/oauth2_consent_test.dart @@ -5,34 +5,38 @@ void main() { group('Oauth2Consent', () { test('model', () { final model = Oauth2Consent( - $id: '5e5ea5c16897e', - $createdAt: '2020-10-15T06:38:00.000+00:00', - $updatedAt: '2020-10-15T06:38:00.000+00:00', - userId: '5e5ea5c16897e', - appId: '5e5ea5c16897e', - cimdUrl: 'https://example.com/.well-known/client-metadata.json', + $id: "5e5ea5c16897e", + $createdAt: "2020-10-15T06:38:00.000+00:00", + $updatedAt: "2020-10-15T06:38:00.000+00:00", + userId: "5e5ea5c16897e", + appId: "5e5ea5c16897e", + cimdUrl: "https://example.com/.well-known/client-metadata.json", scopes: [], resources: [], authorizationDetails: - '[{\"type\":\"calendar\",\"identifier\":\"primary\",\"actions\":[\"read_events\",\"create_event\"]}]', - expire: '2020-10-15T06:38:00.000+00:00', + "[{\"type\":\"calendar\",\"identifier\":\"primary\",\"actions\":[\"read_events\",\"create_event\"]}]", + expire: "2020-10-15T06:38:00.000+00:00", ); final map = model.toMap(); final result = Oauth2Consent.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5ea5c16897e'); - expect(result.appId, '5e5ea5c16897e'); - expect(result.cimdUrl, - 'https://example.com/.well-known/client-metadata.json'); + expect(result.$id, "5e5ea5c16897e"); + expect(result.$createdAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.$updatedAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.userId, "5e5ea5c16897e"); + expect(result.appId, "5e5ea5c16897e"); + expect( + result.cimdUrl, + "https://example.com/.well-known/client-metadata.json", + ); expect(result.scopes, []); expect(result.resources, []); - expect(result.authorizationDetails, - '[{\"type\":\"calendar\",\"identifier\":\"primary\",\"actions\":[\"read_events\",\"create_event\"]}]'); - expect(result.expire, '2020-10-15T06:38:00.000+00:00'); + expect( + result.authorizationDetails, + "[{\"type\":\"calendar\",\"identifier\":\"primary\",\"actions\":[\"read_events\",\"create_event\"]}]", + ); + expect(result.expire, "2020-10-15T06:38:00.000+00:00"); }); }); } diff --git a/test/src/models/oauth2_consent_token_test.dart b/test/src/models/oauth2_consent_token_test.dart index e8a7b94b..08fc9557 100644 --- a/test/src/models/oauth2_consent_token_test.dart +++ b/test/src/models/oauth2_consent_token_test.dart @@ -5,36 +5,40 @@ void main() { group('Oauth2ConsentToken', () { test('model', () { final model = Oauth2ConsentToken( - $id: '5e5ea5c16897e', - $createdAt: '2020-10-15T06:38:00.000+00:00', - $updatedAt: '2020-10-15T06:38:00.000+00:00', - consentId: '5e5ea5c16897e', - userId: '5e5ea5c16897e', - appId: '5e5ea5c16897e', - cimdUrl: 'https://example.com/.well-known/client-metadata.json', + $id: "5e5ea5c16897e", + $createdAt: "2020-10-15T06:38:00.000+00:00", + $updatedAt: "2020-10-15T06:38:00.000+00:00", + consentId: "5e5ea5c16897e", + userId: "5e5ea5c16897e", + appId: "5e5ea5c16897e", + cimdUrl: "https://example.com/.well-known/client-metadata.json", scopes: [], resources: [], authorizationDetails: - '[{\"type\":\"calendar\",\"identifier\":\"primary\",\"actions\":[\"read_events\",\"create_event\"]}]', - expire: '2020-10-15T06:38:00.000+00:00', + "[{\"type\":\"calendar\",\"identifier\":\"primary\",\"actions\":[\"read_events\",\"create_event\"]}]", + expire: "2020-10-15T06:38:00.000+00:00", ); final map = model.toMap(); final result = Oauth2ConsentToken.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.consentId, '5e5ea5c16897e'); - expect(result.userId, '5e5ea5c16897e'); - expect(result.appId, '5e5ea5c16897e'); - expect(result.cimdUrl, - 'https://example.com/.well-known/client-metadata.json'); + expect(result.$id, "5e5ea5c16897e"); + expect(result.$createdAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.$updatedAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.consentId, "5e5ea5c16897e"); + expect(result.userId, "5e5ea5c16897e"); + expect(result.appId, "5e5ea5c16897e"); + expect( + result.cimdUrl, + "https://example.com/.well-known/client-metadata.json", + ); expect(result.scopes, []); expect(result.resources, []); - expect(result.authorizationDetails, - '[{\"type\":\"calendar\",\"identifier\":\"primary\",\"actions\":[\"read_events\",\"create_event\"]}]'); - expect(result.expire, '2020-10-15T06:38:00.000+00:00'); + expect( + result.authorizationDetails, + "[{\"type\":\"calendar\",\"identifier\":\"primary\",\"actions\":[\"read_events\",\"create_event\"]}]", + ); + expect(result.expire, "2020-10-15T06:38:00.000+00:00"); }); }); } diff --git a/test/src/models/phone_test.dart b/test/src/models/phone_test.dart index f70db0e3..3f9c2646 100644 --- a/test/src/models/phone_test.dart +++ b/test/src/models/phone_test.dart @@ -5,17 +5,17 @@ void main() { group('Phone', () { test('model', () { final model = Phone( - code: '+1', - countryCode: 'US', - countryName: 'United States', + code: "+1", + countryCode: "US", + countryName: "United States", ); final map = model.toMap(); final result = Phone.fromMap(map); - expect(result.code, '+1'); - expect(result.countryCode, 'US'); - expect(result.countryName, 'United States'); + expect(result.code, "+1"); + expect(result.countryCode, "US"); + expect(result.countryName, "United States"); }); }); } diff --git a/test/src/models/presence_test.dart b/test/src/models/presence_test.dart index ef2ebe31..854a9695 100644 --- a/test/src/models/presence_test.dart +++ b/test/src/models/presence_test.dart @@ -5,23 +5,23 @@ void main() { group('Presence', () { test('model', () { final model = Presence( - $id: '5e5ea5c16897e', - $createdAt: '2020-10-15T06:38:00.000+00:00', - $updatedAt: '2020-10-15T06:38:00.000+00:00', + $id: "5e5ea5c16897e", + $createdAt: "2020-10-15T06:38:00.000+00:00", + $updatedAt: "2020-10-15T06:38:00.000+00:00", $permissions: [], - userId: '674af8f3e12a5f9ac0be', - source: 'HTTP', + userId: "674af8f3e12a5f9ac0be", + source: "HTTP", ); final map = model.toMap(); final result = Presence.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$id, "5e5ea5c16897e"); + expect(result.$createdAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.$updatedAt, "2020-10-15T06:38:00.000+00:00"); expect(result.$permissions, []); - expect(result.userId, '674af8f3e12a5f9ac0be'); - expect(result.source, 'HTTP'); + expect(result.userId, "674af8f3e12a5f9ac0be"); + expect(result.source, "HTTP"); }); }); } diff --git a/test/src/models/row_test.dart b/test/src/models/row_test.dart index 564bf303..903776c2 100644 --- a/test/src/models/row_test.dart +++ b/test/src/models/row_test.dart @@ -5,12 +5,12 @@ void main() { group('Row', () { test('model', () { final model = Row( - $id: '5e5ea5c16897e', - $sequence: '1', - $tableId: '5e5ea5c15117e', - $databaseId: '5e5ea5c15117e', - $createdAt: '2020-10-15T06:38:00.000+00:00', - $updatedAt: '2020-10-15T06:38:00.000+00:00', + $id: "5e5ea5c16897e", + $sequence: "1", + $tableId: "5e5ea5c15117e", + $databaseId: "5e5ea5c15117e", + $createdAt: "2020-10-15T06:38:00.000+00:00", + $updatedAt: "2020-10-15T06:38:00.000+00:00", $permissions: [], data: {}, ); @@ -18,12 +18,12 @@ void main() { final map = model.toMap(); final result = Row.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$sequence, '1'); - expect(result.$tableId, '5e5ea5c15117e'); - expect(result.$databaseId, '5e5ea5c15117e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$id, "5e5ea5c16897e"); + expect(result.$sequence, "1"); + expect(result.$tableId, "5e5ea5c15117e"); + expect(result.$databaseId, "5e5ea5c15117e"); + expect(result.$createdAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.$updatedAt, "2020-10-15T06:38:00.000+00:00"); expect(result.$permissions, []); }); }); diff --git a/test/src/models/session_test.dart b/test/src/models/session_test.dart index 689e6048..45dd3471 100644 --- a/test/src/models/session_test.dart +++ b/test/src/models/session_test.dart @@ -5,69 +5,69 @@ void main() { group('Session', () { test('model', () { final model = Session( - $id: '5e5ea5c16897e', - $createdAt: '2020-10-15T06:38:00.000+00:00', - $updatedAt: '2020-10-15T06:38:00.000+00:00', - userId: '5e5bb8c16897e', - expire: '2020-10-15T06:38:00.000+00:00', - provider: 'email', - providerUid: 'user@example.com', - providerAccessToken: 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - providerAccessTokenExpiry: '2020-10-15T06:38:00.000+00:00', - providerRefreshToken: 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', - ip: '127.0.0.1', - osCode: 'Mac', - osName: 'Mac', - osVersion: 'Mac', - clientType: 'browser', - clientCode: 'CM', - clientName: 'Chrome Mobile iOS', - clientVersion: '84.0', - clientEngine: 'WebKit', - clientEngineVersion: '605.1.15', - deviceName: 'smartphone', - deviceBrand: 'Google', - deviceModel: 'Nexus 5', - countryCode: 'US', - countryName: 'United States', + $id: "5e5ea5c16897e", + $createdAt: "2020-10-15T06:38:00.000+00:00", + $updatedAt: "2020-10-15T06:38:00.000+00:00", + userId: "5e5bb8c16897e", + expire: "2020-10-15T06:38:00.000+00:00", + provider: "email", + providerUid: "user@example.com", + providerAccessToken: "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + providerAccessTokenExpiry: "2020-10-15T06:38:00.000+00:00", + providerRefreshToken: "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + ip: "127.0.0.1", + osCode: "Mac", + osName: "Mac", + osVersion: "Mac", + clientType: "browser", + clientCode: "CM", + clientName: "Chrome Mobile iOS", + clientVersion: "84.0", + clientEngine: "WebKit", + clientEngineVersion: "605.1.15", + deviceName: "smartphone", + deviceBrand: "Google", + deviceModel: "Nexus 5", + countryCode: "US", + countryName: "United States", current: true, factors: [], - secret: '5e5bb8c16897e', - mfaUpdatedAt: '2020-10-15T06:38:00.000+00:00', + secret: "5e5bb8c16897e", + mfaUpdatedAt: "2020-10-15T06:38:00.000+00:00", ); final map = model.toMap(); final result = Session.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5bb8c16897e'); - expect(result.expire, '2020-10-15T06:38:00.000+00:00'); - expect(result.provider, 'email'); - expect(result.providerUid, 'user@example.com'); - expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); - expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); - expect(result.ip, '127.0.0.1'); - expect(result.osCode, 'Mac'); - expect(result.osName, 'Mac'); - expect(result.osVersion, 'Mac'); - expect(result.clientType, 'browser'); - expect(result.clientCode, 'CM'); - expect(result.clientName, 'Chrome Mobile iOS'); - expect(result.clientVersion, '84.0'); - expect(result.clientEngine, 'WebKit'); - expect(result.clientEngineVersion, '605.1.15'); - expect(result.deviceName, 'smartphone'); - expect(result.deviceBrand, 'Google'); - expect(result.deviceModel, 'Nexus 5'); - expect(result.countryCode, 'US'); - expect(result.countryName, 'United States'); + expect(result.$id, "5e5ea5c16897e"); + expect(result.$createdAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.$updatedAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.userId, "5e5bb8c16897e"); + expect(result.expire, "2020-10-15T06:38:00.000+00:00"); + expect(result.provider, "email"); + expect(result.providerUid, "user@example.com"); + expect(result.providerAccessToken, "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3"); + expect(result.providerAccessTokenExpiry, "2020-10-15T06:38:00.000+00:00"); + expect(result.providerRefreshToken, "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3"); + expect(result.ip, "127.0.0.1"); + expect(result.osCode, "Mac"); + expect(result.osName, "Mac"); + expect(result.osVersion, "Mac"); + expect(result.clientType, "browser"); + expect(result.clientCode, "CM"); + expect(result.clientName, "Chrome Mobile iOS"); + expect(result.clientVersion, "84.0"); + expect(result.clientEngine, "WebKit"); + expect(result.clientEngineVersion, "605.1.15"); + expect(result.deviceName, "smartphone"); + expect(result.deviceBrand, "Google"); + expect(result.deviceModel, "Nexus 5"); + expect(result.countryCode, "US"); + expect(result.countryName, "United States"); expect(result.current, true); expect(result.factors, []); - expect(result.secret, '5e5bb8c16897e'); - expect(result.mfaUpdatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.secret, "5e5bb8c16897e"); + expect(result.mfaUpdatedAt, "2020-10-15T06:38:00.000+00:00"); }); }); } diff --git a/test/src/models/subscriber_test.dart b/test/src/models/subscriber_test.dart index 7445514c..6ac27400 100644 --- a/test/src/models/subscriber_test.dart +++ b/test/src/models/subscriber_test.dart @@ -5,37 +5,37 @@ void main() { group('Subscriber', () { test('model', () { final model = Subscriber( - $id: '259125845563242502', - $createdAt: '2020-10-15T06:38:00.000+00:00', - $updatedAt: '2020-10-15T06:38:00.000+00:00', - targetId: '259125845563242502', + $id: "259125845563242502", + $createdAt: "2020-10-15T06:38:00.000+00:00", + $updatedAt: "2020-10-15T06:38:00.000+00:00", + targetId: "259125845563242502", target: Target( - $id: '259125845563242502', - $createdAt: '2020-10-15T06:38:00.000+00:00', - $updatedAt: '2020-10-15T06:38:00.000+00:00', - name: 'Apple iPhone 12', - userId: '259125845563242502', - providerType: 'email', - identifier: 'token', + $id: "259125845563242502", + $createdAt: "2020-10-15T06:38:00.000+00:00", + $updatedAt: "2020-10-15T06:38:00.000+00:00", + name: "Apple iPhone 12", + userId: "259125845563242502", + providerType: "email", + identifier: "token", expired: true, ), - userId: '5e5ea5c16897e', - userName: 'Aegon Targaryen', - topicId: '259125845563242502', - providerType: 'email', + userId: "5e5ea5c16897e", + userName: "Aegon Targaryen", + topicId: "259125845563242502", + providerType: "email", ); final map = model.toMap(); final result = Subscriber.fromMap(map); - expect(result.$id, '259125845563242502'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.targetId, '259125845563242502'); - expect(result.userId, '5e5ea5c16897e'); - expect(result.userName, 'Aegon Targaryen'); - expect(result.topicId, '259125845563242502'); - expect(result.providerType, 'email'); + expect(result.$id, "259125845563242502"); + expect(result.$createdAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.$updatedAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.targetId, "259125845563242502"); + expect(result.userId, "5e5ea5c16897e"); + expect(result.userName, "Aegon Targaryen"); + expect(result.topicId, "259125845563242502"); + expect(result.providerType, "email"); }); }); } diff --git a/test/src/models/target_test.dart b/test/src/models/target_test.dart index 49f1e75e..67a7dfd1 100644 --- a/test/src/models/target_test.dart +++ b/test/src/models/target_test.dart @@ -5,26 +5,26 @@ void main() { group('Target', () { test('model', () { final model = Target( - $id: '259125845563242502', - $createdAt: '2020-10-15T06:38:00.000+00:00', - $updatedAt: '2020-10-15T06:38:00.000+00:00', - name: 'Apple iPhone 12', - userId: '259125845563242502', - providerType: 'email', - identifier: 'token', + $id: "259125845563242502", + $createdAt: "2020-10-15T06:38:00.000+00:00", + $updatedAt: "2020-10-15T06:38:00.000+00:00", + name: "Apple iPhone 12", + userId: "259125845563242502", + providerType: "email", + identifier: "token", expired: true, ); final map = model.toMap(); final result = Target.fromMap(map); - expect(result.$id, '259125845563242502'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.name, 'Apple iPhone 12'); - expect(result.userId, '259125845563242502'); - expect(result.providerType, 'email'); - expect(result.identifier, 'token'); + expect(result.$id, "259125845563242502"); + expect(result.$createdAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.$updatedAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.name, "Apple iPhone 12"); + expect(result.userId, "259125845563242502"); + expect(result.providerType, "email"); + expect(result.identifier, "token"); expect(result.expired, true); }); }); diff --git a/test/src/models/team_test.dart b/test/src/models/team_test.dart index f652f2c1..8244762c 100644 --- a/test/src/models/team_test.dart +++ b/test/src/models/team_test.dart @@ -5,10 +5,10 @@ void main() { group('Team', () { test('model', () { final model = Team( - $id: '5e5ea5c16897e', - $createdAt: '2020-10-15T06:38:00.000+00:00', - $updatedAt: '2020-10-15T06:38:00.000+00:00', - name: 'VIP', + $id: "5e5ea5c16897e", + $createdAt: "2020-10-15T06:38:00.000+00:00", + $updatedAt: "2020-10-15T06:38:00.000+00:00", + name: "VIP", total: 7, prefs: Preferences(data: {}), ); @@ -16,10 +16,10 @@ void main() { final map = model.toMap(); final result = Team.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.name, 'VIP'); + expect(result.$id, "5e5ea5c16897e"); + expect(result.$createdAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.$updatedAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.name, "VIP"); expect(result.total, 7); }); }); diff --git a/test/src/models/token_test.dart b/test/src/models/token_test.dart index 8f0957c9..b747dfb8 100644 --- a/test/src/models/token_test.dart +++ b/test/src/models/token_test.dart @@ -5,23 +5,23 @@ void main() { group('Token', () { test('model', () { final model = Token( - $id: 'bb8ea5c16897e', - $createdAt: '2020-10-15T06:38:00.000+00:00', - userId: '5e5ea5c168bb8', - secret: '', - expire: '2020-10-15T06:38:00.000+00:00', - phrase: 'Golden Fox', + $id: "bb8ea5c16897e", + $createdAt: "2020-10-15T06:38:00.000+00:00", + userId: "5e5ea5c168bb8", + secret: "", + expire: "2020-10-15T06:38:00.000+00:00", + phrase: "Golden Fox", ); final map = model.toMap(); final result = Token.fromMap(map); - expect(result.$id, 'bb8ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.userId, '5e5ea5c168bb8'); - expect(result.secret, ''); - expect(result.expire, '2020-10-15T06:38:00.000+00:00'); - expect(result.phrase, 'Golden Fox'); + expect(result.$id, "bb8ea5c16897e"); + expect(result.$createdAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.userId, "5e5ea5c168bb8"); + expect(result.secret, ""); + expect(result.expire, "2020-10-15T06:38:00.000+00:00"); + expect(result.phrase, "Golden Fox"); }); }); } diff --git a/test/src/models/transaction_test.dart b/test/src/models/transaction_test.dart index 0169427f..98f0c882 100644 --- a/test/src/models/transaction_test.dart +++ b/test/src/models/transaction_test.dart @@ -5,23 +5,23 @@ void main() { group('Transaction', () { test('model', () { final model = Transaction( - $id: '259125845563242502', - $createdAt: '2020-10-15T06:38:00.000+00:00', - $updatedAt: '2020-10-15T06:38:00.000+00:00', - status: 'pending', + $id: "259125845563242502", + $createdAt: "2020-10-15T06:38:00.000+00:00", + $updatedAt: "2020-10-15T06:38:00.000+00:00", + status: "pending", operations: 5, - expiresAt: '2020-10-15T06:38:00.000+00:00', + expiresAt: "2020-10-15T06:38:00.000+00:00", ); final map = model.toMap(); final result = Transaction.fromMap(map); - expect(result.$id, '259125845563242502'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.status, 'pending'); + expect(result.$id, "259125845563242502"); + expect(result.$createdAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.$updatedAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.status, "pending"); expect(result.operations, 5); - expect(result.expiresAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.expiresAt, "2020-10-15T06:38:00.000+00:00"); }); }); } diff --git a/test/src/models/user_test.dart b/test/src/models/user_test.dart index 77c7dd97..37ca37f7 100644 --- a/test/src/models/user_test.dart +++ b/test/src/models/user_test.dart @@ -5,42 +5,42 @@ void main() { group('User', () { test('model', () { final model = User( - $id: '5e5ea5c16897e', - $createdAt: '2020-10-15T06:38:00.000+00:00', - $updatedAt: '2020-10-15T06:38:00.000+00:00', - name: 'John Doe', - registration: '2020-10-15T06:38:00.000+00:00', + $id: "5e5ea5c16897e", + $createdAt: "2020-10-15T06:38:00.000+00:00", + $updatedAt: "2020-10-15T06:38:00.000+00:00", + name: "John Doe", + registration: "2020-10-15T06:38:00.000+00:00", status: true, labels: [], - passwordUpdate: '2020-10-15T06:38:00.000+00:00', - email: 'john@appwrite.io', - phone: '+4930901820', + passwordUpdate: "2020-10-15T06:38:00.000+00:00", + email: "john@appwrite.io", + phone: "+4930901820", emailVerification: true, phoneVerification: true, mfa: true, prefs: Preferences(data: {}), targets: [], - accessedAt: '2020-10-15T06:38:00.000+00:00', + accessedAt: "2020-10-15T06:38:00.000+00:00", ); final map = model.toMap(); final result = User.fromMap(map); - expect(result.$id, '5e5ea5c16897e'); - expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); - expect(result.name, 'John Doe'); - expect(result.registration, '2020-10-15T06:38:00.000+00:00'); + expect(result.$id, "5e5ea5c16897e"); + expect(result.$createdAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.$updatedAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.name, "John Doe"); + expect(result.registration, "2020-10-15T06:38:00.000+00:00"); expect(result.status, true); expect(result.labels, []); - expect(result.passwordUpdate, '2020-10-15T06:38:00.000+00:00'); - expect(result.email, 'john@appwrite.io'); - expect(result.phone, '+4930901820'); + expect(result.passwordUpdate, "2020-10-15T06:38:00.000+00:00"); + expect(result.email, "john@appwrite.io"); + expect(result.phone, "+4930901820"); expect(result.emailVerification, true); expect(result.phoneVerification, true); expect(result.mfa, true); expect(result.targets, []); - expect(result.accessedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.accessedAt, "2020-10-15T06:38:00.000+00:00"); }); }); } diff --git a/test/src/realtime_response_test.dart b/test/src/realtime_response_test.dart index 4435280a..029c35bf 100644 --- a/test/src/realtime_response_test.dart +++ b/test/src/realtime_response_test.dart @@ -48,7 +48,9 @@ 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 1515f1a3..d19e6eac 100644 --- a/test/src/realtime_subscription_test.dart +++ b/test/src/realtime_subscription_test.dart @@ -8,15 +8,18 @@ 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 d21607ec..3dce66c9 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,