diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a0b94a8..7033bbdd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Change Log +## 18.0.0 + +* Rename `CreditCard` enum value `unionChinaPay` to `unionPay` +* Add time between query support +* Add spatial attribute support +* Add spatial index support +* Add spatial query support + ## 17.0.0 * Support for Appwrite 1.8 diff --git a/README.md b/README.md index 958295f0..8d896938 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Add this to your package's `pubspec.yaml` file: ```yml dependencies: - dart_appwrite: ^17.0.0 + dart_appwrite: ^18.0.0 ``` You can install packages from the command line: diff --git a/docs/examples/account/update-prefs.md b/docs/examples/account/update-prefs.md index f4533cbe..43343835 100644 --- a/docs/examples/account/update-prefs.md +++ b/docs/examples/account/update-prefs.md @@ -8,5 +8,9 @@ Client client = Client() Account account = Account(client); User result = await account.updatePrefs( - prefs: {}, + prefs: { + "language": "en", + "timezone": "UTC", + "darkTheme": true + }, ); diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index 1d58fc58..e3bae981 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -11,6 +11,12 @@ Document result = await databases.createDocument( databaseId: '', collectionId: '', documentId: '', - data: {}, + data: { + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + }, permissions: ["read("any")"], // (optional) ); diff --git a/docs/examples/databases/create-line-attribute.md b/docs/examples/databases/create-line-attribute.md new file mode 100644 index 00000000..aceaeb92 --- /dev/null +++ b/docs/examples/databases/create-line-attribute.md @@ -0,0 +1,16 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Databases databases = Databases(client); + +AttributeLine result = await databases.createLineAttribute( + databaseId: '', + collectionId: '', + key: '', + xrequired: false, + xdefault: [[1,2], [3, 4]], // (optional) +); diff --git a/docs/examples/databases/create-point-attribute.md b/docs/examples/databases/create-point-attribute.md new file mode 100644 index 00000000..1c3bee66 --- /dev/null +++ b/docs/examples/databases/create-point-attribute.md @@ -0,0 +1,16 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Databases databases = Databases(client); + +AttributePoint result = await databases.createPointAttribute( + databaseId: '', + collectionId: '', + key: '', + xrequired: false, + xdefault: [[1,2], [3, 4]], // (optional) +); diff --git a/docs/examples/databases/create-polygon-attribute.md b/docs/examples/databases/create-polygon-attribute.md new file mode 100644 index 00000000..7c259739 --- /dev/null +++ b/docs/examples/databases/create-polygon-attribute.md @@ -0,0 +1,16 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Databases databases = Databases(client); + +AttributePolygon result = await databases.createPolygonAttribute( + databaseId: '', + collectionId: '', + key: '', + xrequired: false, + xdefault: [[1,2], [3, 4]], // (optional) +); diff --git a/docs/examples/databases/update-line-attribute.md b/docs/examples/databases/update-line-attribute.md new file mode 100644 index 00000000..e29549c0 --- /dev/null +++ b/docs/examples/databases/update-line-attribute.md @@ -0,0 +1,17 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Databases databases = Databases(client); + +AttributeLine result = await databases.updateLineAttribute( + databaseId: '', + collectionId: '', + key: '', + xrequired: false, + xdefault: [[1,2], [3, 4]], // (optional) + newKey: '', // (optional) +); diff --git a/docs/examples/databases/update-point-attribute.md b/docs/examples/databases/update-point-attribute.md new file mode 100644 index 00000000..68cf1c53 --- /dev/null +++ b/docs/examples/databases/update-point-attribute.md @@ -0,0 +1,17 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Databases databases = Databases(client); + +AttributePoint result = await databases.updatePointAttribute( + databaseId: '', + collectionId: '', + key: '', + xrequired: false, + xdefault: [[1,2], [3, 4]], // (optional) + newKey: '', // (optional) +); diff --git a/docs/examples/databases/update-polygon-attribute.md b/docs/examples/databases/update-polygon-attribute.md new file mode 100644 index 00000000..fc310666 --- /dev/null +++ b/docs/examples/databases/update-polygon-attribute.md @@ -0,0 +1,17 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Databases databases = Databases(client); + +AttributePolygon result = await databases.updatePolygonAttribute( + databaseId: '', + collectionId: '', + key: '', + xrequired: false, + xdefault: [[1,2], [3, 4]], // (optional) + newKey: '', // (optional) +); diff --git a/docs/examples/tablesdb/create-line-column.md b/docs/examples/tablesdb/create-line-column.md new file mode 100644 index 00000000..60f00790 --- /dev/null +++ b/docs/examples/tablesdb/create-line-column.md @@ -0,0 +1,16 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +ColumnLine result = await tablesDB.createLineColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: false, + xdefault: [[1,2], [3, 4]], // (optional) +); diff --git a/docs/examples/tablesdb/create-point-column.md b/docs/examples/tablesdb/create-point-column.md new file mode 100644 index 00000000..48b759ba --- /dev/null +++ b/docs/examples/tablesdb/create-point-column.md @@ -0,0 +1,16 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +ColumnPoint result = await tablesDB.createPointColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: false, + xdefault: [[1,2], [3, 4]], // (optional) +); diff --git a/docs/examples/tablesdb/create-polygon-column.md b/docs/examples/tablesdb/create-polygon-column.md new file mode 100644 index 00000000..550c0862 --- /dev/null +++ b/docs/examples/tablesdb/create-polygon-column.md @@ -0,0 +1,16 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +ColumnPolygon result = await tablesDB.createPolygonColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: false, + xdefault: [[1,2], [3, 4]], // (optional) +); diff --git a/docs/examples/tablesdb/create-row.md b/docs/examples/tablesdb/create-row.md index 15e4f8ea..c2f5dd82 100644 --- a/docs/examples/tablesdb/create-row.md +++ b/docs/examples/tablesdb/create-row.md @@ -11,6 +11,12 @@ Row result = await tablesDB.createRow( databaseId: '', tableId: '', rowId: '', - data: {}, + data: { + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + }, permissions: ["read("any")"], // (optional) ); diff --git a/docs/examples/tablesdb/update-line-column.md b/docs/examples/tablesdb/update-line-column.md new file mode 100644 index 00000000..26d879d3 --- /dev/null +++ b/docs/examples/tablesdb/update-line-column.md @@ -0,0 +1,17 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +ColumnLine result = await tablesDB.updateLineColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: false, + xdefault: [[1,2], [3, 4]], // (optional) + newKey: '', // (optional) +); diff --git a/docs/examples/tablesdb/update-point-column.md b/docs/examples/tablesdb/update-point-column.md new file mode 100644 index 00000000..e0444b7f --- /dev/null +++ b/docs/examples/tablesdb/update-point-column.md @@ -0,0 +1,17 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +ColumnPoint result = await tablesDB.updatePointColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: false, + xdefault: [[1,2], [3, 4]], // (optional) + newKey: '', // (optional) +); diff --git a/docs/examples/tablesdb/update-polygon-column.md b/docs/examples/tablesdb/update-polygon-column.md new file mode 100644 index 00000000..60ae79b3 --- /dev/null +++ b/docs/examples/tablesdb/update-polygon-column.md @@ -0,0 +1,17 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +TablesDB tablesDB = TablesDB(client); + +ColumnPolygon result = await tablesDB.updatePolygonColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: false, + xdefault: [[1,2], [3, 4]], // (optional) + newKey: '', // (optional) +); diff --git a/lib/models.dart b/lib/models.dart index 71b1a2fd..1074ae80 100644 --- a/lib/models.dart +++ b/lib/models.dart @@ -50,6 +50,9 @@ part 'src/models/attribute_ip.dart'; part 'src/models/attribute_url.dart'; part 'src/models/attribute_datetime.dart'; part 'src/models/attribute_relationship.dart'; +part 'src/models/attribute_point.dart'; +part 'src/models/attribute_line.dart'; +part 'src/models/attribute_polygon.dart'; part 'src/models/table.dart'; part 'src/models/column_list.dart'; part 'src/models/column_string.dart'; @@ -62,6 +65,9 @@ part 'src/models/column_ip.dart'; part 'src/models/column_url.dart'; part 'src/models/column_datetime.dart'; part 'src/models/column_relationship.dart'; +part 'src/models/column_point.dart'; +part 'src/models/column_line.dart'; +part 'src/models/column_polygon.dart'; part 'src/models/index.dart'; part 'src/models/column_index.dart'; part 'src/models/row.dart'; diff --git a/lib/query.dart b/lib/query.dart index c9a2fc91..0bfc4796 100644 --- a/lib/query.dart +++ b/lib/query.dart @@ -9,17 +9,19 @@ class Query { Query._(this.method, [this.attribute = null, this.values = null]); Map toJson() { - final map = {'method': method}; + final result = {}; + + result['method'] = method; if (attribute != null) { - map['attribute'] = attribute; + result['attribute'] = attribute; } if (values != null) { - map['values'] = values is List ? values : [values]; + result['values'] = values is List ? values : [values]; } - return map; + return result; } @override @@ -35,7 +37,7 @@ class Query { /// Filter resources where [attribute] is not equal to [value]. static String notEqual(String attribute, dynamic value) => - Query._('notEqual', attribute, [value]).toString(); + Query._('notEqual', attribute, value).toString(); /// Filter resources where [attribute] is less than [value]. static String lessThan(String attribute, dynamic value) => @@ -111,6 +113,10 @@ class Query { static String createdAfter(String value) => Query._('createdAfter', null, value).toString(); + /// Filter resources where document was created between [start] and [end] (inclusive). + static String createdBetween(String start, String end) => + Query._('createdBetween', null, [start, end]).toString(); + /// Filter resources where document was updated before [value]. static String updatedBefore(String value) => Query._('updatedBefore', null, value).toString(); @@ -119,6 +125,10 @@ class Query { static String updatedAfter(String value) => Query._('updatedAfter', null, value).toString(); + /// Filter resources where document was updated between [start] and [end] (inclusive). + static String updatedBetween(String start, String end) => + Query._('updatedBetween', null, [start, end]).toString(); + static String or(List queries) => Query._( 'or', null, @@ -166,4 +176,76 @@ class Query { /// docs for more information. static String offset(int offset) => Query._('offset', null, offset).toString(); + + /// Filter resources where [attribute] is at a specific distance from the given coordinates. + static String distanceEqual( + String attribute, + List values, + num distance, [ + bool meters = true, + ]) => Query._('distanceEqual', attribute, [ + [values, distance, meters], + ]).toString(); + + /// Filter resources where [attribute] is not at a specific distance from the given coordinates. + static String distanceNotEqual( + String attribute, + List values, + num distance, [ + bool meters = true, + ]) => Query._('distanceNotEqual', attribute, [ + [values, distance, meters], + ]).toString(); + + /// Filter resources where [attribute] is at a distance greater than the specified value from the given coordinates. + static String distanceGreaterThan( + String attribute, + List values, + num distance, [ + bool meters = true, + ]) => Query._('distanceGreaterThan', attribute, [ + [values, distance, meters], + ]).toString(); + + /// Filter resources where [attribute] is at a distance less than the specified value from the given coordinates. + static String distanceLessThan( + String attribute, + List values, + num distance, [ + bool meters = true, + ]) => Query._('distanceLessThan', attribute, [ + [values, distance, meters], + ]).toString(); + + /// Filter resources where [attribute] intersects with the given geometry. + static String intersects(String attribute, List values) => + Query._('intersects', attribute, [values]).toString(); + + /// Filter resources where [attribute] does not intersect with the given geometry. + static String notIntersects(String attribute, List values) => + Query._('notIntersects', attribute, [values]).toString(); + + /// Filter resources where [attribute] crosses the given geometry. + static String crosses(String attribute, List values) => + Query._('crosses', attribute, [values]).toString(); + + /// Filter resources where [attribute] does not cross the given geometry. + static String notCrosses(String attribute, List values) => + Query._('notCrosses', attribute, [values]).toString(); + + /// Filter resources where [attribute] overlaps with the given geometry. + static String overlaps(String attribute, List values) => + Query._('overlaps', attribute, [values]).toString(); + + /// Filter resources where [attribute] does not overlap with the given geometry. + static String notOverlaps(String attribute, List values) => + Query._('notOverlaps', attribute, [values]).toString(); + + /// Filter resources where [attribute] touches the given geometry. + static String touches(String attribute, List values) => + Query._('touches', attribute, [values]).toString(); + + /// Filter resources where [attribute] does not touch the given geometry. + static String notTouches(String attribute, List values) => + Query._('notTouches', attribute, [values]).toString(); } diff --git a/lib/services/account.dart b/lib/services/account.dart index d0c820a1..7044c030 100644 --- a/lib/services/account.dart +++ b/lib/services/account.dart @@ -889,7 +889,9 @@ 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. - @Deprecated('This API has been deprecated.') + @Deprecated( + 'This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.', + ) Future updateMagicURLSession({ required String userId, required String secret, @@ -913,7 +915,9 @@ 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. - @Deprecated('This API has been deprecated.') + @Deprecated( + 'This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.', + ) Future updatePhoneSession({ required String userId, required String secret, diff --git a/lib/services/databases.dart b/lib/services/databases.dart index 223f1318..84999618 100644 --- a/lib/services/databases.dart +++ b/lib/services/databases.dart @@ -36,7 +36,7 @@ class Databases extends Service { /// Create a new Database. /// @Deprecated( - 'This API has been deprecated since 1.8.0. Please use `TablesDB.createDatabase` instead.', + 'This API has been deprecated since 1.8.0. Please use `TablesDB.create` instead.', ) Future create({ required String databaseId, @@ -875,6 +875,219 @@ class Databases extends Service { return models.AttributeIp.fromMap(res.data); } + /// Create a geometric line attribute. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.createLineColumn` instead.', + ) + Future createLineAttribute({ + required String databaseId, + required String collectionId, + required String key, + required bool xrequired, + List? xdefault, + }) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/line' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId); + + final Map apiParams = { + 'key': key, + 'required': xrequired, + 'default': xdefault, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.AttributeLine.fromMap(res.data); + } + + /// Update a line attribute. Changing the `default` value will not update + /// already existing documents. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.updateLineColumn` instead.', + ) + Future updateLineAttribute({ + required String databaseId, + required String collectionId, + required String key, + required bool xrequired, + List? xdefault, + String? newKey, + }) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/line/{key}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{key}', key); + + final Map apiParams = { + 'required': xrequired, + 'default': xdefault, + 'newKey': newKey, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.AttributeLine.fromMap(res.data); + } + + /// Create a geometric point attribute. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.createPointColumn` instead.', + ) + Future createPointAttribute({ + required String databaseId, + required String collectionId, + required String key, + required bool xrequired, + List? xdefault, + }) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/point' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId); + + final Map apiParams = { + 'key': key, + 'required': xrequired, + 'default': xdefault, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.AttributePoint.fromMap(res.data); + } + + /// Update a point attribute. Changing the `default` value will not update + /// already existing documents. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.updatePointColumn` instead.', + ) + Future updatePointAttribute({ + required String databaseId, + required String collectionId, + required String key, + required bool xrequired, + List? xdefault, + String? newKey, + }) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/point/{key}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{key}', key); + + final Map apiParams = { + 'required': xrequired, + 'default': xdefault, + 'newKey': newKey, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.AttributePoint.fromMap(res.data); + } + + /// Create a geometric polygon attribute. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.createPolygonColumn` instead.', + ) + Future createPolygonAttribute({ + required String databaseId, + required String collectionId, + required String key, + required bool xrequired, + List? xdefault, + }) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/polygon' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId); + + final Map apiParams = { + 'key': key, + 'required': xrequired, + 'default': xdefault, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.AttributePolygon.fromMap(res.data); + } + + /// Update a polygon attribute. Changing the `default` value will not update + /// already existing documents. + @Deprecated( + 'This API has been deprecated since 1.8.0. Please use `TablesDB.updatePolygonColumn` instead.', + ) + Future updatePolygonAttribute({ + required String databaseId, + required String collectionId, + required String key, + required bool xrequired, + List? xdefault, + String? newKey, + }) async { + final String apiPath = + '/databases/{databaseId}/collections/{collectionId}/attributes/polygon/{key}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{collectionId}', collectionId) + .replaceAll('{key}', key); + + final Map apiParams = { + 'required': xrequired, + 'default': xdefault, + 'newKey': newKey, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.AttributePolygon.fromMap(res.data); + } + /// Create relationship attribute. [Learn more about relationship /// attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). /// diff --git a/lib/services/tables_db.dart b/lib/services/tables_db.dart index f9d86004..560b7358 100644 --- a/lib/services/tables_db.dart +++ b/lib/services/tables_db.dart @@ -795,6 +795,201 @@ class TablesDB extends Service { return models.ColumnIp.fromMap(res.data); } + /// Create a geometric line column. + Future createLineColumn({ + required String databaseId, + required String tableId, + required String key, + required bool xrequired, + List? xdefault, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/line' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId); + + final Map apiParams = { + 'key': key, + 'required': xrequired, + 'default': xdefault, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.ColumnLine.fromMap(res.data); + } + + /// Update a line column. Changing the `default` value will not update already + /// existing rows. + Future updateLineColumn({ + required String databaseId, + required String tableId, + required String key, + required bool xrequired, + List? xdefault, + String? newKey, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/line/{key}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{key}', key); + + final Map apiParams = { + 'required': xrequired, + 'default': xdefault, + 'newKey': newKey, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.ColumnLine.fromMap(res.data); + } + + /// Create a geometric point column. + Future createPointColumn({ + required String databaseId, + required String tableId, + required String key, + required bool xrequired, + List? xdefault, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/point' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId); + + final Map apiParams = { + 'key': key, + 'required': xrequired, + 'default': xdefault, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.ColumnPoint.fromMap(res.data); + } + + /// Update a point column. Changing the `default` value will not update already + /// existing rows. + Future updatePointColumn({ + required String databaseId, + required String tableId, + required String key, + required bool xrequired, + List? xdefault, + String? newKey, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/point/{key}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{key}', key); + + final Map apiParams = { + 'required': xrequired, + 'default': xdefault, + 'newKey': newKey, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.ColumnPoint.fromMap(res.data); + } + + /// Create a geometric polygon column. + Future createPolygonColumn({ + required String databaseId, + required String tableId, + required String key, + required bool xrequired, + List? xdefault, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/polygon' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId); + + final Map apiParams = { + 'key': key, + 'required': xrequired, + 'default': xdefault, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.ColumnPolygon.fromMap(res.data); + } + + /// Update a polygon column. Changing the `default` value will not update + /// already existing rows. + Future updatePolygonColumn({ + required String databaseId, + required String tableId, + required String key, + required bool xrequired, + List? xdefault, + String? newKey, + }) async { + final String apiPath = + '/tablesdb/{databaseId}/tables/{tableId}/columns/polygon/{key}' + .replaceAll('{databaseId}', databaseId) + .replaceAll('{tableId}', tableId) + .replaceAll('{key}', key); + + final Map apiParams = { + 'required': xrequired, + 'default': xdefault, + 'newKey': newKey, + }; + + final Map apiHeaders = {'content-type': 'application/json'}; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.ColumnPolygon.fromMap(res.data); + } + /// Create relationship column. [Learn more about relationship /// columns](https://appwrite.io/docs/databases-relationships#relationship-columns). /// diff --git a/lib/src/client_browser.dart b/lib/src/client_browser.dart index c961873f..c105ecb1 100644 --- a/lib/src/client_browser.dart +++ b/lib/src/client_browser.dart @@ -30,7 +30,7 @@ class ClientBrowser extends ClientBase with ClientMixin { 'x-sdk-name': 'Dart', 'x-sdk-platform': 'server', 'x-sdk-language': 'dart', - 'x-sdk-version': '17.0.0', + 'x-sdk-version': '18.0.0', 'X-Appwrite-Response-Format': '1.8.0', }; diff --git a/lib/src/client_io.dart b/lib/src/client_io.dart index 2bd7d639..50acd980 100644 --- a/lib/src/client_io.dart +++ b/lib/src/client_io.dart @@ -36,9 +36,9 @@ class ClientIO extends ClientBase with ClientMixin { 'x-sdk-name': 'Dart', 'x-sdk-platform': 'server', 'x-sdk-language': 'dart', - 'x-sdk-version': '17.0.0', + 'x-sdk-version': '18.0.0', 'user-agent': - 'AppwriteDartSDK/17.0.0 (${Platform.operatingSystem}; ${Platform.operatingSystemVersion})', + 'AppwriteDartSDK/18.0.0 (${Platform.operatingSystem}; ${Platform.operatingSystemVersion})', 'X-Appwrite-Response-Format': '1.8.0', }; diff --git a/lib/src/enums/credit_card.dart b/lib/src/enums/credit_card.dart index 1bae5c8a..28c2a1b3 100644 --- a/lib/src/enums/credit_card.dart +++ b/lib/src/enums/credit_card.dart @@ -13,7 +13,7 @@ enum CreditCard { mastercard(value: 'mastercard'), naranja(value: 'naranja'), tarjetaShopping(value: 'targeta-shopping'), - unionChinaPay(value: 'union-china-pay'), + unionPay(value: 'unionpay'), visa(value: 'visa'), mIR(value: 'mir'), maestro(value: 'maestro'), diff --git a/lib/src/enums/execution_method.dart b/lib/src/enums/execution_method.dart index 42954430..44de4907 100644 --- a/lib/src/enums/execution_method.dart +++ b/lib/src/enums/execution_method.dart @@ -6,7 +6,8 @@ enum ExecutionMethod { pUT(value: 'PUT'), pATCH(value: 'PATCH'), dELETE(value: 'DELETE'), - oPTIONS(value: 'OPTIONS'); + oPTIONS(value: 'OPTIONS'), + hEAD(value: 'HEAD'); const ExecutionMethod({required this.value}); diff --git a/lib/src/enums/index_type.dart b/lib/src/enums/index_type.dart index b101d35f..e5633bc2 100644 --- a/lib/src/enums/index_type.dart +++ b/lib/src/enums/index_type.dart @@ -3,7 +3,8 @@ part of '../../enums.dart'; enum IndexType { key(value: 'key'), fulltext(value: 'fulltext'), - unique(value: 'unique'); + unique(value: 'unique'), + spatial(value: 'spatial'); const IndexType({required this.value}); diff --git a/lib/src/models/attribute_line.dart b/lib/src/models/attribute_line.dart new file mode 100644 index 00000000..cae9d1c4 --- /dev/null +++ b/lib/src/models/attribute_line.dart @@ -0,0 +1,71 @@ +part of '../../models.dart'; + +/// AttributeLine +class AttributeLine implements Model { + /// Attribute Key. + final String key; + + /// Attribute type. + final String type; + + /// Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + final String status; + + /// Error message. Displays error generated on failure of creating or deleting an attribute. + final String error; + + /// Is attribute required? + final bool xrequired; + + /// Is attribute an array? + final bool? array; + + /// Attribute creation date in ISO 8601 format. + final String $createdAt; + + /// Attribute update date in ISO 8601 format. + final String $updatedAt; + + /// Default value for attribute when not provided. Cannot be set when attribute is required. + final List? xdefault; + + AttributeLine({ + required this.key, + required this.type, + required this.status, + required this.error, + required this.xrequired, + this.array, + required this.$createdAt, + required this.$updatedAt, + this.xdefault, + }); + + factory AttributeLine.fromMap(Map map) { + return AttributeLine( + key: map['key'].toString(), + type: map['type'].toString(), + status: map['status'].toString(), + error: map['error'].toString(), + xrequired: map['required'], + array: map['array'], + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + xdefault: List.from(map['default'] ?? []), + ); + } + + Map toMap() { + return { + "key": key, + "type": type, + "status": status, + "error": error, + "required": xrequired, + "array": array, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "default": xdefault, + }; + } +} diff --git a/lib/src/models/attribute_point.dart b/lib/src/models/attribute_point.dart new file mode 100644 index 00000000..e0dccf41 --- /dev/null +++ b/lib/src/models/attribute_point.dart @@ -0,0 +1,71 @@ +part of '../../models.dart'; + +/// AttributePoint +class AttributePoint implements Model { + /// Attribute Key. + final String key; + + /// Attribute type. + final String type; + + /// Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + final String status; + + /// Error message. Displays error generated on failure of creating or deleting an attribute. + final String error; + + /// Is attribute required? + final bool xrequired; + + /// Is attribute an array? + final bool? array; + + /// Attribute creation date in ISO 8601 format. + final String $createdAt; + + /// Attribute update date in ISO 8601 format. + final String $updatedAt; + + /// Default value for attribute when not provided. Cannot be set when attribute is required. + final List? xdefault; + + AttributePoint({ + required this.key, + required this.type, + required this.status, + required this.error, + required this.xrequired, + this.array, + required this.$createdAt, + required this.$updatedAt, + this.xdefault, + }); + + factory AttributePoint.fromMap(Map map) { + return AttributePoint( + key: map['key'].toString(), + type: map['type'].toString(), + status: map['status'].toString(), + error: map['error'].toString(), + xrequired: map['required'], + array: map['array'], + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + xdefault: List.from(map['default'] ?? []), + ); + } + + Map toMap() { + return { + "key": key, + "type": type, + "status": status, + "error": error, + "required": xrequired, + "array": array, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "default": xdefault, + }; + } +} diff --git a/lib/src/models/attribute_polygon.dart b/lib/src/models/attribute_polygon.dart new file mode 100644 index 00000000..bd1ea95f --- /dev/null +++ b/lib/src/models/attribute_polygon.dart @@ -0,0 +1,71 @@ +part of '../../models.dart'; + +/// AttributePolygon +class AttributePolygon implements Model { + /// Attribute Key. + final String key; + + /// Attribute type. + final String type; + + /// Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + final String status; + + /// Error message. Displays error generated on failure of creating or deleting an attribute. + final String error; + + /// Is attribute required? + final bool xrequired; + + /// Is attribute an array? + final bool? array; + + /// Attribute creation date in ISO 8601 format. + final String $createdAt; + + /// Attribute update date in ISO 8601 format. + final String $updatedAt; + + /// Default value for attribute when not provided. Cannot be set when attribute is required. + final List? xdefault; + + AttributePolygon({ + required this.key, + required this.type, + required this.status, + required this.error, + required this.xrequired, + this.array, + required this.$createdAt, + required this.$updatedAt, + this.xdefault, + }); + + factory AttributePolygon.fromMap(Map map) { + return AttributePolygon( + key: map['key'].toString(), + type: map['type'].toString(), + status: map['status'].toString(), + error: map['error'].toString(), + xrequired: map['required'], + array: map['array'], + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + xdefault: List.from(map['default'] ?? []), + ); + } + + Map toMap() { + return { + "key": key, + "type": type, + "status": status, + "error": error, + "required": xrequired, + "array": array, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "default": xdefault, + }; + } +} diff --git a/lib/src/models/column_line.dart b/lib/src/models/column_line.dart new file mode 100644 index 00000000..937932a1 --- /dev/null +++ b/lib/src/models/column_line.dart @@ -0,0 +1,71 @@ +part of '../../models.dart'; + +/// ColumnLine +class ColumnLine implements Model { + /// Column Key. + final String key; + + /// Column type. + final String type; + + /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + final String status; + + /// Error message. Displays error generated on failure of creating or deleting an column. + final String error; + + /// Is column required? + final bool xrequired; + + /// Is column an array? + final bool? array; + + /// Column creation date in ISO 8601 format. + final String $createdAt; + + /// Column update date in ISO 8601 format. + final String $updatedAt; + + /// Default value for column when not provided. Cannot be set when column is required. + final List? xdefault; + + ColumnLine({ + required this.key, + required this.type, + required this.status, + required this.error, + required this.xrequired, + this.array, + required this.$createdAt, + required this.$updatedAt, + this.xdefault, + }); + + factory ColumnLine.fromMap(Map map) { + return ColumnLine( + key: map['key'].toString(), + type: map['type'].toString(), + status: map['status'].toString(), + error: map['error'].toString(), + xrequired: map['required'], + array: map['array'], + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + xdefault: List.from(map['default'] ?? []), + ); + } + + Map toMap() { + return { + "key": key, + "type": type, + "status": status, + "error": error, + "required": xrequired, + "array": array, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "default": xdefault, + }; + } +} diff --git a/lib/src/models/column_point.dart b/lib/src/models/column_point.dart new file mode 100644 index 00000000..9c9034e5 --- /dev/null +++ b/lib/src/models/column_point.dart @@ -0,0 +1,71 @@ +part of '../../models.dart'; + +/// ColumnPoint +class ColumnPoint implements Model { + /// Column Key. + final String key; + + /// Column type. + final String type; + + /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + final String status; + + /// Error message. Displays error generated on failure of creating or deleting an column. + final String error; + + /// Is column required? + final bool xrequired; + + /// Is column an array? + final bool? array; + + /// Column creation date in ISO 8601 format. + final String $createdAt; + + /// Column update date in ISO 8601 format. + final String $updatedAt; + + /// Default value for column when not provided. Cannot be set when column is required. + final List? xdefault; + + ColumnPoint({ + required this.key, + required this.type, + required this.status, + required this.error, + required this.xrequired, + this.array, + required this.$createdAt, + required this.$updatedAt, + this.xdefault, + }); + + factory ColumnPoint.fromMap(Map map) { + return ColumnPoint( + key: map['key'].toString(), + type: map['type'].toString(), + status: map['status'].toString(), + error: map['error'].toString(), + xrequired: map['required'], + array: map['array'], + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + xdefault: List.from(map['default'] ?? []), + ); + } + + Map toMap() { + return { + "key": key, + "type": type, + "status": status, + "error": error, + "required": xrequired, + "array": array, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "default": xdefault, + }; + } +} diff --git a/lib/src/models/column_polygon.dart b/lib/src/models/column_polygon.dart new file mode 100644 index 00000000..dedd5e64 --- /dev/null +++ b/lib/src/models/column_polygon.dart @@ -0,0 +1,71 @@ +part of '../../models.dart'; + +/// ColumnPolygon +class ColumnPolygon implements Model { + /// Column Key. + final String key; + + /// Column type. + final String type; + + /// Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + final String status; + + /// Error message. Displays error generated on failure of creating or deleting an column. + final String error; + + /// Is column required? + final bool xrequired; + + /// Is column an array? + final bool? array; + + /// Column creation date in ISO 8601 format. + final String $createdAt; + + /// Column update date in ISO 8601 format. + final String $updatedAt; + + /// Default value for column when not provided. Cannot be set when column is required. + final List? xdefault; + + ColumnPolygon({ + required this.key, + required this.type, + required this.status, + required this.error, + required this.xrequired, + this.array, + required this.$createdAt, + required this.$updatedAt, + this.xdefault, + }); + + factory ColumnPolygon.fromMap(Map map) { + return ColumnPolygon( + key: map['key'].toString(), + type: map['type'].toString(), + status: map['status'].toString(), + error: map['error'].toString(), + xrequired: map['required'], + array: map['array'], + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + xdefault: List.from(map['default'] ?? []), + ); + } + + Map toMap() { + return { + "key": key, + "type": type, + "status": status, + "error": error, + "required": xrequired, + "array": array, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "default": xdefault, + }; + } +} diff --git a/pubspec.yaml b/pubspec.yaml index 9d102b91..0afd93b1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: dart_appwrite -version: 17.0.0 +version: 18.0.0 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-dart diff --git a/test/query_test.dart b/test/query_test.dart index 737a82b3..14dcb151 100644 --- a/test/query_test.dart +++ b/test/query_test.dart @@ -279,6 +279,13 @@ void main() { expect(query['method'], 'createdAfter'); }); + test('returns createdBetween', () { + final query = jsonDecode(Query.createdBetween('2023-01-01', '2023-12-31')); + expect(query['attribute'], null); + expect(query['values'], ['2023-01-01', '2023-12-31']); + expect(query['method'], 'createdBetween'); + }); + test('returns updatedBefore', () { final query = jsonDecode(Query.updatedBefore('2023-01-01')); expect(query['attribute'], null); @@ -292,5 +299,12 @@ void main() { expect(query['values'], ['2023-01-01']); expect(query['method'], 'updatedAfter'); }); + + test('returns updatedBetween', () { + final query = jsonDecode(Query.updatedBetween('2023-01-01', '2023-12-31')); + expect(query['attribute'], null); + expect(query['values'], ['2023-01-01', '2023-12-31']); + expect(query['method'], 'updatedBetween'); + }); } diff --git a/test/services/databases_test.dart b/test/services/databases_test.dart index eeab4468..bf12afce 100644 --- a/test/services/databases_test.dart +++ b/test/services/databases_test.dart @@ -665,6 +665,162 @@ void main() { }); + test('test method createLineAttribute()', () async { + final Map data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.createLineAttribute( + databaseId: '', + collectionId: '', + key: '', + xrequired: true, + ); + expect(response, isA()); + + }); + + test('test method updateLineAttribute()', () async { + final Map data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.updateLineAttribute( + databaseId: '', + collectionId: '', + key: '', + xrequired: true, + ); + expect(response, isA()); + + }); + + test('test method createPointAttribute()', () async { + final Map data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.createPointAttribute( + databaseId: '', + collectionId: '', + key: '', + xrequired: true, + ); + expect(response, isA()); + + }); + + test('test method updatePointAttribute()', () async { + final Map data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.updatePointAttribute( + databaseId: '', + collectionId: '', + key: '', + xrequired: true, + ); + expect(response, isA()); + + }); + + test('test method createPolygonAttribute()', () async { + final Map data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.createPolygonAttribute( + databaseId: '', + collectionId: '', + key: '', + xrequired: true, + ); + expect(response, isA()); + + }); + + test('test method updatePolygonAttribute()', () async { + final Map data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.updatePolygonAttribute( + databaseId: '', + collectionId: '', + key: '', + xrequired: true, + ); + expect(response, isA()); + + }); + test('test method createRelationshipAttribute()', () async { final Map data = { 'key': 'fullName', diff --git a/test/services/tables_db_test.dart b/test/services/tables_db_test.dart index 6122fd6a..63212024 100644 --- a/test/services/tables_db_test.dart +++ b/test/services/tables_db_test.dart @@ -665,6 +665,162 @@ void main() { }); + test('test method createLineColumn()', () async { + final Map data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.createLineColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: true, + ); + expect(response, isA()); + + }); + + test('test method updateLineColumn()', () async { + final Map data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.updateLineColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: true, + ); + expect(response, isA()); + + }); + + test('test method createPointColumn()', () async { + final Map data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.createPointColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: true, + ); + expect(response, isA()); + + }); + + test('test method updatePointColumn()', () async { + final Map data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.updatePointColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: true, + ); + expect(response, isA()); + + }); + + test('test method createPolygonColumn()', () async { + final Map data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.createPolygonColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: true, + ); + expect(response, isA()); + + }); + + test('test method updatePolygonColumn()', () async { + final Map data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'error': 'string', + 'required': true, + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await tablesDB.updatePolygonColumn( + databaseId: '', + tableId: '', + key: '', + xrequired: true, + ); + expect(response, isA()); + + }); + test('test method createRelationshipColumn()', () async { final Map data = { 'key': 'fullName', diff --git a/test/src/models/attribute_line_test.dart b/test/src/models/attribute_line_test.dart new file mode 100644 index 00000000..f5739e35 --- /dev/null +++ b/test/src/models/attribute_line_test.dart @@ -0,0 +1,29 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('AttributeLine', () { + test('model', () { + final model = AttributeLine( + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + xrequired: true, + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + ); + + final map = model.toMap(); + final result = AttributeLine.fromMap(map); + + expect(result.key, 'fullName'); + expect(result.type, 'string'); + expect(result.status, 'available'); + expect(result.error, 'string'); + expect(result.xrequired, true); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + }); + }); +} diff --git a/test/src/models/attribute_point_test.dart b/test/src/models/attribute_point_test.dart new file mode 100644 index 00000000..a95214bb --- /dev/null +++ b/test/src/models/attribute_point_test.dart @@ -0,0 +1,29 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('AttributePoint', () { + test('model', () { + final model = AttributePoint( + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + xrequired: true, + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + ); + + final map = model.toMap(); + final result = AttributePoint.fromMap(map); + + expect(result.key, 'fullName'); + expect(result.type, 'string'); + expect(result.status, 'available'); + expect(result.error, 'string'); + expect(result.xrequired, true); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + }); + }); +} diff --git a/test/src/models/attribute_polygon_test.dart b/test/src/models/attribute_polygon_test.dart new file mode 100644 index 00000000..d8649b93 --- /dev/null +++ b/test/src/models/attribute_polygon_test.dart @@ -0,0 +1,29 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('AttributePolygon', () { + test('model', () { + final model = AttributePolygon( + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + xrequired: true, + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + ); + + final map = model.toMap(); + final result = AttributePolygon.fromMap(map); + + expect(result.key, 'fullName'); + expect(result.type, 'string'); + expect(result.status, 'available'); + expect(result.error, 'string'); + expect(result.xrequired, true); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + }); + }); +} diff --git a/test/src/models/column_line_test.dart b/test/src/models/column_line_test.dart new file mode 100644 index 00000000..3f5d647f --- /dev/null +++ b/test/src/models/column_line_test.dart @@ -0,0 +1,29 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('ColumnLine', () { + test('model', () { + final model = ColumnLine( + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + xrequired: true, + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + ); + + final map = model.toMap(); + final result = ColumnLine.fromMap(map); + + expect(result.key, 'fullName'); + expect(result.type, 'string'); + expect(result.status, 'available'); + expect(result.error, 'string'); + expect(result.xrequired, true); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + }); + }); +} diff --git a/test/src/models/column_point_test.dart b/test/src/models/column_point_test.dart new file mode 100644 index 00000000..a9ef663b --- /dev/null +++ b/test/src/models/column_point_test.dart @@ -0,0 +1,29 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('ColumnPoint', () { + test('model', () { + final model = ColumnPoint( + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + xrequired: true, + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + ); + + final map = model.toMap(); + final result = ColumnPoint.fromMap(map); + + expect(result.key, 'fullName'); + expect(result.type, 'string'); + expect(result.status, 'available'); + expect(result.error, 'string'); + expect(result.xrequired, true); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + }); + }); +} diff --git a/test/src/models/column_polygon_test.dart b/test/src/models/column_polygon_test.dart new file mode 100644 index 00000000..c2a3a1b3 --- /dev/null +++ b/test/src/models/column_polygon_test.dart @@ -0,0 +1,29 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('ColumnPolygon', () { + test('model', () { + final model = ColumnPolygon( + key: 'fullName', + type: 'string', + status: 'available', + error: 'string', + xrequired: true, + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + ); + + final map = model.toMap(); + final result = ColumnPolygon.fromMap(map); + + expect(result.key, 'fullName'); + expect(result.type, 'string'); + expect(result.status, 'available'); + expect(result.error, 'string'); + expect(result.xrequired, true); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + }); + }); +}