Skip to content

Commit db0f1c7

Browse files
feat: support for 0.14.x
1 parent a462e8b commit db0f1c7

File tree

14 files changed

+119
-77
lines changed

14 files changed

+119
-77
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
[![pub package](https://img.shields.io/pub/v/dart_appwrite.svg?style=flat-square)](https://pub.dartlang.org/packages/dart_appwrite)
44
![License](https://img.shields.io/github/license/appwrite/sdk-for-dart.svg?style=flat-square)
5-
![Version](https://img.shields.io/badge/api%20version-0.13.0-blue.svg?style=flat-square)
5+
![Version](https://img.shields.io/badge/api%20version-0.14.0-blue.svg?style=flat-square)
66
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
77
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
88
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
99

10-
**This SDK is compatible with Appwrite server version 0.13.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-dart/releases).**
10+
**This SDK is compatible with Appwrite server version 0.14.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-dart/releases).**
1111

1212
> This is the Dart SDK for integrating with Appwrite from your Dart server-side code. If you're looking for the Flutter SDK you should check [appwrite/sdk-for-flutter](https://github.com/appwrite/sdk-for-flutter)
1313
@@ -23,7 +23,7 @@ Add this to your package's `pubspec.yaml` file:
2323

2424
```yml
2525
dependencies:
26-
dart_appwrite: ^4.0.2
26+
dart_appwrite: ^5.0.0
2727
```
2828
2929
You can install packages from the command line:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ void main() { // Init SDK
1010
.setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token
1111
;
1212

13-
Future result = account.delete();
13+
Future result = account.updateStatus();
1414

1515
result
1616
.then((response) {
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@ import 'package:dart_appwrite/dart_appwrite.dart';
22

33
void main() { // Init SDK
44
Client client = Client();
5-
Health health = Health(client);
5+
Users users = Users(client);
66

77
client
88
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
99
.setProject('5df5acd0d48c2') // Your project ID
1010
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
1111
;
1212

13-
Future result = health.getQueueUsage();
13+
Future result = users.getMemberships(
14+
userId: '[USER_ID]',
15+
);
1416

1517
result
1618
.then((response) {

lib/services/account.dart

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,6 @@ class Account extends Service {
2323
return models.User.fromMap(res.data);
2424
}
2525

26-
/// Delete Account
27-
///
28-
/// Delete a currently logged in user account. Behind the scene, the user
29-
/// record is not deleted but permanently blocked from any access. This is done
30-
/// to avoid deleted accounts being overtaken by new users with the same email
31-
/// address. Any user-related resources like documents or storage files should
32-
/// be deleted separately.
33-
///
34-
Future delete() async {
35-
final String path = '/account';
36-
37-
final Map<String, dynamic> params = {
38-
};
39-
40-
final Map<String, String> headers = {
41-
'content-type': 'application/json',
42-
};
43-
44-
45-
final res = await client.call(HttpMethod.delete, path: path, params: params, headers: headers);
46-
return res.data;
47-
}
48-
4926
/// Update Account Email
5027
///
5128
/// Update currently logged in user account email address. After changing user
@@ -120,7 +97,7 @@ class Account extends Service {
12097
///
12198
/// Update currently logged in user password. For validation, user is required
12299
/// to pass in the new password, and the old password. For users created with
123-
/// OAuth and Team Invites, oldPassword is optional.
100+
/// OAuth, Team Invites and Magic URL, oldPassword is optional.
124101
///
125102
Future<models.User> updatePassword({required String password, String? oldPassword}) async {
126103
final String path = '/account/password';
@@ -300,6 +277,11 @@ class Account extends Service {
300277
}
301278

302279
/// Update Session (Refresh Tokens)
280+
///
281+
/// Access tokens have limited lifespan and expire to mitigate security risks.
282+
/// If session was created using an OAuth provider, this route can be used to
283+
/// "refresh" the access token.
284+
///
303285
Future<models.Session> updateSession({required String sessionId}) async {
304286
final String path = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId);
305287

@@ -337,6 +319,27 @@ class Account extends Service {
337319
return res.data;
338320
}
339321

322+
/// Update Account Status
323+
///
324+
/// Block the currently logged in user account. Behind the scene, the user
325+
/// record is not deleted but permanently blocked from any access. To
326+
/// completely delete a user, use the Users API instead.
327+
///
328+
Future<models.User> updateStatus() async {
329+
final String path = '/account/status';
330+
331+
final Map<String, dynamic> params = {
332+
};
333+
334+
final Map<String, String> headers = {
335+
'content-type': 'application/json',
336+
};
337+
338+
339+
final res = await client.call(HttpMethod.patch, path: path, params: params, headers: headers);
340+
return models.User.fromMap(res.data);
341+
}
342+
340343
/// Create Email Verification
341344
///
342345
/// Use this endpoint to send a verification message to your user email address

lib/services/avatars.dart

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,14 @@ class Avatars extends Service {
88
/// Get Browser Icon
99
///
1010
/// You can use this endpoint to show different browser icons to your users.
11-
/// The code argument receives the browser code as it appears in your user
12-
/// /account/sessions endpoint. Use width, height and quality arguments to
13-
/// change the output settings.
11+
/// The code argument receives the browser code as it appears in your user [GET
12+
/// /account/sessions](/docs/client/account#accountGetSessions) endpoint. Use
13+
/// width, height and quality arguments to change the output settings.
14+
///
15+
/// When one dimension is specified and the other is 0, the image is scaled
16+
/// with preserved aspect ratio. If both dimensions are 0, the API provides an
17+
/// image at source quality. If dimensions are not specified, the default size
18+
/// of image returned is 100x100px.
1419
///
1520
Future<Uint8List> getBrowser({required String code, int? width, int? height, int? quality}) async {
1621
final String path = '/avatars/browsers/{code}'.replaceAll('{code}', code);
@@ -32,6 +37,12 @@ class Avatars extends Service {
3237
/// The credit card endpoint will return you the icon of the credit card
3338
/// provider you need. Use width, height and quality arguments to change the
3439
/// output settings.
40+
///
41+
/// When one dimension is specified and the other is 0, the image is scaled
42+
/// with preserved aspect ratio. If both dimensions are 0, the API provides an
43+
/// image at source quality. If dimensions are not specified, the default size
44+
/// of image returned is 100x100px.
45+
///
3546
///
3647
Future<Uint8List> getCreditCard({required String code, int? width, int? height, int? quality}) async {
3748
final String path = '/avatars/credit-cards/{code}'.replaceAll('{code}', code);
@@ -72,6 +83,12 @@ class Avatars extends Service {
7283
/// You can use this endpoint to show different country flags icons to your
7384
/// users. The code argument receives the 2 letter country code. Use width,
7485
/// height and quality arguments to change the output settings.
86+
///
87+
/// When one dimension is specified and the other is 0, the image is scaled
88+
/// with preserved aspect ratio. If both dimensions are 0, the API provides an
89+
/// image at source quality. If dimensions are not specified, the default size
90+
/// of image returned is 100x100px.
91+
///
7592
///
7693
Future<Uint8List> getFlag({required String code, int? width, int? height, int? quality}) async {
7794
final String path = '/avatars/flags/{code}'.replaceAll('{code}', code);
@@ -94,6 +111,12 @@ class Avatars extends Service {
94111
/// you want. This endpoint is very useful if you need to crop and display
95112
/// remote images in your app or in case you want to make sure a 3rd party
96113
/// image is properly served using a TLS protocol.
114+
///
115+
/// When one dimension is specified and the other is 0, the image is scaled
116+
/// with preserved aspect ratio. If both dimensions are 0, the API provides an
117+
/// image at source quality. If dimensions are not specified, the default size
118+
/// of image returned is 400x400px.
119+
///
97120
///
98121
Future<Uint8List> getImage({required String url, int? width, int? height}) async {
99122
final String path = '/avatars/image';
@@ -122,6 +145,12 @@ class Avatars extends Service {
122145
/// default, a random theme will be selected. The random theme will persist for
123146
/// the user's initials when reloading the same theme will always return for
124147
/// the same initials.
148+
///
149+
/// When one dimension is specified and the other is 0, the image is scaled
150+
/// with preserved aspect ratio. If both dimensions are 0, the API provides an
151+
/// image at source quality. If dimensions are not specified, the default size
152+
/// of image returned is 100x100px.
153+
///
125154
///
126155
Future<Uint8List> getInitials({String? name, int? width, int? height, String? color, String? background}) async {
127156
final String path = '/avatars/initials';
@@ -144,6 +173,7 @@ class Avatars extends Service {
144173
///
145174
/// Converts a given plain text to a QR code image. You can use the query
146175
/// parameters to change the size and style of the resulting image.
176+
///
147177
///
148178
Future<Uint8List> getQR({required String text, int? size, int? margin, bool? download}) async {
149179
final String path = '/avatars/qr';

lib/services/database.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,9 +465,7 @@ class Database extends Service {
465465

466466
/// Delete Document
467467
///
468-
/// Delete a document by its unique ID. This endpoint deletes only the parent
469-
/// documents, its attributes and relations to other documents. Child documents
470-
/// **will not** be deleted.
468+
/// Delete a document by its unique ID.
471469
///
472470
Future deleteDocument({required String collectionId, required String documentId}) async {
473471
final String path = '/database/collections/{collectionId}/documents/{documentId}'.replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId);

lib/services/functions.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class Functions extends Service {
6060
return models.Func.fromMap(res.data);
6161
}
6262

63-
/// List the currently active function runtimes.
63+
/// List runtimes
6464
///
6565
/// Get a list of all runtimes that are currently active on your instance.
6666
///

lib/services/health.dart

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -135,26 +135,6 @@ class Health extends Service {
135135
};
136136

137137

138-
final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers);
139-
return models.HealthQueue.fromMap(res.data);
140-
}
141-
142-
/// Get Usage Queue
143-
///
144-
/// Get the number of usage stats that are waiting to be processed in the
145-
/// Appwrite internal queue server.
146-
///
147-
Future<models.HealthQueue> getQueueUsage() async {
148-
final String path = '/health/queue/usage';
149-
150-
final Map<String, dynamic> params = {
151-
};
152-
153-
final Map<String, String> headers = {
154-
'content-type': 'application/json',
155-
};
156-
157-
158138
final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers);
159139
return models.HealthQueue.fromMap(res.data);
160140
}

lib/services/users.dart

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ class Users extends Service {
7474

7575
/// Delete User
7676
///
77-
/// Delete a user by its unique ID.
77+
/// Delete a user by its unique ID, thereby releasing it's ID. Since ID is
78+
/// released and can be reused, all user-related resources like documents or
79+
/// storage files should be deleted before user deletion. If you want to keep
80+
/// ID reserved, use the [updateStatus](/docs/server/users#usersUpdateStatus)
81+
/// endpoint instead.
7882
///
7983
Future delete({required String userId}) async {
8084
final String path = '/users/{userId}'.replaceAll('{userId}', userId);
@@ -132,6 +136,25 @@ class Users extends Service {
132136
return models.LogList.fromMap(res.data);
133137
}
134138

139+
/// Get User Memberships
140+
///
141+
/// Get the user membership list by its unique ID.
142+
///
143+
Future<models.MembershipList> getMemberships({required String userId}) async {
144+
final String path = '/users/{userId}/memberships'.replaceAll('{userId}', userId);
145+
146+
final Map<String, dynamic> params = {
147+
};
148+
149+
final Map<String, String> headers = {
150+
'content-type': 'application/json',
151+
};
152+
153+
154+
final res = await client.call(HttpMethod.get, path: path, params: params, headers: headers);
155+
return models.MembershipList.fromMap(res.data);
156+
}
157+
135158
/// Update Name
136159
///
137160
/// Update the user name by its unique ID.
@@ -272,7 +295,8 @@ class Users extends Service {
272295

273296
/// Update User Status
274297
///
275-
/// Update the user status by its unique ID.
298+
/// Update the user status by its unique ID. Use this endpoint as an
299+
/// alternative to deleting a user if you want to keep user's ID reserved.
276300
///
277301
Future<models.User> updateStatus({required String userId, required bool status}) async {
278302
final String path = '/users/{userId}/status'.replaceAll('{userId}', userId);

lib/src/client_browser.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class ClientBrowser extends ClientBase with ClientMixin {
2626
_httpClient = BrowserClient();
2727
_headers = {
2828
'content-type': 'application/json',
29-
'x-sdk-version': 'appwrite:dart:4.0.2',
29+
'x-sdk-version': 'appwrite:dart:5.0.0',
3030
'X-Appwrite-Response-Format' : '0.13.0',
3131
};
3232

0 commit comments

Comments
 (0)