diff --git a/.travis.yml b/.travis.yml index 564e643..38001f4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,3 @@ -dist: focal - language: dart dart: stable @@ -7,9 +5,9 @@ dart: stable os: linux install: -- mkdir -p ~/.pub-cache +- mkdir -p ~/.config/dart - | - cat < ~/.pub-cache/credentials.json + cat < ~/.config/dart/pub-credentials.json { "accessToken":"$PUB_ACCESS_TOKEN", "refreshToken":"$PUB_REFRESH_TOKEN", @@ -23,4 +21,4 @@ deploy: skip_cleanup: true script: dart format ./lib/ && dart pub publish -f on: - tags: true + tags: true \ No newline at end of file diff --git a/README.md b/README.md index bb5f42c..678c05b 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,12 @@ [![pub package](https://img.shields.io/pub/v/appwrite?style=flat-square)](https://pub.dartlang.org/packages/appwrite) ![License](https://img.shields.io/github/license/appwrite/sdk-for-flutter.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-0.15.2-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.0.0-RC1-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK is compatible with Appwrite server version 0.15.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-flutter/releases).** +**This SDK is compatible with Appwrite server version 1.0.0-RC1. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-flutter/releases).** Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Flutter SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) @@ -21,7 +21,7 @@ Add this to your package's `pubspec.yaml` file: ```yml dependencies: - appwrite: ^7.0.0 + appwrite: ^8.0.0-dev.1 ``` You can install packages from the command line: diff --git a/docs/examples/account/create-phone-session.md b/docs/examples/account/create-phone-session.md index e1cd25a..65f2861 100644 --- a/docs/examples/account/create-phone-session.md +++ b/docs/examples/account/create-phone-session.md @@ -10,7 +10,7 @@ void main() { // Init SDK ; Future result = account.createPhoneSession( userId: '[USER_ID]', - number: '', + phone: '', ); result diff --git a/docs/examples/account/update-phone.md b/docs/examples/account/update-phone.md index 1269349..fbf1343 100644 --- a/docs/examples/account/update-phone.md +++ b/docs/examples/account/update-phone.md @@ -9,7 +9,7 @@ void main() { // Init SDK .setProject('5df5acd0d48c2') // Your project ID ; Future result = account.updatePhone( - number: '', + phone: '', password: 'password', ); diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index 6c4b9b8..730dd21 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -2,13 +2,14 @@ import 'package:appwrite/appwrite.dart'; void main() { // Init SDK Client client = Client(); - Databases databases = Databases(client, databaseId: '[DATABASE_ID]'); + Databases databases = Databases(client); client .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID ; Future result = databases.createDocument( + databaseId: '[DATABASE_ID]', collectionId: '[COLLECTION_ID]', documentId: '[DOCUMENT_ID]', data: {}, diff --git a/docs/examples/databases/delete-document.md b/docs/examples/databases/delete-document.md index a57ed8e..8dc6246 100644 --- a/docs/examples/databases/delete-document.md +++ b/docs/examples/databases/delete-document.md @@ -2,13 +2,14 @@ import 'package:appwrite/appwrite.dart'; void main() { // Init SDK Client client = Client(); - Databases databases = Databases(client, databaseId: '[DATABASE_ID]'); + Databases databases = Databases(client); client .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID ; Future result = databases.deleteDocument( + databaseId: '[DATABASE_ID]', collectionId: '[COLLECTION_ID]', documentId: '[DOCUMENT_ID]', ); diff --git a/docs/examples/databases/get-document.md b/docs/examples/databases/get-document.md index 585ac2b..71c88d6 100644 --- a/docs/examples/databases/get-document.md +++ b/docs/examples/databases/get-document.md @@ -2,13 +2,14 @@ import 'package:appwrite/appwrite.dart'; void main() { // Init SDK Client client = Client(); - Databases databases = Databases(client, databaseId: '[DATABASE_ID]'); + Databases databases = Databases(client); client .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID ; Future result = databases.getDocument( + databaseId: '[DATABASE_ID]', collectionId: '[COLLECTION_ID]', documentId: '[DOCUMENT_ID]', ); diff --git a/docs/examples/databases/list-documents.md b/docs/examples/databases/list-documents.md index 6ac1153..816a17d 100644 --- a/docs/examples/databases/list-documents.md +++ b/docs/examples/databases/list-documents.md @@ -2,13 +2,14 @@ import 'package:appwrite/appwrite.dart'; void main() { // Init SDK Client client = Client(); - Databases databases = Databases(client, databaseId: '[DATABASE_ID]'); + Databases databases = Databases(client); client .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID ; Future result = databases.listDocuments( + databaseId: '[DATABASE_ID]', collectionId: '[COLLECTION_ID]', ); diff --git a/docs/examples/databases/update-document.md b/docs/examples/databases/update-document.md index f27139f..29abff6 100644 --- a/docs/examples/databases/update-document.md +++ b/docs/examples/databases/update-document.md @@ -2,13 +2,14 @@ import 'package:appwrite/appwrite.dart'; void main() { // Init SDK Client client = Client(); - Databases databases = Databases(client, databaseId: '[DATABASE_ID]'); + Databases databases = Databases(client); client .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID ; Future result = databases.updateDocument( + databaseId: '[DATABASE_ID]', collectionId: '[COLLECTION_ID]', documentId: '[DOCUMENT_ID]', ); diff --git a/lib/appwrite.dart b/lib/appwrite.dart index bf6752a..f6448ab 100644 --- a/lib/appwrite.dart +++ b/lib/appwrite.dart @@ -19,6 +19,9 @@ export 'src/realtime_message.dart'; export 'src/input_file.dart'; part 'query.dart'; +part 'permission.dart'; +part 'role.dart'; +part 'id.dart'; part 'services/account.dart'; part 'services/avatars.dart'; part 'services/databases.dart'; diff --git a/lib/id.dart b/lib/id.dart new file mode 100644 index 0000000..257a4f7 --- /dev/null +++ b/lib/id.dart @@ -0,0 +1,11 @@ +part of appwrite; + +class ID { + static String unique() { + return 'unique()'; + } + + static String custom(String id) { + return id; + } +} \ No newline at end of file diff --git a/lib/models.dart b/lib/models.dart index 3b0d8d9..47f5cce 100644 --- a/lib/models.dart +++ b/lib/models.dart @@ -15,7 +15,7 @@ part 'src/models/currency_list.dart'; part 'src/models/phone_list.dart'; part 'src/models/document.dart'; part 'src/models/log.dart'; -part 'src/models/user.dart'; +part 'src/models/account.dart'; part 'src/models/preferences.dart'; part 'src/models/session.dart'; part 'src/models/token.dart'; diff --git a/lib/permission.dart b/lib/permission.dart new file mode 100644 index 0000000..330be95 --- /dev/null +++ b/lib/permission.dart @@ -0,0 +1,19 @@ +part of appwrite; + +class Permission { + static String read(String role) { + return 'read("$role")'; + } + static String write(String role) { + return 'write("$role")'; + } + static String create(String role) { + return 'create("$role")'; + } + static String update(String role) { + return 'update("$role")'; + } + static String delete(String role) { + return 'delete("$role")'; + } +} diff --git a/lib/query.dart b/lib/query.dart index e9dd0a2..41a4449 100644 --- a/lib/query.dart +++ b/lib/query.dart @@ -7,25 +7,37 @@ class Query { static notEqual(String attribute, dynamic value) => _addQuery(attribute, 'notEqual', value); - static lesser(String attribute, dynamic value) => - _addQuery(attribute, 'lesser', value); + static lessThan(String attribute, dynamic value) => + _addQuery(attribute, 'lessThan', value); - static lesserEqual(String attribute, dynamic value) => - _addQuery(attribute, 'lesserEqual', value); + static lessThanEqual(String attribute, dynamic value) => + _addQuery(attribute, 'lessThanEqual', value); - static greater(String attribute, dynamic value) => - _addQuery(attribute, 'greater', value); + static greaterThan(String attribute, dynamic value) => + _addQuery(attribute, 'greaterThan', value); - static greaterEqual(String attribute, dynamic value) => - _addQuery(attribute, 'greaterEqual', value); + static greaterThanEqual(String attribute, dynamic value) => + _addQuery(attribute, 'greaterThanEqual', value); static search(String attribute, String value) => _addQuery(attribute, 'search', value); - static String _addQuery(String attribute, String oper, dynamic value) => (value + static String orderAsc(String attribute) => 'orderAsc("$attribute")'; + + static String orderDesc(String attribute) => 'orderDesc("$attribute")'; + + static String cursorBefore(String id) => 'cursorBefore("$id")'; + + static String cursorAfter(String id) => 'cursorAfter("$id")'; + + static String limit(int limit) => 'limit($limit)'; + + static String offset(int offset) => 'offset($offset)'; + + static String _addQuery(String attribute, String method, dynamic value) => (value is List) - ? '$attribute.$oper(${value.map((item) => parseValues(item)).join(",")})' - : '$attribute.$oper(${parseValues(value)})'; + ? '$method("$attribute", [${value.map((item) => parseValues(item)).join(",")}])' + : '$method("$attribute", [${parseValues(value)}])'; static String parseValues(dynamic value) => (value is String) ? '"$value"' : '$value'; diff --git a/lib/role.dart b/lib/role.dart new file mode 100644 index 0000000..c3f2c81 --- /dev/null +++ b/lib/role.dart @@ -0,0 +1,30 @@ +part of appwrite; + +class Role { + static String any() { + return 'any'; + } + + static String user(String id) { + return 'user:$id'; + } + + static String users() { + return 'users'; + } + + static String guests() { + return 'guests'; + } + + static String team(String id, [String role = '']) { + if(role.isEmpty) { + return 'team:$id'; + } + return 'team:$id/$role'; + } + + static String status(String status) { + return 'status:$status'; + } +} \ No newline at end of file diff --git a/lib/services/account.dart b/lib/services/account.dart index d88a28c..ab9dd5f 100644 --- a/lib/services/account.dart +++ b/lib/services/account.dart @@ -2,13 +2,13 @@ part of appwrite; /// The Account service allows you to authenticate and manage a user account. class Account extends Service { - Account(Client client): super(client); + Account(super.client); /// Get Account /// /// Get currently logged in user data as JSON object. /// - Future get() async { + Future get() async { const String path = '/account'; final Map params = { @@ -20,7 +20,7 @@ class Account extends Service { final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers); - return models.User.fromMap(res.data); + return models.Account.fromMap(res.data); } @@ -33,7 +33,7 @@ class Account extends Service { /// login to their new account, you need to create a new [account /// session](/docs/client/account#accountCreateSession). /// - Future create({required String userId, required String email, required String password, String? name}) async { + Future create({required String userId, required String email, required String password, String? name}) async { const String path = '/account'; final Map params = { @@ -49,7 +49,7 @@ class Account extends Service { final res = await client.call(HttpMethod.post, path: path, params: params, headers: headers); - return models.User.fromMap(res.data); + return models.Account.fromMap(res.data); } @@ -64,7 +64,7 @@ class Account extends Service { /// one, by passing an email address and a new password. /// /// - Future updateEmail({required String email, required String password}) async { + Future updateEmail({required String email, required String password}) async { const String path = '/account/email'; final Map params = { @@ -78,7 +78,7 @@ class Account extends Service { final res = await client.call(HttpMethod.patch, path: path, params: params, headers: headers); - return models.User.fromMap(res.data); + return models.Account.fromMap(res.data); } @@ -111,12 +111,11 @@ class Account extends Service { /// Get currently logged in user list of latest security activity logs. Each /// log returns user IP address, location and date and time of log. /// - Future getLogs({int? limit, int? offset}) async { + Future getLogs({List? queries}) async { const String path = '/account/logs'; final Map params = { - 'limit': limit, - 'offset': offset, + 'queries': queries, }; final Map headers = { @@ -133,7 +132,7 @@ class Account extends Service { /// /// Update currently logged in user account name. /// - Future updateName({required String name}) async { + Future updateName({required String name}) async { const String path = '/account/name'; final Map params = { @@ -146,7 +145,7 @@ class Account extends Service { final res = await client.call(HttpMethod.patch, path: path, params: params, headers: headers); - return models.User.fromMap(res.data); + return models.Account.fromMap(res.data); } @@ -156,7 +155,7 @@ class Account extends Service { /// to pass in the new password, and the old password. For users created with /// OAuth, Team Invites and Magic URL, oldPassword is optional. /// - Future updatePassword({required String password, String? oldPassword}) async { + Future updatePassword({required String password, String? oldPassword}) async { const String path = '/account/password'; final Map params = { @@ -170,7 +169,7 @@ class Account extends Service { final res = await client.call(HttpMethod.patch, path: path, params: params, headers: headers); - return models.User.fromMap(res.data); + return models.Account.fromMap(res.data); } @@ -182,11 +181,11 @@ class Account extends Service { /// /account/verification/phone](/docs/client/account#accountCreatePhoneVerification) /// endpoint to send a confirmation SMS. /// - Future updatePhone({required String number, required String password}) async { + Future updatePhone({required String phone, required String password}) async { const String path = '/account/phone'; final Map params = { - 'number': number, + 'phone': phone, 'password': password, }; @@ -196,7 +195,7 @@ class Account extends Service { final res = await client.call(HttpMethod.patch, path: path, params: params, headers: headers); - return models.User.fromMap(res.data); + return models.Account.fromMap(res.data); } @@ -226,7 +225,7 @@ class Account extends Service { /// 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 { const String path = '/account/prefs'; final Map params = { @@ -239,7 +238,7 @@ class Account extends Service { final res = await client.call(HttpMethod.patch, path: path, params: params, headers: headers); - return models.User.fromMap(res.data); + return models.Account.fromMap(res.data); } @@ -396,9 +395,10 @@ class Account extends Service { /// Create Magic URL session /// - /// Sends the user an email with a secret key for creating a session. When the - /// user clicks the link in the email, the user is redirected back to the URL - /// you provided with the secret key and userId values attached to the URL + /// Sends the user an email with a secret key for creating a session. If the + /// provided user ID has not be registered, a new user will be created. When + /// the user clicks the link in the email, the user is redirected back to the + /// URL you provided with the secret key and userId values attached to the URL /// query string. Use the query string parameters to submit a request to the /// [PUT /// /account/sessions/magic-url](/docs/client/account#accountUpdateMagicURLSession) @@ -473,7 +473,7 @@ class Account extends Service { /// user.. /// /// - Future createOAuth2Session({required String provider, String? success, String? failure, List? scopes}) async { + Future createOAuth2Session({required String provider, String? success, String? failure, List? scopes}) async { final String path = '/account/sessions/oauth2/{provider}'.replaceAll('{provider}', provider); final Map params = { @@ -517,12 +517,12 @@ class Account extends Service { /// endpoint to complete the login process. The secret sent to the user's phone /// is valid for 15 minutes. /// - Future createPhoneSession({required String userId, required String number}) async { + Future createPhoneSession({required String userId, required String phone}) async { const String path = '/account/sessions/phone'; final Map params = { 'userId': userId, - 'number': number, + 'phone': phone, }; final Map headers = { @@ -535,7 +535,7 @@ class Account extends Service { } - /// Create Phone session (confirmation) + /// Create Phone Session (confirmation) /// /// Use this endpoint to complete creating a session with SMS. Use the /// **userId** from the @@ -633,7 +633,7 @@ class Account extends Service { /// record is not deleted but permanently blocked from any access. To /// completely delete a user, use the Users API instead. /// - Future updateStatus() async { + Future updateStatus() async { const String path = '/account/status'; final Map params = { @@ -645,7 +645,7 @@ class Account extends Service { final res = await client.call(HttpMethod.patch, path: path, params: params, headers: headers); - return models.User.fromMap(res.data); + return models.Account.fromMap(res.data); } diff --git a/lib/services/avatars.dart b/lib/services/avatars.dart index 28f43ff..52d0535 100644 --- a/lib/services/avatars.dart +++ b/lib/services/avatars.dart @@ -3,7 +3,7 @@ part of appwrite; /// The Avatars service aims to help you complete everyday tasks related to /// your app image, icons, and avatars. class Avatars extends Service { - Avatars(Client client): super(client); + Avatars(super.client); /// Get Browser Icon /// @@ -85,7 +85,8 @@ class Avatars extends Service { /// /// You can use this endpoint to show different country flags icons to your /// users. The code argument receives the 2 letter country code. Use width, - /// height and quality arguments to change the output settings. + /// height and quality arguments to change the output settings. Country codes + /// follow the [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) standard. /// /// When one dimension is specified and the other is 0, the image is scaled /// with preserved aspect ratio. If both dimensions are 0, the API provides an diff --git a/lib/services/databases.dart b/lib/services/databases.dart index c7323b7..2511b08 100644 --- a/lib/services/databases.dart +++ b/lib/services/databases.dart @@ -3,21 +3,20 @@ part of appwrite; /// The Databases service allows you to create structured collections of /// documents, query and filter lists of documents class Databases extends Service { - Databases(Client client, {required this.databaseId}): super(client); - String databaseId; + Databases(super.client); /// List Documents - Future listDocuments({required String collectionId, List? queries, int? limit, int? offset, String? cursor, String? cursorDirection, List? orderAttributes, List? orderTypes}) async { + /// + /// Get a list of all the user's documents in a given collection. You can use + /// the query params to filter your results. On admin mode, this endpoint will + /// return a list of all of documents belonging to the provided collectionId. + /// [Learn more about different API modes](/docs/admin). + /// + Future listDocuments({required String databaseId, required String collectionId, List? queries}) async { final String path = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); final Map params = { 'queries': queries, - 'limit': limit, - 'offset': offset, - 'cursor': cursor, - 'cursorDirection': cursorDirection, - 'orderAttributes': orderAttributes, - 'orderTypes': orderTypes, }; final Map headers = { @@ -31,14 +30,19 @@ class Databases extends Service { } /// Create Document - Future createDocument({required String collectionId, required String documentId, required Map data, List? read, List? write}) async { + /// + /// Create a new Document. Before using this route, you should create a new + /// collection resource using either a [server + /// integration](/docs/server/databases#databasesCreateCollection) API or + /// directly from your database console. + /// + Future createDocument({required String databaseId, required String collectionId, required String documentId, required Map data, List? permissions}) async { final String path = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); final Map params = { 'documentId': documentId, 'data': data, - 'read': read, - 'write': write, + 'permissions': permissions, }; final Map headers = { @@ -52,7 +56,11 @@ class Databases extends Service { } /// Get Document - Future getDocument({required String collectionId, required String documentId}) async { + /// + /// Get a document by its unique ID. This endpoint response returns a JSON + /// object with the document data. + /// + Future getDocument({required String databaseId, required String collectionId, required String documentId}) async { final String path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); final Map params = { @@ -69,13 +77,16 @@ class Databases extends Service { } /// Update Document - Future updateDocument({required String collectionId, required String documentId, Map? data, List? read, List? write}) async { + /// + /// Update a document by its unique ID. Using the patch method you can pass + /// only specific fields that will get updated. + /// + Future updateDocument({required String databaseId, required String collectionId, required String documentId, Map? data, List? permissions}) async { final String path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); final Map params = { 'data': data, - 'read': read, - 'write': write, + 'permissions': permissions, }; final Map headers = { @@ -89,7 +100,10 @@ class Databases extends Service { } /// Delete Document - Future deleteDocument({required String collectionId, required String documentId}) async { + /// + /// Delete a document by its unique ID. + /// + Future deleteDocument({required String databaseId, required String collectionId, required String documentId}) async { final String path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); final Map params = { diff --git a/lib/services/functions.dart b/lib/services/functions.dart index 2592baa..d733ce2 100644 --- a/lib/services/functions.dart +++ b/lib/services/functions.dart @@ -3,7 +3,7 @@ part of appwrite; /// The Functions Service allows you view, create and manage your Cloud /// Functions. class Functions extends Service { - Functions(Client client): super(client); + Functions(super.client); /// Retry Build Future retryBuild({required String functionId, required String deploymentId, required String buildId}) async { @@ -29,15 +29,12 @@ class Functions extends Service { /// return a list of all of the project's executions. [Learn more about /// different API modes](/docs/admin). /// - Future listExecutions({required String functionId, int? limit, int? offset, String? search, String? cursor, String? cursorDirection}) async { + Future listExecutions({required String functionId, List? queries, String? search}) async { final String path = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); final Map params = { - 'limit': limit, - 'offset': offset, + 'queries': queries, 'search': search, - 'cursor': cursor, - 'cursorDirection': cursorDirection, }; final Map headers = { diff --git a/lib/services/locale.dart b/lib/services/locale.dart index 937ebd5..be42798 100644 --- a/lib/services/locale.dart +++ b/lib/services/locale.dart @@ -3,7 +3,7 @@ part of appwrite; /// The Locale service allows you to customize your app based on your users' /// location. class Locale extends Service { - Locale(Client client): super(client); + Locale(super.client); /// Get User Locale /// diff --git a/lib/services/storage.dart b/lib/services/storage.dart index 37fbd58..595c6f7 100644 --- a/lib/services/storage.dart +++ b/lib/services/storage.dart @@ -2,7 +2,7 @@ part of appwrite; /// The Storage service allows you to manage your project files. class Storage extends Service { - Storage(Client client): super(client); + Storage(super.client); /// List Files /// @@ -10,16 +10,12 @@ class Storage extends Service { /// your results. On admin mode, this endpoint will return a list of all of the /// project's files. [Learn more about different API modes](/docs/admin). /// - Future listFiles({required String bucketId, String? search, int? limit, int? offset, String? cursor, String? cursorDirection, String? orderType}) async { + Future listFiles({required String bucketId, List? queries, String? search}) async { final String path = '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); final Map params = { + 'queries': queries, 'search': search, - 'limit': limit, - 'offset': offset, - 'cursor': cursor, - 'cursorDirection': cursorDirection, - 'orderType': orderType, }; final Map headers = { @@ -36,8 +32,8 @@ class Storage extends Service { /// /// Create a new file. Before using this route, you should create a new bucket /// resource using either a [server - /// integration](/docs/server/database#storageCreateBucket) API or directly - /// from your Appwrite console. + /// integration](/docs/server/storage#storageCreateBucket) API or directly from + /// your Appwrite console. /// /// Larger files should be uploaded using multiple requests with the /// [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range) @@ -53,7 +49,7 @@ class Storage extends Service { /// chunking logic will be managed by the SDK internally. /// /// - Future createFile({required String bucketId, required String fileId, required InputFile file, List? read, List? write, Function(UploadProgress)? onProgress}) async { + Future createFile({required String bucketId, required String fileId, required InputFile file, List? permissions, Function(UploadProgress)? onProgress}) async { final String path = '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); final Map params = { @@ -61,8 +57,7 @@ class Storage extends Service { 'fileId': fileId, 'file': file, - 'read': read, - 'write': write, + 'permissions': permissions, }; final Map headers = { @@ -111,12 +106,11 @@ class Storage extends Service { /// 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, List? read, List? write}) async { + Future updateFile({required String bucketId, required String fileId, List? permissions}) async { final String path = '/storage/buckets/{bucketId}/files/{fileId}'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); final Map params = { - 'read': read, - 'write': write, + 'permissions': permissions, }; final Map headers = { diff --git a/lib/services/teams.dart b/lib/services/teams.dart index 7eca108..ec83839 100644 --- a/lib/services/teams.dart +++ b/lib/services/teams.dart @@ -3,7 +3,7 @@ part of appwrite; /// The Teams service allows you to group users of your project and to enable /// them to share read and write access to your project resources class Teams extends Service { - Teams(Client client): super(client); + Teams(super.client); /// List Teams /// @@ -13,16 +13,12 @@ class Teams extends Service { /// In admin mode, this endpoint returns a list of all the teams in the current /// project. [Learn more about different API modes](/docs/admin). /// - Future list({String? search, int? limit, int? offset, String? cursor, String? cursorDirection, String? orderType}) async { + Future list({List? queries, String? search}) async { const String path = '/teams'; final Map params = { + 'queries': queries, 'search': search, - 'limit': limit, - 'offset': offset, - 'cursor': cursor, - 'cursorDirection': cursorDirection, - 'orderType': orderType, }; final Map headers = { @@ -41,7 +37,7 @@ class Teams extends Service { /// assigned as the owner of the team. Only the users with the owner role can /// invite new members, add new owners and delete or update the team. /// - Future create({required String teamId, required String name, List? roles}) async { + Future create({required String teamId, required String name, List? roles}) async { const String path = '/teams'; final Map params = { @@ -128,16 +124,12 @@ 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. /// - Future getMemberships({required String teamId, String? search, int? limit, int? offset, String? cursor, String? cursorDirection, String? orderType}) async { + Future getMemberships({required String teamId, List? queries, String? search}) async { final String path = '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); final Map params = { + 'queries': queries, 'search': search, - 'limit': limit, - 'offset': offset, - 'cursor': cursor, - 'cursorDirection': cursorDirection, - 'orderType': orderType, }; final Map headers = { @@ -168,7 +160,7 @@ class Teams extends Service { /// the only valid redirect URL's are the once from domains you have set when /// adding your platforms in the console interface. /// - Future createMembership({required String teamId, required String email, required List roles, required String url, String? name}) async { + Future createMembership({required String teamId, required String email, required List roles, required String url, String? name}) async { final String path = '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); final Map params = { @@ -215,7 +207,7 @@ class Teams extends Service { /// have access to this endpoint. Learn more about [roles and /// permissions](/docs/permissions). /// - Future updateMembershipRoles({required String teamId, required String membershipId, required List roles}) async { + Future updateMembershipRoles({required String teamId, required String membershipId, required List roles}) async { final String path = '/teams/{teamId}/memberships/{membershipId}'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); final Map params = { diff --git a/lib/src/client_browser.dart b/lib/src/client_browser.dart index e50bf2f..704cce1 100644 --- a/lib/src/client_browser.dart +++ b/lib/src/client_browser.dart @@ -40,8 +40,11 @@ class ClientBrowser extends ClientBase with ClientMixin { .replaceFirst('http://', 'ws://'); _headers = { 'content-type': 'application/json', - 'x-sdk-version': 'appwrite:flutter:7.0.0', - 'X-Appwrite-Response-Format' : '0.15.0', + 'x-sdk-name': 'Flutter', + 'x-sdk-platform': 'client', + 'x-sdk-language': 'flutter', + 'x-sdk-version': '8.0.0-dev.1', + 'X-Appwrite-Response-Format' : '1.0.0-RC1', }; config = {}; diff --git a/lib/src/client_io.dart b/lib/src/client_io.dart index 666f794..0da90bd 100644 --- a/lib/src/client_io.dart +++ b/lib/src/client_io.dart @@ -49,7 +49,7 @@ class ClientIO extends ClientBase with ClientMixin { String? get endPointRealtime => _endPointRealtime; ClientIO({ - String endPoint = 'https://appwrite.io/v1', + String endPoint = 'https://HOSTNAME/v1', this.selfSigned = false, }) : _endPoint = endPoint { _nativeClient = HttpClient() @@ -61,8 +61,11 @@ class ClientIO extends ClientBase with ClientMixin { .replaceFirst('http://', 'ws://'); _headers = { 'content-type': 'application/json', - 'x-sdk-version': 'appwrite:flutter:7.0.0', - 'X-Appwrite-Response-Format' : '0.15.0', + 'x-sdk-name': 'Flutter', + 'x-sdk-platform': 'client', + 'x-sdk-language': 'flutter', + 'x-sdk-version': '8.0.0-dev.1', + 'X-Appwrite-Response-Format' : '1.0.0-RC1', }; config = {}; diff --git a/lib/src/exception.dart b/lib/src/exception.dart index 5887d8d..a5c6a9f 100644 --- a/lib/src/exception.dart +++ b/lib/src/exception.dart @@ -1,11 +1,11 @@ class AppwriteException implements Exception { final String? message; - final int? code; final String? type; + final int? code; final dynamic response; AppwriteException([this.message = "", this.code, this.type, this.response]); - + @override String toString() { if (message == null) return "AppwriteException"; diff --git a/lib/src/input_file.dart b/lib/src/input_file.dart index 46bdd0a..5a32192 100644 --- a/lib/src/input_file.dart +++ b/lib/src/input_file.dart @@ -1,4 +1,3 @@ -import 'package:flutter/foundation.dart'; import 'exception.dart'; class InputFile { @@ -10,10 +9,8 @@ class InputFile { /// Provide a file, use `path` for IO platforms /// and provide `bytes` for web platform InputFile({this.path, this.filename, this.contentType, this.bytes}) { - if (kIsWeb && bytes == null) { - throw AppwriteException('On web `bytes` is required'); - } else if(!kIsWeb && path == null && bytes == null) { - throw AppwriteException('On IO platforms one of `path` or `bytes` is required'); + if (path == null && bytes == null) { + throw AppwriteException('One of `path` or `bytes` is required'); } } } diff --git a/lib/src/models/user.dart b/lib/src/models/account.dart similarity index 71% rename from lib/src/models/user.dart rename to lib/src/models/account.dart index e27668c..a1d3b6c 100644 --- a/lib/src/models/user.dart +++ b/lib/src/models/account.dart @@ -1,21 +1,21 @@ part of appwrite.models; -/// User -class User implements Model { +/// Account +class Account implements Model { /// User ID. final String $id; - /// User creation date in Unix timestamp. - final int $createdAt; - /// User update date in Unix timestamp. - final int $updatedAt; + /// User creation date in ISO 8601 format. + final String $createdAt; + /// User update date in ISO 8601 format. + final String $updatedAt; /// User name. final String name; - /// User registration date in Unix timestamp. - final int registration; + /// User registration date in ISO 8601 format. + final String registration; /// User status. Pass `true` for enabled and `false` for disabled. final bool status; - /// Unix timestamp of the most recent password update - final int passwordUpdate; + /// Password update time in ISO 8601 format. + final String passwordUpdate; /// User email address. final String email; /// User phone number in E.164 format. @@ -27,8 +27,7 @@ class User implements Model { /// User preferences as a key-value object final Preferences prefs; - User({ - required this.$id, + Account({ required this.$id, required this.$createdAt, required this.$updatedAt, required this.name, @@ -42,15 +41,15 @@ class User implements Model { required this.prefs, }); - factory User.fromMap(Map map) { - return User( + factory Account.fromMap(Map map) { + return Account( $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'], - $updatedAt: map['\$updatedAt'], + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), name: map['name'].toString(), - registration: map['registration'], + registration: map['registration'].toString(), status: map['status'], - passwordUpdate: map['passwordUpdate'], + passwordUpdate: map['passwordUpdate'].toString(), email: map['email'].toString(), phone: map['phone'].toString(), emailVerification: map['emailVerification'], @@ -59,7 +58,6 @@ class User implements Model { ); } - @override Map toMap() { return { "\$id": $id, diff --git a/lib/src/models/continent.dart b/lib/src/models/continent.dart index 6b26500..c9c4e56 100644 --- a/lib/src/models/continent.dart +++ b/lib/src/models/continent.dart @@ -7,8 +7,7 @@ class Continent implements Model { /// Continent two letter code. final String code; - Continent({ - required this.name, + Continent({ required this.name, required this.code, }); @@ -19,7 +18,6 @@ class Continent implements Model { ); } - @override Map toMap() { return { "name": name, diff --git a/lib/src/models/continent_list.dart b/lib/src/models/continent_list.dart index 254264f..6325f65 100644 --- a/lib/src/models/continent_list.dart +++ b/lib/src/models/continent_list.dart @@ -7,8 +7,7 @@ class ContinentList implements Model { /// List of continents. final List continents; - ContinentList({ - required this.total, + ContinentList({ required this.total, required this.continents, }); @@ -19,7 +18,6 @@ class ContinentList implements Model { ); } - @override Map toMap() { return { "total": total, diff --git a/lib/src/models/country.dart b/lib/src/models/country.dart index e5b8131..4ab0435 100644 --- a/lib/src/models/country.dart +++ b/lib/src/models/country.dart @@ -7,8 +7,7 @@ class Country implements Model { /// Country two-character ISO 3166-1 alpha code. final String code; - Country({ - required this.name, + Country({ required this.name, required this.code, }); @@ -19,7 +18,6 @@ class Country implements Model { ); } - @override Map toMap() { return { "name": name, diff --git a/lib/src/models/country_list.dart b/lib/src/models/country_list.dart index 5c62416..f2e461a 100644 --- a/lib/src/models/country_list.dart +++ b/lib/src/models/country_list.dart @@ -7,8 +7,7 @@ class CountryList implements Model { /// List of countries. final List countries; - CountryList({ - required this.total, + CountryList({ required this.total, required this.countries, }); @@ -19,7 +18,6 @@ class CountryList implements Model { ); } - @override Map toMap() { return { "total": total, diff --git a/lib/src/models/currency.dart b/lib/src/models/currency.dart index 37a88f5..c14963b 100644 --- a/lib/src/models/currency.dart +++ b/lib/src/models/currency.dart @@ -17,8 +17,7 @@ class Currency implements Model { /// Currency plural name final String namePlural; - Currency({ - required this.symbol, + Currency({ required this.symbol, required this.name, required this.symbolNative, required this.decimalDigits, @@ -39,7 +38,6 @@ class Currency implements Model { ); } - @override Map toMap() { return { "symbol": symbol, diff --git a/lib/src/models/currency_list.dart b/lib/src/models/currency_list.dart index 23ef9a7..769bf7f 100644 --- a/lib/src/models/currency_list.dart +++ b/lib/src/models/currency_list.dart @@ -7,8 +7,7 @@ class CurrencyList implements Model { /// List of currencies. final List currencies; - CurrencyList({ - required this.total, + CurrencyList({ required this.total, required this.currencies, }); @@ -19,7 +18,6 @@ class CurrencyList implements Model { ); } - @override Map toMap() { return { "total": total, diff --git a/lib/src/models/document.dart b/lib/src/models/document.dart index 7051104..f1060ce 100644 --- a/lib/src/models/document.dart +++ b/lib/src/models/document.dart @@ -6,23 +6,19 @@ class Document implements Model { final String $id; /// Collection ID. final String $collection; - /// Document creation date in Unix timestamp. - final int $createdAt; - /// Document update date in Unix timestamp. - final int $updatedAt; - /// Document read permissions. - final List $read; - /// Document write permissions. - final List $write; + /// Document creation date in ISO 8601 format. + final String $createdAt; + /// Document update date in ISO 8601 format. + final String $updatedAt; + /// Document permissions. [Learn more about permissions](/docs/permissions). + final List $permissions; final Map data; - Document({ - required this.$id, + Document({ required this.$id, required this.$collection, required this.$createdAt, required this.$updatedAt, - required this.$read, - required this.$write, + required this.$permissions, required this.data, }); @@ -30,23 +26,20 @@ class Document implements Model { return Document( $id: map['\$id'].toString(), $collection: map['\$collection'].toString(), - $createdAt: map['\$createdAt'], - $updatedAt: map['\$updatedAt'], - $read: map['\$read'], - $write: map['\$write'], + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: map['\$permissions'], data: map, ); } - @override Map toMap() { return { "\$id": $id, "\$collection": $collection, "\$createdAt": $createdAt, "\$updatedAt": $updatedAt, - "\$read": $read, - "\$write": $write, + "\$permissions": $permissions, "data": data, }; } diff --git a/lib/src/models/document_list.dart b/lib/src/models/document_list.dart index a98d9c8..fb054a2 100644 --- a/lib/src/models/document_list.dart +++ b/lib/src/models/document_list.dart @@ -7,8 +7,7 @@ class DocumentList implements Model { /// List of documents. final List documents; - DocumentList({ - required this.total, + DocumentList({ required this.total, required this.documents, }); @@ -19,7 +18,6 @@ class DocumentList implements Model { ); } - @override Map toMap() { return { "total": total, diff --git a/lib/src/models/execution.dart b/lib/src/models/execution.dart index 2e9dfbc..8ccc195 100644 --- a/lib/src/models/execution.dart +++ b/lib/src/models/execution.dart @@ -4,12 +4,12 @@ part of appwrite.models; class Execution implements Model { /// Execution ID. final String $id; - /// Execution creation date in Unix timestamp. - final int $createdAt; - /// Execution update date in Unix timestamp. - final int $updatedAt; - /// Execution read permissions. - final List $read; + /// Execution creation date in ISO 8601 format. + final String $createdAt; + /// Execution upate date in ISO 8601 format. + final String $updatedAt; + /// Execution roles. + final List $permissions; /// Function ID. final String functionId; /// The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. @@ -20,21 +20,23 @@ class Execution implements Model { final int statusCode; /// The script response output string. Logs the last 4,000 characters of the execution response output. final String response; - /// The script stderr output string. Logs the last 4,000 characters of the execution stderr output + /// The script stdout output string. Logs the last 4,000 characters of the execution stdout output. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. + final String stdout; + /// The script stderr output string. Logs the last 4,000 characters of the execution stderr output. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. final String stderr; /// The script execution time in seconds. final double time; - Execution({ - required this.$id, + Execution({ required this.$id, required this.$createdAt, required this.$updatedAt, - required this.$read, + required this.$permissions, required this.functionId, required this.trigger, required this.status, required this.statusCode, required this.response, + required this.stdout, required this.stderr, required this.time, }); @@ -42,31 +44,32 @@ class Execution implements Model { factory Execution.fromMap(Map map) { return Execution( $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'], - $updatedAt: map['\$updatedAt'], - $read: map['\$read'], + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: map['\$permissions'], functionId: map['functionId'].toString(), trigger: map['trigger'].toString(), status: map['status'].toString(), statusCode: map['statusCode'], response: map['response'].toString(), + stdout: map['stdout'].toString(), stderr: map['stderr'].toString(), time: map['time'].toDouble(), ); } - @override Map toMap() { return { "\$id": $id, "\$createdAt": $createdAt, "\$updatedAt": $updatedAt, - "\$read": $read, + "\$permissions": $permissions, "functionId": functionId, "trigger": trigger, "status": status, "statusCode": statusCode, "response": response, + "stdout": stdout, "stderr": stderr, "time": time, }; diff --git a/lib/src/models/execution_list.dart b/lib/src/models/execution_list.dart index 77a4133..12bd2c1 100644 --- a/lib/src/models/execution_list.dart +++ b/lib/src/models/execution_list.dart @@ -7,8 +7,7 @@ class ExecutionList implements Model { /// List of executions. final List executions; - ExecutionList({ - required this.total, + ExecutionList({ required this.total, required this.executions, }); @@ -19,7 +18,6 @@ class ExecutionList implements Model { ); } - @override Map toMap() { return { "total": total, diff --git a/lib/src/models/file.dart b/lib/src/models/file.dart index aa86db7..8eae915 100644 --- a/lib/src/models/file.dart +++ b/lib/src/models/file.dart @@ -6,14 +6,12 @@ class File implements Model { final String $id; /// Bucket ID. final String bucketId; - /// File creation date in Unix timestamp. - final int $createdAt; - /// File update date in Unix timestamp. - final int $updatedAt; - /// File read permissions. - final List $read; - /// File write permissions. - final List $write; + /// File creation date in ISO 8601 format. + final String $createdAt; + /// File update date in ISO 8601 format. + final String $updatedAt; + /// File permissions. [Learn more about permissions](/docs/permissions). + final List $permissions; /// File name. final String name; /// File MD5 signature. @@ -27,13 +25,11 @@ class File implements Model { /// Total number of chunks uploaded final int chunksUploaded; - File({ - required this.$id, + File({ required this.$id, required this.bucketId, required this.$createdAt, required this.$updatedAt, - required this.$read, - required this.$write, + required this.$permissions, required this.name, required this.signature, required this.mimeType, @@ -46,10 +42,9 @@ class File implements Model { return File( $id: map['\$id'].toString(), bucketId: map['bucketId'].toString(), - $createdAt: map['\$createdAt'], - $updatedAt: map['\$updatedAt'], - $read: map['\$read'], - $write: map['\$write'], + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + $permissions: map['\$permissions'], name: map['name'].toString(), signature: map['signature'].toString(), mimeType: map['mimeType'].toString(), @@ -59,15 +54,13 @@ class File implements Model { ); } - @override Map toMap() { return { "\$id": $id, "bucketId": bucketId, "\$createdAt": $createdAt, "\$updatedAt": $updatedAt, - "\$read": $read, - "\$write": $write, + "\$permissions": $permissions, "name": name, "signature": signature, "mimeType": mimeType, diff --git a/lib/src/models/file_list.dart b/lib/src/models/file_list.dart index dc22032..b44d70c 100644 --- a/lib/src/models/file_list.dart +++ b/lib/src/models/file_list.dart @@ -7,8 +7,7 @@ class FileList implements Model { /// List of files. final List files; - FileList({ - required this.total, + FileList({ required this.total, required this.files, }); @@ -19,7 +18,6 @@ class FileList implements Model { ); } - @override Map toMap() { return { "total": total, diff --git a/lib/src/models/jwt.dart b/lib/src/models/jwt.dart index 6c59156..df5750e 100644 --- a/lib/src/models/jwt.dart +++ b/lib/src/models/jwt.dart @@ -5,8 +5,7 @@ class Jwt implements Model { /// JWT encoded string. final String jwt; - Jwt({ - required this.jwt, + Jwt({ required this.jwt, }); factory Jwt.fromMap(Map map) { @@ -15,7 +14,6 @@ class Jwt implements Model { ); } - @override Map toMap() { return { "jwt": jwt, diff --git a/lib/src/models/language.dart b/lib/src/models/language.dart index ac394f5..5ca2729 100644 --- a/lib/src/models/language.dart +++ b/lib/src/models/language.dart @@ -9,8 +9,7 @@ class Language implements Model { /// Language native name. final String nativeName; - Language({ - required this.name, + Language({ required this.name, required this.code, required this.nativeName, }); @@ -23,7 +22,6 @@ class Language implements Model { ); } - @override Map toMap() { return { "name": name, diff --git a/lib/src/models/language_list.dart b/lib/src/models/language_list.dart index ee3e993..e642f1c 100644 --- a/lib/src/models/language_list.dart +++ b/lib/src/models/language_list.dart @@ -7,8 +7,7 @@ class LanguageList implements Model { /// List of languages. final List languages; - LanguageList({ - required this.total, + LanguageList({ required this.total, required this.languages, }); @@ -19,7 +18,6 @@ class LanguageList implements Model { ); } - @override Map toMap() { return { "total": total, diff --git a/lib/src/models/locale.dart b/lib/src/models/locale.dart index 97bee76..666d372 100644 --- a/lib/src/models/locale.dart +++ b/lib/src/models/locale.dart @@ -17,8 +17,7 @@ class Locale implements Model { /// Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format final String currency; - Locale({ - required this.ip, + Locale({ required this.ip, required this.countryCode, required this.country, required this.continentCode, @@ -39,7 +38,6 @@ class Locale implements Model { ); } - @override Map toMap() { return { "ip": ip, diff --git a/lib/src/models/log.dart b/lib/src/models/log.dart index f6675fa..c7a8745 100644 --- a/lib/src/models/log.dart +++ b/lib/src/models/log.dart @@ -14,8 +14,8 @@ class Log implements Model { final String mode; /// IP session in use when the session was created. final String ip; - /// Log creation time in Unix timestamp. - final int time; + /// Log creation date in ISO 8601 format. + final String time; /// Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). final String osCode; /// Operating system name. @@ -45,8 +45,7 @@ class Log implements Model { /// Country name. final String countryName; - Log({ - required this.event, + Log({ required this.event, required this.userId, required this.userEmail, required this.userName, @@ -77,7 +76,7 @@ class Log implements Model { userName: map['userName'].toString(), mode: map['mode'].toString(), ip: map['ip'].toString(), - time: map['time'], + time: map['time'].toString(), osCode: map['osCode'].toString(), osName: map['osName'].toString(), osVersion: map['osVersion'].toString(), @@ -95,7 +94,6 @@ class Log implements Model { ); } - @override Map toMap() { return { "event": event, diff --git a/lib/src/models/log_list.dart b/lib/src/models/log_list.dart index bb71020..ebedb65 100644 --- a/lib/src/models/log_list.dart +++ b/lib/src/models/log_list.dart @@ -7,8 +7,7 @@ class LogList implements Model { /// List of logs. final List logs; - LogList({ - required this.total, + LogList({ required this.total, required this.logs, }); @@ -19,7 +18,6 @@ class LogList implements Model { ); } - @override Map toMap() { return { "total": total, diff --git a/lib/src/models/membership.dart b/lib/src/models/membership.dart index 1805d1f..4949360 100644 --- a/lib/src/models/membership.dart +++ b/lib/src/models/membership.dart @@ -4,10 +4,10 @@ part of appwrite.models; class Membership implements Model { /// Membership ID. final String $id; - /// Membership creation date in Unix timestamp. - final int $createdAt; - /// Membership update date in Unix timestamp. - final int $updatedAt; + /// Membership creation date in ISO 8601 format. + final String $createdAt; + /// Membership update date in ISO 8601 format. + final String $updatedAt; /// User ID. final String userId; /// User name. @@ -18,17 +18,16 @@ class Membership implements Model { final String teamId; /// Team name. final String teamName; - /// Date, the user has been invited to join the team in Unix timestamp. - final int invited; - /// Date, the user has accepted the invitation to join the team in Unix timestamp. - final int joined; + /// Date, the user has been invited to join the team in ISO 8601 format. + final String invited; + /// Date, the user has accepted the invitation to join the team in ISO 8601 format. + final String joined; /// User confirmation status, true if the user has joined the team or false otherwise. final bool confirm; /// User list of roles final List roles; - Membership({ - required this.$id, + Membership({ required this.$id, required this.$createdAt, required this.$updatedAt, required this.userId, @@ -45,21 +44,20 @@ class Membership implements Model { factory Membership.fromMap(Map map) { return Membership( $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'], - $updatedAt: map['\$updatedAt'], + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), userId: map['userId'].toString(), userName: map['userName'].toString(), userEmail: map['userEmail'].toString(), teamId: map['teamId'].toString(), teamName: map['teamName'].toString(), - invited: map['invited'], - joined: map['joined'], + invited: map['invited'].toString(), + joined: map['joined'].toString(), confirm: map['confirm'], roles: map['roles'], ); } - @override Map toMap() { return { "\$id": $id, diff --git a/lib/src/models/membership_list.dart b/lib/src/models/membership_list.dart index 329f724..c3335e3 100644 --- a/lib/src/models/membership_list.dart +++ b/lib/src/models/membership_list.dart @@ -7,8 +7,7 @@ class MembershipList implements Model { /// List of memberships. final List memberships; - MembershipList({ - required this.total, + MembershipList({ required this.total, required this.memberships, }); @@ -19,7 +18,6 @@ class MembershipList implements Model { ); } - @override Map toMap() { return { "total": total, diff --git a/lib/src/models/phone.dart b/lib/src/models/phone.dart index 7484970..1812504 100644 --- a/lib/src/models/phone.dart +++ b/lib/src/models/phone.dart @@ -9,8 +9,7 @@ class Phone implements Model { /// Country name. final String countryName; - Phone({ - required this.code, + Phone({ required this.code, required this.countryCode, required this.countryName, }); @@ -23,7 +22,6 @@ class Phone implements Model { ); } - @override Map toMap() { return { "code": code, diff --git a/lib/src/models/phone_list.dart b/lib/src/models/phone_list.dart index 8fa635b..0d2c6ba 100644 --- a/lib/src/models/phone_list.dart +++ b/lib/src/models/phone_list.dart @@ -7,8 +7,7 @@ class PhoneList implements Model { /// List of phones. final List phones; - PhoneList({ - required this.total, + PhoneList({ required this.total, required this.phones, }); @@ -19,7 +18,6 @@ class PhoneList implements Model { ); } - @override Map toMap() { return { "total": total, diff --git a/lib/src/models/preferences.dart b/lib/src/models/preferences.dart index 4c24a49..42cbdf2 100644 --- a/lib/src/models/preferences.dart +++ b/lib/src/models/preferences.dart @@ -4,8 +4,7 @@ part of appwrite.models; class Preferences implements Model { final Map data; - Preferences({ - required this.data, + Preferences({ required this.data, }); factory Preferences.fromMap(Map map) { @@ -14,7 +13,6 @@ class Preferences implements Model { ); } - @override Map toMap() { return { "data": data, diff --git a/lib/src/models/session.dart b/lib/src/models/session.dart index ae6ac10..296abe8 100644 --- a/lib/src/models/session.dart +++ b/lib/src/models/session.dart @@ -4,20 +4,20 @@ part of appwrite.models; class Session implements Model { /// Session ID. final String $id; - /// Session creation date in Unix timestamp. - final int $createdAt; + /// Session creation date in ISO 8601 format. + final String $createdAt; /// User ID. final String userId; - /// Session expiration date in Unix timestamp. - final int expire; + /// Session expiration date in ISO 8601 format. + final String expire; /// Session Provider. final String provider; /// Session Provider User ID. final String providerUid; /// Session Provider Access Token. final String providerAccessToken; - /// Date, the Unix timestamp of when the access token expires. - final int providerAccessTokenExpiry; + /// The date of when the access token expires in ISO 8601 format. + final String providerAccessTokenExpiry; /// Session Provider Refresh Token. final String providerRefreshToken; /// IP in use when the session was created. @@ -53,8 +53,7 @@ class Session implements Model { /// Returns true if this the current user session. final bool current; - Session({ - required this.$id, + Session({ required this.$id, required this.$createdAt, required this.userId, required this.expire, @@ -84,13 +83,13 @@ class Session implements Model { factory Session.fromMap(Map map) { return Session( $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'], + $createdAt: map['\$createdAt'].toString(), userId: map['userId'].toString(), - expire: map['expire'], + expire: map['expire'].toString(), provider: map['provider'].toString(), providerUid: map['providerUid'].toString(), providerAccessToken: map['providerAccessToken'].toString(), - providerAccessTokenExpiry: map['providerAccessTokenExpiry'], + providerAccessTokenExpiry: map['providerAccessTokenExpiry'].toString(), providerRefreshToken: map['providerRefreshToken'].toString(), ip: map['ip'].toString(), osCode: map['osCode'].toString(), @@ -111,7 +110,6 @@ class Session implements Model { ); } - @override Map toMap() { return { "\$id": $id, diff --git a/lib/src/models/session_list.dart b/lib/src/models/session_list.dart index 1c990ab..9701ef1 100644 --- a/lib/src/models/session_list.dart +++ b/lib/src/models/session_list.dart @@ -7,8 +7,7 @@ class SessionList implements Model { /// List of sessions. final List sessions; - SessionList({ - required this.total, + SessionList({ required this.total, required this.sessions, }); @@ -19,7 +18,6 @@ class SessionList implements Model { ); } - @override Map toMap() { return { "total": total, diff --git a/lib/src/models/team.dart b/lib/src/models/team.dart index dde2e29..8825eb9 100644 --- a/lib/src/models/team.dart +++ b/lib/src/models/team.dart @@ -4,17 +4,16 @@ part of appwrite.models; class Team implements Model { /// Team ID. final String $id; - /// Team creation date in Unix timestamp. - final int $createdAt; - /// Team update date in Unix timestamp. - final int $updatedAt; + /// Team creation date in ISO 8601 format. + final String $createdAt; + /// Team update date in ISO 8601 format. + final String $updatedAt; /// Team name. final String name; /// Total number of team members. final int total; - Team({ - required this.$id, + Team({ required this.$id, required this.$createdAt, required this.$updatedAt, required this.name, @@ -24,14 +23,13 @@ class Team implements Model { factory Team.fromMap(Map map) { return Team( $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'], - $updatedAt: map['\$updatedAt'], + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), name: map['name'].toString(), total: map['total'], ); } - @override Map toMap() { return { "\$id": $id, diff --git a/lib/src/models/team_list.dart b/lib/src/models/team_list.dart index fa011f4..2b35893 100644 --- a/lib/src/models/team_list.dart +++ b/lib/src/models/team_list.dart @@ -7,8 +7,7 @@ class TeamList implements Model { /// List of teams. final List teams; - TeamList({ - required this.total, + TeamList({ required this.total, required this.teams, }); @@ -19,7 +18,6 @@ class TeamList implements Model { ); } - @override Map toMap() { return { "total": total, diff --git a/lib/src/models/token.dart b/lib/src/models/token.dart index 729623e..eda5b03 100644 --- a/lib/src/models/token.dart +++ b/lib/src/models/token.dart @@ -4,17 +4,16 @@ part of appwrite.models; class Token implements Model { /// Token ID. final String $id; - /// Token creation date in Unix timestamp. - final int $createdAt; + /// Token creation date in ISO 8601 format. + final String $createdAt; /// User ID. final String userId; /// Token secret key. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. final String secret; - /// Token expiration date in Unix timestamp. - final int expire; + /// Token expiration date in ISO 8601 format. + final String expire; - Token({ - required this.$id, + Token({ required this.$id, required this.$createdAt, required this.userId, required this.secret, @@ -24,14 +23,13 @@ class Token implements Model { factory Token.fromMap(Map map) { return Token( $id: map['\$id'].toString(), - $createdAt: map['\$createdAt'], + $createdAt: map['\$createdAt'].toString(), userId: map['userId'].toString(), secret: map['secret'].toString(), - expire: map['expire'], + expire: map['expire'].toString(), ); } - @override Map toMap() { return { "\$id": $id, diff --git a/pubspec.yaml b/pubspec.yaml index 5c61009..e9f8b58 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: appwrite -version: 7.0.0 +version: 8.0.0-dev.1 description: Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API homepage: https://appwrite.io repository: https://github.com/appwrite/sdk-for-flutter