Skip to content

Commit bddfa8f

Browse files
Merge pull request #6 from appwrite/dev
feat: update version
2 parents 02e1353 + 53cb8e9 commit bddfa8f

14 files changed

+129
-43
lines changed

CHANGELOG.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## 0.7.0
2+
- Support for Appwrite 0.9
3+
- Breaking - removed order type enum, now you should pass string 'ASC' or 'DESC'
4+
- Breaking - changed param name from `env` to `runtime` in the **Functions** API
5+
- Image Crop Gravity support in image preview service
6+
- New endpoint in Account getSession to get session by ID
7+
- New endpoint in the Users API to update user verification status
8+
- Fix - issues with User-Agent when app name consisted of non-ASCII characters
9+
110
## 0.6.2
211

312
- Removed default values, nothing should change in usage as default values are already allocated in server
@@ -37,4 +46,4 @@
3746

3847
## 0.1.0
3948

40-
- First release
49+
- First release

README.md

+6-7
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@
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.8.0-blue.svg?style=flat-square)
5+
![Version](https://img.shields.io/badge/api%20version-0.9.0-blue.svg?style=flat-square)
6+
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
67
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite_io?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite_io)
78
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
89

9-
**This SDK is compatible with Appwrite server version 0.8.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.9.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-dart/releases).**
1011

1112
> 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)
1213
13-
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.
14-
Use the Dart SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools.
15-
For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
14+
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 Dart 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)
1615

1716

1817

@@ -24,7 +23,7 @@ Add this to your package's `pubspec.yaml` file:
2423

2524
```yml
2625
dependencies:
27-
dart_appwrite: ^0.6.3
26+
dart_appwrite: ^0.7.0
2827
```
2928
3029
You can install packages from the command line:
@@ -76,7 +75,7 @@ try {
7675
```
7776

7877
### Learn more
79-
You can use followng resources to learn more and get help
78+
You can use following resources to learn more and get help
8079
- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-server)
8180
- 📜 [Appwrite Docs](https://appwrite.io/docs)
8281
- 💬 [Discord Community](https://appwrite.io/discord)

docs/examples/account/get-session.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import 'package:dart_appwrite/dart_appwrite.dart';
2+
3+
void main() { // Init SDK
4+
Client client = Client();
5+
Account account = Account(client);
6+
7+
client
8+
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
9+
.setProject('5df5acd0d48c2') // Your project ID
10+
.setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token
11+
;
12+
13+
Future result = account.getSession(
14+
sessionId: '[SESSION_ID]',
15+
);
16+
17+
result
18+
.then((response) {
19+
print(response);
20+
}).catchError((error) {
21+
print(error.response);
22+
});
23+
}

docs/examples/functions/create.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ void main() { // Init SDK
1313
Future result = functions.create(
1414
name: '[NAME]',
1515
execute: [],
16-
env: 'dotnet-3.1',
16+
runtime: 'java-11.0',
1717
);
1818

1919
result
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import 'package:dart_appwrite/dart_appwrite.dart';
2+
3+
void main() { // Init SDK
4+
Client client = Client();
5+
Users users = Users(client);
6+
7+
client
8+
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
9+
.setProject('5df5acd0d48c2') // Your project ID
10+
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
11+
;
12+
13+
Future result = users.updateVerification(
14+
userId: '[USER_ID]',
15+
emailVerification: false,
16+
);
17+
18+
result
19+
.then((response) {
20+
print(response);
21+
}).catchError((error) {
22+
print(error.response);
23+
});
24+
}

lib/client.dart

+6-4
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ class Client {
1313

1414
this.headers = {
1515
'content-type': 'application/json',
16-
'x-sdk-version': 'appwrite:dart:0.6.3',
17-
'X-Appwrite-Response-Format':'0.8.0',
16+
'x-sdk-version': 'appwrite:dart:0.7.0',
17+
'X-Appwrite-Response-Format':'0.9.0',
1818
};
1919

2020
this.config = {};
@@ -82,7 +82,9 @@ class Client {
8282
};
8383
}
8484

85-
params.removeWhere((key,value) => value == null);
85+
if(params.isNotEmpty) {
86+
params.removeWhere((key,value) => value == null);
87+
}
8688

8789
// Origin is hardcoded for testing
8890
Options options = Options(
@@ -127,4 +129,4 @@ class Client {
127129
throw AppwriteException(e.toString());
128130
}
129131
}
130-
}
132+
}

lib/enums.dart

-8
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,3 @@ extension HttpMethodString on HttpMethod {
77
return this.toString().split('.').last.toUpperCase();
88
}
99
}
10-
11-
enum OrderType { asc, desc }
12-
13-
extension OrderTypeString on OrderType {
14-
String name() {
15-
return this.toString().split('.').last.toUpperCase();
16-
}
17-
}

lib/services/account.dart

+18
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,24 @@ class Account extends Service {
250250
return client.call(HttpMethod.delete, path: path, params: params, headers: headers);
251251
}
252252

253+
/// Get Session By ID
254+
///
255+
/// Use this endpoint to get a logged in user's session using a Session ID.
256+
/// Inputting 'current' will return the current session being used.
257+
///
258+
Future<Response> getSession({required String sessionId}) {
259+
final String path = '/account/sessions/{sessionId}'.replaceAll(RegExp('{sessionId}'), sessionId);
260+
261+
final Map<String, dynamic> params = {
262+
};
263+
264+
final Map<String, String> headers = {
265+
'content-type': 'application/json',
266+
};
267+
268+
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
269+
}
270+
253271
/// Delete Account Session
254272
///
255273
/// Use this endpoint to log out the currently logged in user from all their

lib/services/database.dart

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ class Database extends Service {
1111
/// of the project's collections. [Learn more about different API
1212
/// modes](/docs/admin).
1313
///
14-
Future<Response> listCollections({String? search, int? limit, int? offset, OrderType? orderType}) {
14+
Future<Response> listCollections({String? search, int? limit, int? offset, String? orderType}) {
1515
final String path = '/database/collections';
1616

1717
final Map<String, dynamic> params = {
1818
'search': search,
1919
'limit': limit,
2020
'offset': offset,
21-
'orderType': orderType?.name(),
21+
'orderType': orderType,
2222
};
2323

2424
final Map<String, String> headers = {
@@ -113,15 +113,15 @@ class Database extends Service {
113113
/// of the project's documents. [Learn more about different API
114114
/// modes](/docs/admin).
115115
///
116-
Future<Response> listDocuments({required String collectionId, List? filters, int? limit, int? offset, String? orderField, OrderType? orderType, String? orderCast, String? search}) {
116+
Future<Response> listDocuments({required String collectionId, List? filters, int? limit, int? offset, String? orderField, String? orderType, String? orderCast, String? search}) {
117117
final String path = '/database/collections/{collectionId}/documents'.replaceAll(RegExp('{collectionId}'), collectionId);
118118

119119
final Map<String, dynamic> params = {
120120
'filters': filters,
121121
'limit': limit,
122122
'offset': offset,
123123
'orderField': orderField,
124-
'orderType': orderType?.name(),
124+
'orderType': orderType,
125125
'orderCast': orderCast,
126126
'search': search,
127127
};

lib/services/functions.dart

+8-8
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ class Functions extends Service {
99
/// Get a list of all the project's functions. You can use the query params to
1010
/// filter your results.
1111
///
12-
Future<Response> list({String? search, int? limit, int? offset, OrderType? orderType}) {
12+
Future<Response> list({String? search, int? limit, int? offset, String? orderType}) {
1313
final String path = '/functions';
1414

1515
final Map<String, dynamic> params = {
1616
'search': search,
1717
'limit': limit,
1818
'offset': offset,
19-
'orderType': orderType?.name(),
19+
'orderType': orderType,
2020
};
2121

2222
final Map<String, String> headers = {
@@ -32,13 +32,13 @@ class Functions extends Service {
3232
/// [permissions](/docs/permissions) to allow different project users or team
3333
/// with access to execute the function using the client API.
3434
///
35-
Future<Response> create({required String name, required List execute, required String env, Map? vars, List? events, String? schedule, int? timeout}) {
35+
Future<Response> create({required String name, required List execute, required String runtime, Map? vars, List? events, String? schedule, int? timeout}) {
3636
final String path = '/functions';
3737

3838
final Map<String, dynamic> params = {
3939
'name': name,
4040
'execute': execute,
41-
'env': env,
41+
'runtime': runtime,
4242
'vars': vars,
4343
'events': events,
4444
'schedule': schedule,
@@ -116,14 +116,14 @@ class Functions extends Service {
116116
/// return a list of all of the project's executions. [Learn more about
117117
/// different API modes](/docs/admin).
118118
///
119-
Future<Response> listExecutions({required String functionId, String? search, int? limit, int? offset, OrderType? orderType}) {
119+
Future<Response> listExecutions({required String functionId, String? search, int? limit, int? offset, String? orderType}) {
120120
final String path = '/functions/{functionId}/executions'.replaceAll(RegExp('{functionId}'), functionId);
121121

122122
final Map<String, dynamic> params = {
123123
'search': search,
124124
'limit': limit,
125125
'offset': offset,
126-
'orderType': orderType?.name(),
126+
'orderType': orderType,
127127
};
128128

129129
final Map<String, String> headers = {
@@ -196,14 +196,14 @@ class Functions extends Service {
196196
/// Get a list of all the project's code tags. You can use the query params to
197197
/// filter your results.
198198
///
199-
Future<Response> listTags({required String functionId, String? search, int? limit, int? offset, OrderType? orderType}) {
199+
Future<Response> listTags({required String functionId, String? search, int? limit, int? offset, String? orderType}) {
200200
final String path = '/functions/{functionId}/tags'.replaceAll(RegExp('{functionId}'), functionId);
201201

202202
final Map<String, dynamic> params = {
203203
'search': search,
204204
'limit': limit,
205205
'offset': offset,
206-
'orderType': orderType?.name(),
206+
'orderType': orderType,
207207
};
208208

209209
final Map<String, String> headers = {

lib/services/storage.dart

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ class Storage extends Service {
1010
/// your results. On admin mode, this endpoint will return a list of all of the
1111
/// project's files. [Learn more about different API modes](/docs/admin).
1212
///
13-
Future<Response> listFiles({String? search, int? limit, int? offset, OrderType? orderType}) {
13+
Future<Response> listFiles({String? search, int? limit, int? offset, String? orderType}) {
1414
final String path = '/storage/files';
1515

1616
final Map<String, dynamic> params = {
1717
'search': search,
1818
'limit': limit,
1919
'offset': offset,
20-
'orderType': orderType?.name(),
20+
'orderType': orderType,
2121
};
2222

2323
final Map<String, String> headers = {
@@ -133,12 +133,13 @@ class Storage extends Service {
133133
/// and spreadsheets, will return the file icon image. You can also pass query
134134
/// string arguments for cutting and resizing your preview image.
135135
///
136-
Future<Response> getFilePreview({required String fileId, int? width, int? height, int? quality, int? borderWidth, String? borderColor, int? borderRadius, double? opacity, int? rotation, String? background, String? output}) {
136+
Future<Response> getFilePreview({required String fileId, int? width, int? height, String? gravity, int? quality, int? borderWidth, String? borderColor, int? borderRadius, double? opacity, int? rotation, String? background, String? output}) {
137137
final String path = '/storage/files/{fileId}/preview'.replaceAll(RegExp('{fileId}'), fileId);
138138

139139
final Map<String, dynamic> params = {
140140
'width': width,
141141
'height': height,
142+
'gravity': gravity,
142143
'quality': quality,
143144
'borderWidth': borderWidth,
144145
'borderColor': borderColor,

lib/services/teams.dart

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ class Teams extends Service {
1111
/// of the project's teams. [Learn more about different API
1212
/// modes](/docs/admin).
1313
///
14-
Future<Response> list({String? search, int? limit, int? offset, OrderType? orderType}) {
14+
Future<Response> list({String? search, int? limit, int? offset, String? orderType}) {
1515
final String path = '/teams';
1616

1717
final Map<String, dynamic> params = {
1818
'search': search,
1919
'limit': limit,
2020
'offset': offset,
21-
'orderType': orderType?.name(),
21+
'orderType': orderType,
2222
};
2323

2424
final Map<String, String> headers = {
@@ -110,14 +110,14 @@ class Teams extends Service {
110110
/// Get a team members by the team unique ID. All team members have read access
111111
/// for this list of resources.
112112
///
113-
Future<Response> getMemberships({required String teamId, String? search, int? limit, int? offset, OrderType? orderType}) {
113+
Future<Response> getMemberships({required String teamId, String? search, int? limit, int? offset, String? orderType}) {
114114
final String path = '/teams/{teamId}/memberships'.replaceAll(RegExp('{teamId}'), teamId);
115115

116116
final Map<String, dynamic> params = {
117117
'search': search,
118118
'limit': limit,
119119
'offset': offset,
120-
'orderType': orderType?.name(),
120+
'orderType': orderType,
121121
};
122122

123123
final Map<String, String> headers = {

lib/services/users.dart

+20-2
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ class Users extends Service {
99
/// Get a list of all the project's users. You can use the query params to
1010
/// filter your results.
1111
///
12-
Future<Response> list({String? search, int? limit, int? offset, OrderType? orderType}) {
12+
Future<Response> list({String? search, int? limit, int? offset, String? orderType}) {
1313
final String path = '/users';
1414

1515
final Map<String, dynamic> params = {
1616
'search': search,
1717
'limit': limit,
1818
'offset': offset,
19-
'orderType': orderType?.name(),
19+
'orderType': orderType,
2020
};
2121

2222
final Map<String, String> headers = {
@@ -199,6 +199,24 @@ class Users extends Service {
199199
'content-type': 'application/json',
200200
};
201201

202+
return client.call(HttpMethod.patch, path: path, params: params, headers: headers);
203+
}
204+
205+
/// Update Email Verification
206+
///
207+
/// Update the user email verification status by its unique ID.
208+
///
209+
Future<Response> updateVerification({required String userId, required bool emailVerification}) {
210+
final String path = '/users/{userId}/verification'.replaceAll(RegExp('{userId}'), userId);
211+
212+
final Map<String, dynamic> params = {
213+
'emailVerification': emailVerification,
214+
};
215+
216+
final Map<String, String> headers = {
217+
'content-type': 'application/json',
218+
};
219+
202220
return client.call(HttpMethod.patch, path: path, params: params, headers: headers);
203221
}
204222
}

0 commit comments

Comments
 (0)