-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
819 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
|
@@ -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: | ||
|
@@ -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); | ||
|
@@ -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) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
} |
Oops, something went wrong.