Skip to content

Commit 3fa7a0e

Browse files
committed
feat: update version
1 parent 02e1353 commit 3fa7a0e

File tree

14 files changed

+366
-89
lines changed

14 files changed

+366
-89
lines changed

README.md

Lines changed: 5 additions & 6 deletions
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:
Lines changed: 23 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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',
1717
);
1818

1919
result
Lines changed: 24 additions & 0 deletions
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

Lines changed: 6 additions & 4 deletions
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

Lines changed: 0 additions & 8 deletions
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

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ class Account extends Service {
5151
/// This endpoint can also be used to convert an anonymous account to a normal
5252
/// one, by passing an email address and a new password.
5353
///
54-
Future<Response> updateEmail({required String email, required String password}) {
54+
Future<Response> updateEmail({required String email
55+
, required String password
56+
}) {
5557
final String path = '/account/email';
5658

5759
final Map<String, dynamic> params = {
@@ -88,7 +90,8 @@ class Account extends Service {
8890
///
8991
/// Update currently logged in user account name.
9092
///
91-
Future<Response> updateName({required String name}) {
93+
Future<Response> updateName({required String name
94+
}) {
9295
final String path = '/account/name';
9396

9497
final Map<String, dynamic> params = {
@@ -108,7 +111,9 @@ class Account extends Service {
108111
/// to pass in the new password, and the old password. For users created with
109112
/// OAuth and Team Invites, oldPassword is optional.
110113
///
111-
Future<Response> updatePassword({required String password, String? oldPassword}) {
114+
Future<Response> updatePassword({required String password
115+
, String? oldPassword
116+
}) {
112117
final String path = '/account/password';
113118

114119
final Map<String, dynamic> params = {
@@ -145,7 +150,8 @@ class Account extends Service {
145150
/// Update currently logged in user account preferences. You can pass only the
146151
/// specific settings you wish to update.
147152
///
148-
Future<Response> updatePrefs({required Map prefs}) {
153+
Future<Response> updatePrefs({required Map prefs
154+
}) {
149155
final String path = '/account/prefs';
150156

151157
final Map<String, dynamic> params = {
@@ -170,7 +176,9 @@ class Account extends Service {
170176
/// complete the process. The verification link sent to the user's email
171177
/// address is valid for 1 hour.
172178
///
173-
Future<Response> createRecovery({required String email, required String url}) {
179+
Future<Response> createRecovery({required String email
180+
, required String url
181+
}) {
174182
final String path = '/account/recovery';
175183

176184
final Map<String, dynamic> params = {
@@ -197,7 +205,11 @@ class Account extends Service {
197205
/// the only valid redirect URLs are the ones from domains you have set when
198206
/// adding your platforms in the console interface.
199207
///
200-
Future<Response> updateRecovery({required String userId, required String secret, required String password, required String passwordAgain}) {
208+
Future<Response> updateRecovery({required String userId
209+
, required String secret
210+
, required String password
211+
, required String passwordAgain
212+
}) {
201213
final String path = '/account/recovery';
202214

203215
final Map<String, dynamic> params = {
@@ -250,13 +262,33 @@ class Account extends Service {
250262
return client.call(HttpMethod.delete, path: path, params: params, headers: headers);
251263
}
252264

265+
/// Get Session By ID
266+
///
267+
/// Use this endpoint to get a logged in user's session using a Session ID.
268+
/// Inputting 'current' will return the current session being used.
269+
///
270+
Future<Response> getSession({required String sessionId
271+
}) {
272+
final String path = '/account/sessions/{sessionId}'.replaceAll(RegExp('{sessionId}'), sessionId);
273+
274+
final Map<String, dynamic> params = {
275+
};
276+
277+
final Map<String, String> headers = {
278+
'content-type': 'application/json',
279+
};
280+
281+
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
282+
}
283+
253284
/// Delete Account Session
254285
///
255286
/// Use this endpoint to log out the currently logged in user from all their
256287
/// account sessions across all of their different devices. When using the
257288
/// option id argument, only the session unique ID provider will be deleted.
258289
///
259-
Future<Response> deleteSession({required String sessionId}) {
290+
Future<Response> deleteSession({required String sessionId
291+
}) {
260292
final String path = '/account/sessions/{sessionId}'.replaceAll(RegExp('{sessionId}'), sessionId);
261293

262294
final Map<String, dynamic> params = {
@@ -287,7 +319,8 @@ class Account extends Service {
287319
/// adding your platforms in the console interface.
288320
///
289321
///
290-
Future<Response> createVerification({required String url}) {
322+
Future<Response> createVerification({required String url
323+
}) {
291324
final String path = '/account/verification';
292325

293326
final Map<String, dynamic> params = {
@@ -308,7 +341,9 @@ class Account extends Service {
308341
/// to verify the user email ownership. If confirmed this route will return a
309342
/// 200 status code.
310343
///
311-
Future<Response> updateVerification({required String userId, required String secret}) {
344+
Future<Response> updateVerification({required String userId
345+
, required String secret
346+
}) {
312347
final String path = '/account/verification';
313348

314349
final Map<String, dynamic> params = {

lib/services/avatars.dart

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ class Avatars extends Service {
1111
/// /account/sessions endpoint. Use width, height and quality arguments to
1212
/// change the output settings.
1313
///
14-
Future<Response> getBrowser({required String code, int? width, int? height, int? quality}) {
14+
Future<Response> getBrowser({required String code
15+
, int? width
16+
, int? height
17+
, int? quality
18+
}) {
1519
final String path = '/avatars/browsers/{code}'.replaceAll(RegExp('{code}'), code);
1620

1721
final Map<String, dynamic> params = {
@@ -35,7 +39,11 @@ class Avatars extends Service {
3539
/// provider you need. Use width, height and quality arguments to change the
3640
/// output settings.
3741
///
38-
Future<Response> getCreditCard({required String code, int? width, int? height, int? quality}) {
42+
Future<Response> getCreditCard({required String code
43+
, int? width
44+
, int? height
45+
, int? quality
46+
}) {
3947
final String path = '/avatars/credit-cards/{code}'.replaceAll(RegExp('{code}'), code);
4048

4149
final Map<String, dynamic> params = {
@@ -59,7 +67,8 @@ class Avatars extends Service {
5967
/// website URL.
6068
///
6169
///
62-
Future<Response> getFavicon({required String url}) {
70+
Future<Response> getFavicon({required String url
71+
}) {
6372
final String path = '/avatars/favicon';
6473

6574
final Map<String, dynamic> params = {
@@ -81,7 +90,11 @@ class Avatars extends Service {
8190
/// users. The code argument receives the 2 letter country code. Use width,
8291
/// height and quality arguments to change the output settings.
8392
///
84-
Future<Response> getFlag({required String code, int? width, int? height, int? quality}) {
93+
Future<Response> getFlag({required String code
94+
, int? width
95+
, int? height
96+
, int? quality
97+
}) {
8598
final String path = '/avatars/flags/{code}'.replaceAll(RegExp('{code}'), code);
8699

87100
final Map<String, dynamic> params = {
@@ -106,7 +119,10 @@ class Avatars extends Service {
106119
/// remote images in your app or in case you want to make sure a 3rd party
107120
/// image is properly served using a TLS protocol.
108121
///
109-
Future<Response> getImage({required String url, int? width, int? height}) {
122+
Future<Response> getImage({required String url
123+
, int? width
124+
, int? height
125+
}) {
110126
final String path = '/avatars/image';
111127

112128
final Map<String, dynamic> params = {
@@ -137,7 +153,12 @@ class Avatars extends Service {
137153
/// the user's initials when reloading the same theme will always return for
138154
/// the same initials.
139155
///
140-
Future<Response> getInitials({String? name, int? width, int? height, String? color, String? background}) {
156+
Future<Response> getInitials({String? name
157+
, int? width
158+
, int? height
159+
, String? color
160+
, String? background
161+
}) {
141162
final String path = '/avatars/initials';
142163

143164
final Map<String, dynamic> params = {
@@ -162,7 +183,11 @@ class Avatars extends Service {
162183
/// Converts a given plain text to a QR code image. You can use the query
163184
/// parameters to change the size and style of the resulting image.
164185
///
165-
Future<Response> getQR({required String text, int? size, int? margin, bool? download}) {
186+
Future<Response> getQR({required String text
187+
, int? size
188+
, int? margin
189+
, bool? download
190+
}) {
166191
final String path = '/avatars/qr';
167192

168193
final Map<String, dynamic> params = {

0 commit comments

Comments
 (0)