Skip to content
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Analyze and test

on: pull_request

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dart-lang/setup-dart@v1
- name: Install dependencies
run: dart pub get
- name: Analyze
run: dart analyze --no-fatal-warnings
- name: Test
run: dart test
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# Change Log

## 17.0.0

* Support for Appwrite 1.8
* Added TablesDB service
* Added new query types:
* `notContains`
* `notSearch`
* `notBetween`
* `notStartsWith`
* `notEndsWith`
* `createdBefore`
* `createdAfter`
* `updatedBefore`
* `updatedAfter`
* Deprecated `updateMagicURLSession`
* Deprecated `updatePhoneSession`
* Deprecated Databases service
> The TablesDB service is the new recommended way to work with databases.
> Existing databases/collections/attributes/documents can be managed using the TablesDB service.
> Existing Databases service will continue to work, but new features may only be added to the TablesDB service.


## 16.2.0

* Add `incrementDocumentAttribute` and `decrementDocumentAttribute` support to `Databases` service
Expand Down
45 changes: 18 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

[![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-1.7.x-blue.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.8.x-blue.svg?style=flat-square)
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)

**This SDK is compatible with Appwrite server version 1.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 1.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 @@ -23,7 +23,7 @@ Add this to your package's `pubspec.yaml` file:

```yml
dependencies:
dart_appwrite: ^16.2.0
dart_appwrite: ^17.0.0
```

You can install packages from the command line:
Expand All @@ -39,38 +39,29 @@ dart pub add dart_appwrite
Once you add the dependencies, its extremely easy to get started with the SDK; All you need to do is import the package in your code, set your Appwrite credentials, and start making API calls. Below is a simple example:

```dart
import 'package:dart_appwrite/dart_appwrite.dart';

void main() async {
Client client = Client()
.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);

try {
final user = await users.create(userId: ID.unique(), email: "[email protected]", phone: "+123456789", password: "password", name: "Walter O'Brien");
print(user.toMap());
} on AppwriteException catch(e) {
print(e.message);
}
}
Client client = Client()
.setProject('<YOUR_PROJECT_ID>')
.setKey('<YOUR_API_KEY>');

Users users = Users(client);

User user = await users.create(
userId: ID.unique(),
email: '[email protected]',
phone: '+123456789',
password: 'password',
name: 'Walter O'Brien'
);
```

### 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 user = await users.create(userId: ID.unique(), email: "[email protected]", phone: "+123456789", password: "password", name: "Walter O'Brien");
print(user.toMap());
User user = await users.create(...);
} on AppwriteException catch(e) {
//show message to user or do other operation based on error as required
print(e.message);
// Handle the error
}
```

Expand Down
1 change: 1 addition & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include: package:lints/recommended.yaml
12 changes: 12 additions & 0 deletions docs/examples/account/create-m-f-a-authenticator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'package:dart_appwrite/dart_appwrite.dart';

Client client = Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setSession(''); // The user session to authenticate with

Account account = Account(client);

MfaType result = await account.createMFAAuthenticator(
type: AuthenticatorType.totp,
);
11 changes: 11 additions & 0 deletions docs/examples/account/create-m-f-a-challenge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import 'package:dart_appwrite/dart_appwrite.dart';

Client client = Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

Account account = Account(client);

MfaChallenge result = await account.createMFAChallenge(
factor: AuthenticationFactor.email,
);
10 changes: 10 additions & 0 deletions docs/examples/account/create-m-f-a-recovery-codes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import 'package:dart_appwrite/dart_appwrite.dart';

Client client = Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setSession(''); // The user session to authenticate with

Account account = Account(client);

MfaRecoveryCodes result = await account.createMFARecoveryCodes();
12 changes: 12 additions & 0 deletions docs/examples/account/delete-m-f-a-authenticator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'package:dart_appwrite/dart_appwrite.dart';

Client client = Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setSession(''); // The user session to authenticate with

Account account = Account(client);

await account.deleteMFAAuthenticator(
type: AuthenticatorType.totp,
);
10 changes: 10 additions & 0 deletions docs/examples/account/get-m-f-a-recovery-codes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import 'package:dart_appwrite/dart_appwrite.dart';

Client client = Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setSession(''); // The user session to authenticate with

Account account = Account(client);

MfaRecoveryCodes result = await account.getMFARecoveryCodes();
10 changes: 10 additions & 0 deletions docs/examples/account/list-m-f-a-factors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import 'package:dart_appwrite/dart_appwrite.dart';

Client client = Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setSession(''); // The user session to authenticate with

Account account = Account(client);

MfaFactors result = await account.listMFAFactors();
13 changes: 13 additions & 0 deletions docs/examples/account/update-m-f-a-authenticator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import 'package:dart_appwrite/dart_appwrite.dart';

Client client = Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setSession(''); // The user session to authenticate with

Account account = Account(client);

User result = await account.updateMFAAuthenticator(
type: AuthenticatorType.totp,
otp: '<OTP>',
);
13 changes: 13 additions & 0 deletions docs/examples/account/update-m-f-a-challenge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import 'package:dart_appwrite/dart_appwrite.dart';

Client client = Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setSession(''); // The user session to authenticate with

Account account = Account(client);

Session result = await account.updateMFAChallenge(
challengeId: '<CHALLENGE_ID>',
otp: '<OTP>',
);
10 changes: 10 additions & 0 deletions docs/examples/account/update-m-f-a-recovery-codes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import 'package:dart_appwrite/dart_appwrite.dart';

Client client = Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setSession(''); // The user session to authenticate with

Account account = Account(client);

MfaRecoveryCodes result = await account.updateMFARecoveryCodes();
2 changes: 1 addition & 1 deletion docs/examples/databases/decrement-document-attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
.setSession(''); // The user session to authenticate with

Databases databases = Databases(client);

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/databases/increment-document-attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:dart_appwrite/dart_appwrite.dart';
Client client = Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
.setSession(''); // The user session to authenticate with

Databases databases = Databases(client);

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/functions/create-execution.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ Execution result = await functions.createExecution(
path: '<PATH>', // (optional)
method: ExecutionMethod.gET, // (optional)
headers: {}, // (optional)
scheduledAt: '', // (optional)
scheduledAt: '<SCHEDULED_AT>', // (optional)
);
19 changes: 19 additions & 0 deletions docs/examples/messaging/create-a-p-n-s-provider.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'package:dart_appwrite/dart_appwrite.dart';

Client client = Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key

Messaging messaging = Messaging(client);

Provider result = await messaging.createAPNSProvider(
providerId: '<PROVIDER_ID>',
name: '<NAME>',
authKey: '<AUTH_KEY>', // (optional)
authKeyId: '<AUTH_KEY_ID>', // (optional)
teamId: '<TEAM_ID>', // (optional)
bundleId: '<BUNDLE_ID>', // (optional)
sandbox: false, // (optional)
enabled: false, // (optional)
);
15 changes: 15 additions & 0 deletions docs/examples/messaging/create-f-c-m-provider.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import 'package:dart_appwrite/dart_appwrite.dart';

Client client = Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key

Messaging messaging = Messaging(client);

Provider result = await messaging.createFCMProvider(
providerId: '<PROVIDER_ID>',
name: '<NAME>',
serviceAccountJSON: {}, // (optional)
enabled: false, // (optional)
);
18 changes: 18 additions & 0 deletions docs/examples/messaging/create-s-m-s.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import 'package:dart_appwrite/dart_appwrite.dart';

Client client = Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key

Messaging messaging = Messaging(client);

Message result = await messaging.createSMS(
messageId: '<MESSAGE_ID>',
content: '<CONTENT>',
topics: [], // (optional)
users: [], // (optional)
targets: [], // (optional)
draft: false, // (optional)
scheduledAt: '', // (optional)
);
25 changes: 25 additions & 0 deletions docs/examples/messaging/create-s-m-t-p-provider.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import 'package:dart_appwrite/dart_appwrite.dart';

Client client = Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key

Messaging messaging = Messaging(client);

Provider result = await messaging.createSMTPProvider(
providerId: '<PROVIDER_ID>',
name: '<NAME>',
host: '<HOST>',
port: 1, // (optional)
username: '<USERNAME>', // (optional)
password: '<PASSWORD>', // (optional)
encryption: SmtpEncryption.none, // (optional)
autoTLS: false, // (optional)
mailer: '<MAILER>', // (optional)
fromName: '<FROM_NAME>', // (optional)
fromEmail: '[email protected]', // (optional)
replyToName: '<REPLY_TO_NAME>', // (optional)
replyToEmail: '[email protected]', // (optional)
enabled: false, // (optional)
);
19 changes: 19 additions & 0 deletions docs/examples/messaging/update-a-p-n-s-provider.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'package:dart_appwrite/dart_appwrite.dart';

Client client = Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key

Messaging messaging = Messaging(client);

Provider result = await messaging.updateAPNSProvider(
providerId: '<PROVIDER_ID>',
name: '<NAME>', // (optional)
enabled: false, // (optional)
authKey: '<AUTH_KEY>', // (optional)
authKeyId: '<AUTH_KEY_ID>', // (optional)
teamId: '<TEAM_ID>', // (optional)
bundleId: '<BUNDLE_ID>', // (optional)
sandbox: false, // (optional)
);
15 changes: 15 additions & 0 deletions docs/examples/messaging/update-f-c-m-provider.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import 'package:dart_appwrite/dart_appwrite.dart';

Client client = Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key

Messaging messaging = Messaging(client);

Provider result = await messaging.updateFCMProvider(
providerId: '<PROVIDER_ID>',
name: '<NAME>', // (optional)
enabled: false, // (optional)
serviceAccountJSON: {}, // (optional)
);
18 changes: 18 additions & 0 deletions docs/examples/messaging/update-s-m-s.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import 'package:dart_appwrite/dart_appwrite.dart';

Client client = Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key

Messaging messaging = Messaging(client);

Message result = await messaging.updateSMS(
messageId: '<MESSAGE_ID>',
topics: [], // (optional)
users: [], // (optional)
targets: [], // (optional)
content: '<CONTENT>', // (optional)
draft: false, // (optional)
scheduledAt: '', // (optional)
);
Loading