Skip to content

Commit

Permalink
Upgraded to support Appwrite 0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
eldadfux committed May 19, 2021
1 parent e5d0f3a commit d8303f7
Show file tree
Hide file tree
Showing 36 changed files with 819 additions and 33 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 0.6.0

- Upgraded to Null-safety, minimum Dart SDK required 2.12.0
- Upgraded all underlying dependencies to null safe version
- BREAKING Renamed users.deleteUser to users.delete
- BREAKING Renamed parameter inviteId to membershipId on teams.updateMembershipStatus, teams.deleteMembership
- JWT Support client.setJWT('JWT_GENERATED_IN_CLIENT')
- [Update membership roles](https://appwrite.io/docs/client/teams?sdk=dart#teamsUpdateMembershipRoles)
- New awesome image preview features, supports borderRadius, borderColor, borderWidth

## 0.5.0-dev.1

- Upgraded to Null-safety, minimum Dart SDK required 2.12.0
Expand Down
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

[![pub package](https://img.shields.io/pub/v/dart_appwrite.svg?style=flat-square)](https://pub.dartlang.org/packages/dart_appwrite)
![License](https://img.shields.io/github/license/appwrite/sdk-for-dart.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-0.7.0-blue.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-0.8.0-blue.svg?style=flat-square)
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite_io?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite_io)
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)

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

> 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)
Expand All @@ -24,7 +24,7 @@ Add this to your package's `pubspec.yaml` file:

```yml
dependencies:
dart_appwrite: ^0.5.0-dev.1
dart_appwrite: ^0.6.0
```
You can install packages from the command line:
Expand All @@ -47,6 +47,7 @@ void main() async {
.setEndpoint('http://[HOSTNAME_OR_IP]/v1') // Make sure your endpoint is accessible
.setProject('5ff3379a01d25') // Your project ID
.setKey('cd868c7af8bdc893b4...93b7535db89')
.setSelfSigned() // Use only on dev mode with a self-signed SSL cert
Users users = Users(client);
Expand All @@ -59,6 +60,21 @@ void main() async {
}
```

### Error handling
The Appwrite Dart SDK raises `AppwriteException` object with `message`, `code` and `response` properties. You can handle any errors by catching `AppwriteException` and present the `message` to the user or handle it yourself based on the provided error information. Below is an example.

```dart
Users users = Users(client);
try {
final response = await users.create(email: ‘[email protected]’,password: ‘password’, name: ‘name’);
print(response.data);
} on AppwriteException catch(e) {
//show message to user or do other operation based on error as required
print(e.message);
}
```

### Learn more
You can use followng resources to learn more and get help
- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-server)
Expand Down
24 changes: 24 additions & 0 deletions docs/examples/account/create-recovery.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import 'package:dart_appwrite/dart_appwrite.dart';

void main() { // Init SDK
Client client = Client();
Account account = Account(client);

client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token
;

Future result = account.createRecovery(
email: '[email protected]',
url: 'https://example.com',
);

result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
23 changes: 23 additions & 0 deletions docs/examples/account/create-verification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'package:dart_appwrite/dart_appwrite.dart';

void main() { // Init SDK
Client client = Client();
Account account = Account(client);

client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token
;

Future result = account.createVerification(
url: 'https://example.com',
);

result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
23 changes: 23 additions & 0 deletions docs/examples/account/delete-session.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'package:dart_appwrite/dart_appwrite.dart';

void main() { // Init SDK
Client client = Client();
Account account = Account(client);

client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token
;

Future result = account.deleteSession(
sessionId: '[SESSION_ID]',
);

result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
21 changes: 21 additions & 0 deletions docs/examples/account/delete-sessions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'package:dart_appwrite/dart_appwrite.dart';

void main() { // Init SDK
Client client = Client();
Account account = Account(client);

client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token
;

Future result = account.deleteSessions();

result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
21 changes: 21 additions & 0 deletions docs/examples/account/delete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'package:dart_appwrite/dart_appwrite.dart';

void main() { // Init SDK
Client client = Client();
Account account = Account(client);

client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token
;

Future result = account.delete();

result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
21 changes: 21 additions & 0 deletions docs/examples/account/get-logs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'package:dart_appwrite/dart_appwrite.dart';

void main() { // Init SDK
Client client = Client();
Account account = Account(client);

client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token
;

Future result = account.getLogs();

result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
21 changes: 21 additions & 0 deletions docs/examples/account/get-prefs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'package:dart_appwrite/dart_appwrite.dart';

void main() { // Init SDK
Client client = Client();
Account account = Account(client);

client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token
;

Future result = account.getPrefs();

result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
21 changes: 21 additions & 0 deletions docs/examples/account/get-sessions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'package:dart_appwrite/dart_appwrite.dart';

void main() { // Init SDK
Client client = Client();
Account account = Account(client);

client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token
;

Future result = account.getSessions();

result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
21 changes: 21 additions & 0 deletions docs/examples/account/get.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'package:dart_appwrite/dart_appwrite.dart';

void main() { // Init SDK
Client client = Client();
Account account = Account(client);

client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token
;

Future result = account.get();

result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
24 changes: 24 additions & 0 deletions docs/examples/account/update-email.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import 'package:dart_appwrite/dart_appwrite.dart';

void main() { // Init SDK
Client client = Client();
Account account = Account(client);

client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token
;

Future result = account.updateEmail(
email: '[email protected]',
password: 'password',
);

result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
23 changes: 23 additions & 0 deletions docs/examples/account/update-name.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'package:dart_appwrite/dart_appwrite.dart';

void main() { // Init SDK
Client client = Client();
Account account = Account(client);

client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token
;

Future result = account.updateName(
name: '[NAME]',
);

result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
23 changes: 23 additions & 0 deletions docs/examples/account/update-password.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'package:dart_appwrite/dart_appwrite.dart';

void main() { // Init SDK
Client client = Client();
Account account = Account(client);

client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token
;

Future result = account.updatePassword(
password: 'password',
);

result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
23 changes: 23 additions & 0 deletions docs/examples/account/update-prefs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'package:dart_appwrite/dart_appwrite.dart';

void main() { // Init SDK
Client client = Client();
Account account = Account(client);

client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token
;

Future result = account.updatePrefs(
prefs: {},
);

result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
Loading

0 comments on commit d8303f7

Please sign in to comment.