Skip to content

Commit f4c98c9

Browse files
feat: support for 0.14.x
1 parent ab73474 commit f4c98c9

File tree

10 files changed

+87
-51
lines changed

10 files changed

+87
-51
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/appwrite?style=flat-square)](https://pub.dartlang.org/packages/appwrite)
44
![License](https://img.shields.io/github/license/appwrite/sdk-for-flutter.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-flutter/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-flutter/releases).**
1111

1212
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)
1313

@@ -21,7 +21,7 @@ Add this to your package's `pubspec.yaml` file:
2121

2222
```yml
2323
dependencies:
24-
appwrite: ^4.0.2
24+
appwrite: ^5.0.0
2525
```
2626
2727
You can install packages from the command line:

docs/examples/account/delete.md renamed to docs/examples/account/update-status.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ void main() { // Init SDK
88
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
99
.setProject('5df5acd0d48c2') // Your project ID
1010
;
11-
Future result = account.delete();
11+
Future result = account.updateStatus();
1212

1313
result
1414
.then((response) {

lib/services/account.dart

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -50,28 +50,6 @@ class Account extends Service {
5050
return models.User.fromMap(res.data);
5151
}
5252

53-
/// Delete Account
54-
///
55-
/// Delete a currently logged in user account. Behind the scene, the user
56-
/// record is not deleted but permanently blocked from any access. This is done
57-
/// to avoid deleted accounts being overtaken by new users with the same email
58-
/// address. Any user-related resources like documents or storage files should
59-
/// be deleted separately.
60-
///
61-
Future delete() async {
62-
const String path = '/account';
63-
64-
final Map<String, dynamic> params = {
65-
};
66-
67-
final Map<String, String> headers = {
68-
'content-type': 'application/json',
69-
};
70-
71-
final res = await client.call(HttpMethod.delete, path: path, params: params, headers: headers);
72-
return res.data;
73-
}
74-
7553
/// Update Account Email
7654
///
7755
/// Update currently logged in user account email address. After changing user
@@ -165,7 +143,7 @@ class Account extends Service {
165143
///
166144
/// Update currently logged in user password. For validation, user is required
167145
/// to pass in the new password, and the old password. For users created with
168-
/// OAuth and Team Invites, oldPassword is optional.
146+
/// OAuth, Team Invites and Magic URL, oldPassword is optional.
169147
///
170148
Future<models.User> updatePassword({required String password, String? oldPassword}) async {
171149
const String path = '/account/password';
@@ -491,6 +469,11 @@ class Account extends Service {
491469
}
492470

493471
/// Update Session (Refresh Tokens)
472+
///
473+
/// Access tokens have limited lifespan and expire to mitigate security risks.
474+
/// If session was created using an OAuth provider, this route can be used to
475+
/// "refresh" the access token.
476+
///
494477
Future<models.Session> updateSession({required String sessionId}) async {
495478
final String path = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId);
496479

@@ -526,6 +509,26 @@ class Account extends Service {
526509
return res.data;
527510
}
528511

512+
/// Update Account Status
513+
///
514+
/// Block the currently logged in user account. Behind the scene, the user
515+
/// record is not deleted but permanently blocked from any access. To
516+
/// completely delete a user, use the Users API instead.
517+
///
518+
Future<models.User> updateStatus() async {
519+
const String path = '/account/status';
520+
521+
final Map<String, dynamic> params = {
522+
};
523+
524+
final Map<String, String> headers = {
525+
'content-type': 'application/json',
526+
};
527+
528+
final res = await client.call(HttpMethod.patch, path: path, params: params, headers: headers);
529+
return models.User.fromMap(res.data);
530+
}
531+
529532
/// Create Email Verification
530533
///
531534
/// 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
@@ -9,9 +9,14 @@ class Avatars extends Service {
99
/// Get Browser Icon
1010
///
1111
/// You can use this endpoint to show different browser icons to your users.
12-
/// The code argument receives the browser code as it appears in your user
13-
/// /account/sessions endpoint. Use width, height and quality arguments to
14-
/// change the output settings.
12+
/// The code argument receives the browser code as it appears in your user [GET
13+
/// /account/sessions](/docs/client/account#accountGetSessions) endpoint. Use
14+
/// width, height and quality arguments to change the output settings.
15+
///
16+
/// When one dimension is specified and the other is 0, the image is scaled
17+
/// with preserved aspect ratio. If both dimensions are 0, the API provides an
18+
/// image at source quality. If dimensions are not specified, the default size
19+
/// of image returned is 100x100px.
1520
///
1621
Future<Uint8List> getBrowser({required String code, int? width, int? height, int? quality}) async {
1722
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);
@@ -70,6 +81,12 @@ class Avatars extends Service {
7081
/// You can use this endpoint to show different country flags icons to your
7182
/// users. The code argument receives the 2 letter country code. Use width,
7283
/// height and quality arguments to change the output settings.
84+
///
85+
/// When one dimension is specified and the other is 0, the image is scaled
86+
/// with preserved aspect ratio. If both dimensions are 0, the API provides an
87+
/// image at source quality. If dimensions are not specified, the default size
88+
/// of image returned is 100x100px.
89+
///
7390
///
7491
Future<Uint8List> getFlag({required String code, int? width, int? height, int? quality}) async {
7592
final String path = '/avatars/flags/{code}'.replaceAll('{code}', code);
@@ -91,6 +108,12 @@ class Avatars extends Service {
91108
/// you want. This endpoint is very useful if you need to crop and display
92109
/// remote images in your app or in case you want to make sure a 3rd party
93110
/// image is properly served using a TLS protocol.
111+
///
112+
/// When one dimension is specified and the other is 0, the image is scaled
113+
/// with preserved aspect ratio. If both dimensions are 0, the API provides an
114+
/// image at source quality. If dimensions are not specified, the default size
115+
/// of image returned is 400x400px.
116+
///
94117
///
95118
Future<Uint8List> getImage({required String url, int? width, int? height}) async {
96119
const String path = '/avatars/image';
@@ -118,6 +141,12 @@ class Avatars extends Service {
118141
/// default, a random theme will be selected. The random theme will persist for
119142
/// the user's initials when reloading the same theme will always return for
120143
/// the same initials.
144+
///
145+
/// When one dimension is specified and the other is 0, the image is scaled
146+
/// with preserved aspect ratio. If both dimensions are 0, the API provides an
147+
/// image at source quality. If dimensions are not specified, the default size
148+
/// of image returned is 100x100px.
149+
///
121150
///
122151
Future<Uint8List> getInitials({String? name, int? width, int? height, String? color, String? background}) async {
123152
const String path = '/avatars/initials';
@@ -139,6 +168,7 @@ class Avatars extends Service {
139168
///
140169
/// Converts a given plain text to a QR code image. You can use the query
141170
/// parameters to change the size and style of the resulting image.
171+
///
142172
///
143173
Future<Uint8List> getQR({required String text, int? size, int? margin, bool? download}) async {
144174
const String path = '/avatars/qr';

lib/services/database.dart

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

103103
/// Delete Document
104104
///
105-
/// Delete a document by its unique ID. This endpoint deletes only the parent
106-
/// documents, its attributes and relations to other documents. Child documents
107-
/// **will not** be deleted.
105+
/// Delete a document by its unique ID.
108106
///
109107
Future deleteDocument({required String collectionId, required String documentId}) async {
110108
final String path = '/database/collections/{collectionId}/documents/{documentId}'.replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId);

lib/src/client_browser.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ClientBrowser extends ClientBase with ClientMixin {
3737
.replaceFirst('http://', 'ws://');
3838
_headers = {
3939
'content-type': 'application/json',
40-
'x-sdk-version': 'appwrite:flutter:4.0.2',
40+
'x-sdk-version': 'appwrite:flutter:5.0.0',
4141
'X-Appwrite-Response-Format' : '0.13.0',
4242
};
4343

lib/src/client_io.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class ClientIO extends ClientBase with ClientMixin {
5555
.replaceFirst('http://', 'ws://');
5656
_headers = {
5757
'content-type': 'application/json',
58-
'x-sdk-version': 'appwrite:flutter:4.0.2',
58+
'x-sdk-version': 'appwrite:flutter:5.0.0',
5959
'X-Appwrite-Response-Format' : '0.13.0',
6060
};
6161

lib/src/models/execution.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ class Execution implements Model {
1616
final String status;
1717
/// The script status code.
1818
final int statusCode;
19-
/// The script stdout output string. Logs the last 4,000 characters of the execution stdout output.
20-
final String stdout;
19+
/// The script response output string. Logs the last 4,000 characters of the execution response output.
20+
final String response;
2121
/// The script stderr output string. Logs the last 4,000 characters of the execution stderr output
2222
final String stderr;
2323
/// The script execution time in seconds.
@@ -31,7 +31,7 @@ class Execution implements Model {
3131
required this.trigger,
3232
required this.status,
3333
required this.statusCode,
34-
required this.stdout,
34+
required this.response,
3535
required this.stderr,
3636
required this.time,
3737
});
@@ -45,7 +45,7 @@ class Execution implements Model {
4545
trigger: map['trigger'].toString(),
4646
status: map['status'].toString(),
4747
statusCode: map['statusCode'],
48-
stdout: map['stdout'].toString(),
48+
response: map['response'].toString(),
4949
stderr: map['stderr'].toString(),
5050
time: map['time'].toDouble(),
5151
);
@@ -61,7 +61,7 @@ class Execution implements Model {
6161
"trigger": trigger,
6262
"status": status,
6363
"statusCode": statusCode,
64-
"stdout": stdout,
64+
"response": response,
6565
"stderr": stderr,
6666
"time": time,
6767
};

lib/src/models/membership.dart

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ class Membership implements Model {
66
final String $id;
77
/// User ID.
88
final String userId;
9-
/// Team ID.
10-
final String teamId;
119
/// User name.
12-
final String name;
10+
final String userName;
1311
/// User email address.
14-
final String email;
12+
final String userEmail;
13+
/// Team ID.
14+
final String teamId;
15+
/// Team name.
16+
final String teamName;
1517
/// Date, the user has been invited to join the team in Unix timestamp.
1618
final int invited;
1719
/// Date, the user has accepted the invitation to join the team in Unix timestamp.
@@ -24,9 +26,10 @@ class Membership implements Model {
2426
Membership({
2527
required this.$id,
2628
required this.userId,
29+
required this.userName,
30+
required this.userEmail,
2731
required this.teamId,
28-
required this.name,
29-
required this.email,
32+
required this.teamName,
3033
required this.invited,
3134
required this.joined,
3235
required this.confirm,
@@ -37,9 +40,10 @@ class Membership implements Model {
3740
return Membership(
3841
$id: map['\$id'].toString(),
3942
userId: map['userId'].toString(),
43+
userName: map['userName'].toString(),
44+
userEmail: map['userEmail'].toString(),
4045
teamId: map['teamId'].toString(),
41-
name: map['name'].toString(),
42-
email: map['email'].toString(),
46+
teamName: map['teamName'].toString(),
4347
invited: map['invited'],
4448
joined: map['joined'],
4549
confirm: map['confirm'],
@@ -52,9 +56,10 @@ class Membership implements Model {
5256
return {
5357
"\$id": $id,
5458
"userId": userId,
59+
"userName": userName,
60+
"userEmail": userEmail,
5561
"teamId": teamId,
56-
"name": name,
57-
"email": email,
62+
"teamName": teamName,
5863
"invited": invited,
5964
"joined": joined,
6065
"confirm": confirm,

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: appwrite
2-
version: 4.0.2
2+
version: 5.0.0
33
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
44
homepage: https://appwrite.io
55
repository: https://github.com/appwrite/sdk-for-flutter

0 commit comments

Comments
 (0)