Skip to content

Commit 041f94d

Browse files
authored
Merge pull request #85 from appwrite/dev
chore: regenerate sdk
2 parents 271931a + ab49806 commit 041f94d

14 files changed

+179
-8
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Change Log
22

3+
## 16.2.0
4+
5+
* Add `incrementDocumentAttribute` and `decrementDocumentAttribute` support to `Databases` service
6+
* Add `encrypt` support to string attribute model
7+
* Add `sequence` support to `Document` model
8+
39
## 16.1.0
410

511
* Add `gif` support to `ImageFormat` enum

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Add this to your package's `pubspec.yaml` file:
2323

2424
```yml
2525
dependencies:
26-
dart_appwrite: ^16.1.0
26+
dart_appwrite: ^16.2.0
2727
```
2828
2929
You can install packages from the command line:

docs/examples/databases/create-document.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ import 'package:dart_appwrite/dart_appwrite.dart';
22

33
Client client = Client()
44
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
5-
.setSession('') // The user session to authenticate with
6-
.setKey('<YOUR_API_KEY>') // Your secret API key
7-
.setJWT('<YOUR_JWT>'); // Your secret JSON Web Token
5+
.setProject('<YOUR_PROJECT_ID>') // Your project ID
6+
.setSession(''); // The user session to authenticate with
87

98
Databases databases = Databases(client);
109

docs/examples/databases/create-documents.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'package:dart_appwrite/dart_appwrite.dart';
22

33
Client client = Client()
44
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
5+
.setProject('<YOUR_PROJECT_ID>') // Your project ID
56
.setKey('<YOUR_API_KEY>'); // Your secret API key
67

78
Databases databases = Databases(client);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import 'package:dart_appwrite/dart_appwrite.dart';
2+
3+
Client client = Client()
4+
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
5+
.setProject('<YOUR_PROJECT_ID>') // Your project ID
6+
.setKey('<YOUR_API_KEY>'); // Your secret API key
7+
8+
Databases databases = Databases(client);
9+
10+
Document result = await databases.decrementDocumentAttribute(
11+
databaseId: '<DATABASE_ID>',
12+
collectionId: '<COLLECTION_ID>',
13+
documentId: '<DOCUMENT_ID>',
14+
attribute: '',
15+
value: 0, // (optional)
16+
min: 0, // (optional)
17+
);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import 'package:dart_appwrite/dart_appwrite.dart';
2+
3+
Client client = Client()
4+
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
5+
.setProject('<YOUR_PROJECT_ID>') // Your project ID
6+
.setKey('<YOUR_API_KEY>'); // Your secret API key
7+
8+
Databases databases = Databases(client);
9+
10+
Document result = await databases.incrementDocumentAttribute(
11+
databaseId: '<DATABASE_ID>',
12+
collectionId: '<COLLECTION_ID>',
13+
documentId: '<DOCUMENT_ID>',
14+
attribute: '',
15+
value: 0, // (optional)
16+
max: 0, // (optional)
17+
);

lib/services/databases.dart

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,6 +1168,7 @@ class Databases extends Service {
11681168
/// new collection resource using either a [server
11691169
/// integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
11701170
/// API or directly from your database console.
1171+
///
11711172
Future<models.DocumentList> upsertDocuments({
11721173
required String databaseId,
11731174
required String collectionId,
@@ -1378,6 +1379,66 @@ class Databases extends Service {
13781379
return res.data;
13791380
}
13801381

1382+
/// Decrement a specific attribute of a document by a given value.
1383+
Future<models.Document> decrementDocumentAttribute({
1384+
required String databaseId,
1385+
required String collectionId,
1386+
required String documentId,
1387+
required String attribute,
1388+
double? value,
1389+
double? min,
1390+
}) async {
1391+
final String apiPath =
1392+
'/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement'
1393+
.replaceAll('{databaseId}', databaseId)
1394+
.replaceAll('{collectionId}', collectionId)
1395+
.replaceAll('{documentId}', documentId)
1396+
.replaceAll('{attribute}', attribute);
1397+
1398+
final Map<String, dynamic> apiParams = {'value': value, 'min': min};
1399+
1400+
final Map<String, String> apiHeaders = {'content-type': 'application/json'};
1401+
1402+
final res = await client.call(
1403+
HttpMethod.patch,
1404+
path: apiPath,
1405+
params: apiParams,
1406+
headers: apiHeaders,
1407+
);
1408+
1409+
return models.Document.fromMap(res.data);
1410+
}
1411+
1412+
/// Increment a specific attribute of a document by a given value.
1413+
Future<models.Document> incrementDocumentAttribute({
1414+
required String databaseId,
1415+
required String collectionId,
1416+
required String documentId,
1417+
required String attribute,
1418+
double? value,
1419+
double? max,
1420+
}) async {
1421+
final String apiPath =
1422+
'/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment'
1423+
.replaceAll('{databaseId}', databaseId)
1424+
.replaceAll('{collectionId}', collectionId)
1425+
.replaceAll('{documentId}', documentId)
1426+
.replaceAll('{attribute}', attribute);
1427+
1428+
final Map<String, dynamic> apiParams = {'value': value, 'max': max};
1429+
1430+
final Map<String, String> apiHeaders = {'content-type': 'application/json'};
1431+
1432+
final res = await client.call(
1433+
HttpMethod.patch,
1434+
path: apiPath,
1435+
params: apiParams,
1436+
headers: apiHeaders,
1437+
);
1438+
1439+
return models.Document.fromMap(res.data);
1440+
}
1441+
13811442
/// List indexes in the collection.
13821443
Future<models.IndexList> listIndexes({
13831444
required String databaseId,

lib/src/client_browser.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class ClientBrowser extends ClientBase with ClientMixin {
3030
'x-sdk-name': 'Dart',
3131
'x-sdk-platform': 'server',
3232
'x-sdk-language': 'dart',
33-
'x-sdk-version': '16.1.0',
33+
'x-sdk-version': '16.2.0',
3434
'X-Appwrite-Response-Format': '1.7.0',
3535
};
3636

lib/src/client_io.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ class ClientIO extends ClientBase with ClientMixin {
3636
'x-sdk-name': 'Dart',
3737
'x-sdk-platform': 'server',
3838
'x-sdk-language': 'dart',
39-
'x-sdk-version': '16.1.0',
39+
'x-sdk-version': '16.2.0',
4040
'user-agent':
41-
'AppwriteDartSDK/16.1.0 (${Platform.operatingSystem}; ${Platform.operatingSystemVersion})',
41+
'AppwriteDartSDK/16.2.0 (${Platform.operatingSystem}; ${Platform.operatingSystemVersion})',
4242
'X-Appwrite-Response-Format': '1.7.0',
4343
};
4444

lib/src/models/attribute_string.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ class AttributeString implements Model {
3232
/// Default value for attribute when not provided. Cannot be set when attribute is required.
3333
final String? xdefault;
3434

35+
/// Defines whether this attribute is encrypted or not.
36+
final bool? encrypt;
37+
3538
AttributeString({
3639
required this.key,
3740
required this.type,
@@ -43,6 +46,7 @@ class AttributeString implements Model {
4346
required this.$updatedAt,
4447
required this.size,
4548
this.xdefault,
49+
this.encrypt,
4650
});
4751

4852
factory AttributeString.fromMap(Map<String, dynamic> map) {
@@ -57,6 +61,7 @@ class AttributeString implements Model {
5761
$updatedAt: map['\$updatedAt'].toString(),
5862
size: map['size'],
5963
xdefault: map['default']?.toString(),
64+
encrypt: map['encrypt'],
6065
);
6166
}
6267

@@ -72,6 +77,7 @@ class AttributeString implements Model {
7277
"\$updatedAt": $updatedAt,
7378
"size": size,
7479
"default": xdefault,
80+
"encrypt": encrypt,
7581
};
7682
}
7783
}

0 commit comments

Comments
 (0)