diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c4d97e..adc136a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## 11.0.0 + +* Added enum support +* Added SSR support +* Added messaging service support +* Added contains query support +* Added or query support + ## 10.1.0 * Add new queue health endpoints diff --git a/README.md b/README.md index 97573fc..e21a7a7 100644 --- a/README.md +++ b/README.md @@ -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.4.x-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.5.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.4.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.5.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) @@ -15,7 +15,7 @@ Appwrite is an open-source backend as a service server that abstract and simplif -![Appwrite](https://appwrite.io/images/github.png) +![Appwrite](https://github.com/appwrite/appwrite/raw/main/public/images/github.png) ## Installation @@ -23,7 +23,7 @@ Add this to your package's `pubspec.yaml` file: ```yml dependencies: - dart_appwrite: ^10.1.1 + dart_appwrite: ^11.0.0 ``` You can install packages from the command line: @@ -51,7 +51,7 @@ void main() async { Users users = Users(client); try { - final user = await users.create(userId: ID.unique(), email: ‘email@example.com’,password: ‘password’, name: ‘name’); + final user = await users.create(userId: ID.unique(), email: "email@example.com", phone: "+123456789", password: "password", name: "Walter O'Brien"); print(user.toMap()); } on AppwriteException catch(e) { print(e.message); @@ -66,7 +66,7 @@ The Appwrite Dart SDK raises `AppwriteException` object with `message`, `code` a Users users = Users(client); try { - final user = await users.create(userId: ID.unique(), email: ‘email@example.com’,password: ‘password’, name: ‘name’); + final user = await users.create(userId: ID.unique(), email: "email@example.com", phone: "+123456789", password: "password", name: "Walter O'Brien"); print(user.toMap()); } on AppwriteException catch(e) { //show message to user or do other operation based on error as required diff --git a/docs/examples/account/create-anonymous-session.md b/docs/examples/account/create-anonymous-session.md new file mode 100644 index 0000000..200b49e --- /dev/null +++ b/docs/examples/account/create-anonymous-session.md @@ -0,0 +1,9 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2'); // Your project ID + +Account account = Account(client); + +Session result = await account.createAnonymousSession(); diff --git a/docs/examples/account/create-email-password-session.md b/docs/examples/account/create-email-password-session.md new file mode 100644 index 0000000..9e07cd8 --- /dev/null +++ b/docs/examples/account/create-email-password-session.md @@ -0,0 +1,12 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2'); // Your project ID + +Account account = Account(client); + +Session result = await account.createEmailPasswordSession( + email: 'email@example.com', + password: 'password', +); diff --git a/docs/examples/account/create-email-token.md b/docs/examples/account/create-email-token.md new file mode 100644 index 0000000..70870d9 --- /dev/null +++ b/docs/examples/account/create-email-token.md @@ -0,0 +1,13 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2'); // Your project ID + +Account account = Account(client); + +Token result = await account.createEmailToken( + userId: '', + email: 'email@example.com', + phrase: false, // (optional) +); diff --git a/docs/examples/account/create-j-w-t.md b/docs/examples/account/create-j-w-t.md new file mode 100644 index 0000000..4e452ab --- /dev/null +++ b/docs/examples/account/create-j-w-t.md @@ -0,0 +1,9 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2'); // Your project ID + +Account account = Account(client); + +Jwt result = await account.createJWT(); diff --git a/docs/examples/account/create-magic-u-r-l-token.md b/docs/examples/account/create-magic-u-r-l-token.md new file mode 100644 index 0000000..ac60b0d --- /dev/null +++ b/docs/examples/account/create-magic-u-r-l-token.md @@ -0,0 +1,14 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2'); // Your project ID + +Account account = Account(client); + +Token result = await account.createMagicURLToken( + userId: '', + email: 'email@example.com', + url: 'https://example.com', // (optional) + phrase: false, // (optional) +); diff --git a/docs/examples/account/create-mfa-authenticator.md b/docs/examples/account/create-mfa-authenticator.md new file mode 100644 index 0000000..a920b47 --- /dev/null +++ b/docs/examples/account/create-mfa-authenticator.md @@ -0,0 +1,12 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setSession(''); // The user session to authenticate with + +Account account = Account(client); + +MfaType result = await account.createMfaAuthenticator( + type: AuthenticatorType.totp, +); diff --git a/docs/examples/account/create-mfa-challenge.md b/docs/examples/account/create-mfa-challenge.md new file mode 100644 index 0000000..f7e24ff --- /dev/null +++ b/docs/examples/account/create-mfa-challenge.md @@ -0,0 +1,11 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2'); // Your project ID + +Account account = Account(client); + +MfaChallenge result = await account.createMfaChallenge( + factor: AuthenticationFactor.email, +); diff --git a/docs/examples/account/create-mfa-recovery-codes.md b/docs/examples/account/create-mfa-recovery-codes.md new file mode 100644 index 0000000..d44817e --- /dev/null +++ b/docs/examples/account/create-mfa-recovery-codes.md @@ -0,0 +1,10 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setSession(''); // The user session to authenticate with + +Account account = Account(client); + +MfaRecoveryCodes result = await account.createMfaRecoveryCodes(); diff --git a/docs/examples/account/create-o-auth2token.md b/docs/examples/account/create-o-auth2token.md new file mode 100644 index 0000000..2d33ad3 --- /dev/null +++ b/docs/examples/account/create-o-auth2token.md @@ -0,0 +1,14 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2'); // Your project ID + +Account account = Account(client); + +await account.createOAuth2Token( + provider: OAuthProvider.amazon, + success: 'https://example.com', // (optional) + failure: 'https://example.com', // (optional) + scopes: [], // (optional) +); diff --git a/docs/examples/account/create-phone-token.md b/docs/examples/account/create-phone-token.md new file mode 100644 index 0000000..8653ad0 --- /dev/null +++ b/docs/examples/account/create-phone-token.md @@ -0,0 +1,12 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2'); // Your project ID + +Account account = Account(client); + +Token result = await account.createPhoneToken( + userId: '', + phone: '+12065550100', +); diff --git a/docs/examples/account/create-phone-verification.md b/docs/examples/account/create-phone-verification.md index 912f8c3..40d6f2f 100644 --- a/docs/examples/account/create-phone-verification.md +++ b/docs/examples/account/create-phone-verification.md @@ -1,21 +1,10 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Account account = Account(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token - ; + .setSession(''); // The user session to authenticate with - Future result = account.createPhoneVerification(); +Account account = Account(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Token result = await account.createPhoneVerification(); diff --git a/docs/examples/account/create-recovery.md b/docs/examples/account/create-recovery.md index d9f1395..0b0584d 100644 --- a/docs/examples/account/create-recovery.md +++ b/docs/examples/account/create-recovery.md @@ -1,24 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Account account = Account(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token - ; + .setSession(''); // The user session to authenticate with + +Account account = Account(client); - Future result = account.createRecovery( +Token result = await account.createRecovery( email: 'email@example.com', url: 'https://example.com', - ); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +); diff --git a/docs/examples/account/create-session.md b/docs/examples/account/create-session.md new file mode 100644 index 0000000..a85be64 --- /dev/null +++ b/docs/examples/account/create-session.md @@ -0,0 +1,12 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2'); // Your project ID + +Account account = Account(client); + +Session result = await account.createSession( + userId: '', + secret: '', +); diff --git a/docs/examples/account/create-verification.md b/docs/examples/account/create-verification.md index cca3c7b..4ec54dc 100644 --- a/docs/examples/account/create-verification.md +++ b/docs/examples/account/create-verification.md @@ -1,23 +1,12 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Account account = Account(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token - ; + .setSession(''); // The user session to authenticate with - Future result = account.createVerification( - url: 'https://example.com', - ); +Account account = Account(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Token result = await account.createVerification( + url: 'https://example.com', +); diff --git a/docs/examples/account/create.md b/docs/examples/account/create.md new file mode 100644 index 0000000..ac630d1 --- /dev/null +++ b/docs/examples/account/create.md @@ -0,0 +1,14 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2'); // Your project ID + +Account account = Account(client); + +User result = await account.create( + userId: '', + email: 'email@example.com', + password: '', + name: '', // (optional) +); diff --git a/docs/examples/account/delete-identity.md b/docs/examples/account/delete-identity.md index 7b8f09a..4982e13 100644 --- a/docs/examples/account/delete-identity.md +++ b/docs/examples/account/delete-identity.md @@ -1,23 +1,12 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Account account = Account(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token - ; + .setSession(''); // The user session to authenticate with - Future result = account.deleteIdentity( - identityId: '[IDENTITY_ID]', - ); +Account account = Account(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +await account.deleteIdentity( + identityId: '', +); diff --git a/docs/examples/account/delete-mfa-authenticator.md b/docs/examples/account/delete-mfa-authenticator.md new file mode 100644 index 0000000..cbeb5cd --- /dev/null +++ b/docs/examples/account/delete-mfa-authenticator.md @@ -0,0 +1,13 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setSession(''); // The user session to authenticate with + +Account account = Account(client); + +await account.deleteMfaAuthenticator( + type: AuthenticatorType.totp, + otp: '', +); diff --git a/docs/examples/account/delete-session.md b/docs/examples/account/delete-session.md index 9486ec9..eb740f1 100644 --- a/docs/examples/account/delete-session.md +++ b/docs/examples/account/delete-session.md @@ -1,23 +1,12 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Account account = Account(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token - ; + .setSession(''); // The user session to authenticate with - Future result = account.deleteSession( - sessionId: '[SESSION_ID]', - ); +Account account = Account(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +await account.deleteSession( + sessionId: '', +); diff --git a/docs/examples/account/delete-sessions.md b/docs/examples/account/delete-sessions.md index a5732cb..e42f161 100644 --- a/docs/examples/account/delete-sessions.md +++ b/docs/examples/account/delete-sessions.md @@ -1,21 +1,10 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Account account = Account(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token - ; + .setSession(''); // The user session to authenticate with - Future result = account.deleteSessions(); +Account account = Account(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +await account.deleteSessions(); diff --git a/docs/examples/account/get-mfa-recovery-codes.md b/docs/examples/account/get-mfa-recovery-codes.md new file mode 100644 index 0000000..b378ee7 --- /dev/null +++ b/docs/examples/account/get-mfa-recovery-codes.md @@ -0,0 +1,10 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setSession(''); // The user session to authenticate with + +Account account = Account(client); + +MfaRecoveryCodes result = await account.getMfaRecoveryCodes(); diff --git a/docs/examples/account/get-prefs.md b/docs/examples/account/get-prefs.md index 527a71f..4f5ad7c 100644 --- a/docs/examples/account/get-prefs.md +++ b/docs/examples/account/get-prefs.md @@ -1,21 +1,10 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Account account = Account(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token - ; + .setSession(''); // The user session to authenticate with - Future result = account.getPrefs(); +Account account = Account(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Preferences result = await account.getPrefs(); diff --git a/docs/examples/account/get-session.md b/docs/examples/account/get-session.md index 6eb711a..e2423d6 100644 --- a/docs/examples/account/get-session.md +++ b/docs/examples/account/get-session.md @@ -1,23 +1,12 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Account account = Account(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token - ; + .setSession(''); // The user session to authenticate with - Future result = account.getSession( - sessionId: '[SESSION_ID]', - ); +Account account = Account(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Session result = await account.getSession( + sessionId: '', +); diff --git a/docs/examples/account/get.md b/docs/examples/account/get.md index c72fddd..86a8074 100644 --- a/docs/examples/account/get.md +++ b/docs/examples/account/get.md @@ -1,21 +1,10 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Account account = Account(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token - ; + .setSession(''); // The user session to authenticate with - Future result = account.get(); +Account account = Account(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +User result = await account.get(); diff --git a/docs/examples/account/list-identities.md b/docs/examples/account/list-identities.md index 63789e5..bcd3671 100644 --- a/docs/examples/account/list-identities.md +++ b/docs/examples/account/list-identities.md @@ -1,22 +1,12 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Account account = Account(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token - ; + .setSession(''); // The user session to authenticate with - Future result = account.listIdentities( - ); +Account account = Account(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +IdentityList result = await account.listIdentities( + queries: [], // (optional) +); diff --git a/docs/examples/account/list-logs.md b/docs/examples/account/list-logs.md index 68d2c49..a45ddf2 100644 --- a/docs/examples/account/list-logs.md +++ b/docs/examples/account/list-logs.md @@ -1,22 +1,12 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Account account = Account(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token - ; + .setSession(''); // The user session to authenticate with - Future result = account.listLogs( - ); +Account account = Account(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +LogList result = await account.listLogs( + queries: [], // (optional) +); diff --git a/docs/examples/account/list-mfa-factors.md b/docs/examples/account/list-mfa-factors.md new file mode 100644 index 0000000..1a8a416 --- /dev/null +++ b/docs/examples/account/list-mfa-factors.md @@ -0,0 +1,10 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setSession(''); // The user session to authenticate with + +Account account = Account(client); + +MfaFactors result = await account.listMfaFactors(); diff --git a/docs/examples/account/list-sessions.md b/docs/examples/account/list-sessions.md index 0d6567b..7469ba5 100644 --- a/docs/examples/account/list-sessions.md +++ b/docs/examples/account/list-sessions.md @@ -1,21 +1,10 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Account account = Account(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token - ; + .setSession(''); // The user session to authenticate with - Future result = account.listSessions(); +Account account = Account(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +SessionList result = await account.listSessions(); diff --git a/docs/examples/account/update-email.md b/docs/examples/account/update-email.md index b83f7d8..325b764 100644 --- a/docs/examples/account/update-email.md +++ b/docs/examples/account/update-email.md @@ -1,24 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Account account = Account(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token - ; + .setSession(''); // The user session to authenticate with + +Account account = Account(client); - Future result = account.updateEmail( +User result = await account.updateEmail( email: 'email@example.com', password: 'password', - ); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +); diff --git a/docs/examples/account/update-m-f-a.md b/docs/examples/account/update-m-f-a.md new file mode 100644 index 0000000..102525e --- /dev/null +++ b/docs/examples/account/update-m-f-a.md @@ -0,0 +1,12 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setSession(''); // The user session to authenticate with + +Account account = Account(client); + +User result = await account.updateMFA( + mfa: false, +); diff --git a/docs/examples/account/update-magic-u-r-l-session.md b/docs/examples/account/update-magic-u-r-l-session.md new file mode 100644 index 0000000..535d26d --- /dev/null +++ b/docs/examples/account/update-magic-u-r-l-session.md @@ -0,0 +1,12 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2'); // Your project ID + +Account account = Account(client); + +Session result = await account.updateMagicURLSession( + userId: '', + secret: '', +); diff --git a/docs/examples/account/update-mfa-authenticator.md b/docs/examples/account/update-mfa-authenticator.md new file mode 100644 index 0000000..f7d585e --- /dev/null +++ b/docs/examples/account/update-mfa-authenticator.md @@ -0,0 +1,13 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setSession(''); // The user session to authenticate with + +Account account = Account(client); + +User result = await account.updateMfaAuthenticator( + type: AuthenticatorType.totp, + otp: '', +); diff --git a/docs/examples/account/update-mfa-challenge.md b/docs/examples/account/update-mfa-challenge.md new file mode 100644 index 0000000..024ac9d --- /dev/null +++ b/docs/examples/account/update-mfa-challenge.md @@ -0,0 +1,13 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setSession(''); // The user session to authenticate with + +Account account = Account(client); + + result = await account.updateMfaChallenge( + challengeId: '', + otp: '', +); diff --git a/docs/examples/account/update-mfa-recovery-codes.md b/docs/examples/account/update-mfa-recovery-codes.md new file mode 100644 index 0000000..7899143 --- /dev/null +++ b/docs/examples/account/update-mfa-recovery-codes.md @@ -0,0 +1,10 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setSession(''); // The user session to authenticate with + +Account account = Account(client); + +MfaRecoveryCodes result = await account.updateMfaRecoveryCodes(); diff --git a/docs/examples/account/update-name.md b/docs/examples/account/update-name.md index 0bd27cf..bf05b27 100644 --- a/docs/examples/account/update-name.md +++ b/docs/examples/account/update-name.md @@ -1,23 +1,12 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Account account = Account(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token - ; + .setSession(''); // The user session to authenticate with - Future result = account.updateName( - name: '[NAME]', - ); +Account account = Account(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +User result = await account.updateName( + name: '', +); diff --git a/docs/examples/account/update-password.md b/docs/examples/account/update-password.md index d5e27a7..92d53fa 100644 --- a/docs/examples/account/update-password.md +++ b/docs/examples/account/update-password.md @@ -1,23 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Account account = Account(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token - ; + .setSession(''); // The user session to authenticate with - Future result = account.updatePassword( - password: '', - ); +Account account = Account(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +User result = await account.updatePassword( + password: '', + oldPassword: 'password', // (optional) +); diff --git a/docs/examples/account/update-phone-session.md b/docs/examples/account/update-phone-session.md new file mode 100644 index 0000000..2586a89 --- /dev/null +++ b/docs/examples/account/update-phone-session.md @@ -0,0 +1,12 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2'); // Your project ID + +Account account = Account(client); + +Session result = await account.updatePhoneSession( + userId: '', + secret: '', +); diff --git a/docs/examples/account/update-phone-verification.md b/docs/examples/account/update-phone-verification.md index f2995b9..a778967 100644 --- a/docs/examples/account/update-phone-verification.md +++ b/docs/examples/account/update-phone-verification.md @@ -1,24 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Account account = Account(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token - ; + .setSession(''); // The user session to authenticate with - Future result = account.updatePhoneVerification( - userId: '[USER_ID]', - secret: '[SECRET]', - ); +Account account = Account(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Token result = await account.updatePhoneVerification( + userId: '', + secret: '', +); diff --git a/docs/examples/account/update-phone.md b/docs/examples/account/update-phone.md index 5848da5..9613bda 100644 --- a/docs/examples/account/update-phone.md +++ b/docs/examples/account/update-phone.md @@ -1,24 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Account account = Account(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token - ; + .setSession(''); // The user session to authenticate with + +Account account = Account(client); - Future result = account.updatePhone( +User result = await account.updatePhone( phone: '+12065550100', password: 'password', - ); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +); diff --git a/docs/examples/account/update-prefs.md b/docs/examples/account/update-prefs.md index ffbe700..1ef69ee 100644 --- a/docs/examples/account/update-prefs.md +++ b/docs/examples/account/update-prefs.md @@ -1,23 +1,12 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Account account = Account(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token - ; + .setSession(''); // The user session to authenticate with - Future result = account.updatePrefs( - prefs: {}, - ); +Account account = Account(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +User result = await account.updatePrefs( + prefs: {}, +); diff --git a/docs/examples/account/update-recovery.md b/docs/examples/account/update-recovery.md index c2cf9d2..c0923c1 100644 --- a/docs/examples/account/update-recovery.md +++ b/docs/examples/account/update-recovery.md @@ -1,26 +1,14 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Account account = Account(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token - ; + .setSession(''); // The user session to authenticate with - Future result = account.updateRecovery( - userId: '[USER_ID]', - secret: '[SECRET]', - password: 'password', - passwordAgain: 'password', - ); +Account account = Account(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Token result = await account.updateRecovery( + userId: '', + secret: '', + password: '', +); diff --git a/docs/examples/account/update-session.md b/docs/examples/account/update-session.md index 61e11e2..624b006 100644 --- a/docs/examples/account/update-session.md +++ b/docs/examples/account/update-session.md @@ -1,23 +1,12 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Account account = Account(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token - ; + .setSession(''); // The user session to authenticate with - Future result = account.updateSession( - sessionId: '[SESSION_ID]', - ); +Account account = Account(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Session result = await account.updateSession( + sessionId: '', +); diff --git a/docs/examples/account/update-status.md b/docs/examples/account/update-status.md index 12f7333..211421c 100644 --- a/docs/examples/account/update-status.md +++ b/docs/examples/account/update-status.md @@ -1,21 +1,10 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Account account = Account(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token - ; + .setSession(''); // The user session to authenticate with - Future result = account.updateStatus(); +Account account = Account(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +User result = await account.updateStatus(); diff --git a/docs/examples/account/update-verification.md b/docs/examples/account/update-verification.md index 40e3642..e0e2518 100644 --- a/docs/examples/account/update-verification.md +++ b/docs/examples/account/update-verification.md @@ -1,24 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Account account = Account(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token - ; + .setSession(''); // The user session to authenticate with - Future result = account.updateVerification( - userId: '[USER_ID]', - secret: '[SECRET]', - ); +Account account = Account(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Token result = await account.updateVerification( + userId: '', + secret: '', +); diff --git a/docs/examples/avatars/get-browser.md b/docs/examples/avatars/get-browser.md index 0bac9df..4ad79d3 100644 --- a/docs/examples/avatars/get-browser.md +++ b/docs/examples/avatars/get-browser.md @@ -1,23 +1,15 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Avatars avatars = Avatars(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = avatars.getBrowser( - code: 'aa', - ); +Avatars avatars = Avatars(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +UInt8List result = await avatars.getBrowser( + code: Browser.avantBrowser, + width: 0, // (optional) + height: 0, // (optional) + quality: 0, // (optional) +); diff --git a/docs/examples/avatars/get-credit-card.md b/docs/examples/avatars/get-credit-card.md index b9a8166..95f84b6 100644 --- a/docs/examples/avatars/get-credit-card.md +++ b/docs/examples/avatars/get-credit-card.md @@ -1,23 +1,15 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Avatars avatars = Avatars(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = avatars.getCreditCard( - code: 'amex', - ); +Avatars avatars = Avatars(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +UInt8List result = await avatars.getCreditCard( + code: CreditCard.americanExpress, + width: 0, // (optional) + height: 0, // (optional) + quality: 0, // (optional) +); diff --git a/docs/examples/avatars/get-favicon.md b/docs/examples/avatars/get-favicon.md index 6a728e7..5fc3051 100644 --- a/docs/examples/avatars/get-favicon.md +++ b/docs/examples/avatars/get-favicon.md @@ -1,23 +1,12 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Avatars avatars = Avatars(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = avatars.getFavicon( - url: 'https://example.com', - ); +Avatars avatars = Avatars(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +UInt8List result = await avatars.getFavicon( + url: 'https://example.com', +); diff --git a/docs/examples/avatars/get-flag.md b/docs/examples/avatars/get-flag.md index 02e4880..3f7a10d 100644 --- a/docs/examples/avatars/get-flag.md +++ b/docs/examples/avatars/get-flag.md @@ -1,23 +1,15 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Avatars avatars = Avatars(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = avatars.getFlag( - code: 'af', - ); +Avatars avatars = Avatars(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +UInt8List result = await avatars.getFlag( + code: Flag.afghanistan, + width: 0, // (optional) + height: 0, // (optional) + quality: 0, // (optional) +); diff --git a/docs/examples/avatars/get-image.md b/docs/examples/avatars/get-image.md index b1d5e33..f1d911e 100644 --- a/docs/examples/avatars/get-image.md +++ b/docs/examples/avatars/get-image.md @@ -1,23 +1,14 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Avatars avatars = Avatars(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = avatars.getImage( - url: 'https://example.com', - ); +Avatars avatars = Avatars(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +UInt8List result = await avatars.getImage( + url: 'https://example.com', + width: 0, // (optional) + height: 0, // (optional) +); diff --git a/docs/examples/avatars/get-initials.md b/docs/examples/avatars/get-initials.md index 5a68caf..da2849c 100644 --- a/docs/examples/avatars/get-initials.md +++ b/docs/examples/avatars/get-initials.md @@ -1,22 +1,15 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Avatars avatars = Avatars(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = avatars.getInitials( - ); +Avatars avatars = Avatars(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +UInt8List result = await avatars.getInitials( + name: '', // (optional) + width: 0, // (optional) + height: 0, // (optional) + background: '', // (optional) +); diff --git a/docs/examples/avatars/get-q-r.md b/docs/examples/avatars/get-q-r.md index 8283b9b..97d31d5 100644 --- a/docs/examples/avatars/get-q-r.md +++ b/docs/examples/avatars/get-q-r.md @@ -1,23 +1,15 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Avatars avatars = Avatars(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = avatars.getQR( - text: '[TEXT]', - ); +Avatars avatars = Avatars(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +UInt8List result = await avatars.getQR( + text: '', + size: 1, // (optional) + margin: 0, // (optional) + download: false, // (optional) +); diff --git a/docs/examples/databases/create-boolean-attribute.md b/docs/examples/databases/create-boolean-attribute.md index 2247196..4c70730 100644 --- a/docs/examples/databases/create-boolean-attribute.md +++ b/docs/examples/databases/create-boolean-attribute.md @@ -1,26 +1,17 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Databases databases = Databases(client); - Future result = databases.createBooleanAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', +AttributeBoolean result = await databases.createBooleanAttribute( + databaseId: '', + collectionId: '', key: '', xrequired: false, - ); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file + xdefault: false, // (optional) + array: false, // (optional) +); diff --git a/docs/examples/databases/create-collection.md b/docs/examples/databases/create-collection.md index c90183d..2a6d8e9 100644 --- a/docs/examples/databases/create-collection.md +++ b/docs/examples/databases/create-collection.md @@ -1,25 +1,17 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = databases.createCollection( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', - name: '[NAME]', - ); +Databases databases = Databases(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Collection result = await databases.createCollection( + databaseId: '', + collectionId: '', + name: '', + permissions: ["read("any")"], // (optional) + documentSecurity: false, // (optional) + enabled: false, // (optional) +); diff --git a/docs/examples/databases/create-datetime-attribute.md b/docs/examples/databases/create-datetime-attribute.md index 24c4408..6d44a26 100644 --- a/docs/examples/databases/create-datetime-attribute.md +++ b/docs/examples/databases/create-datetime-attribute.md @@ -1,26 +1,17 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Databases databases = Databases(client); - Future result = databases.createDatetimeAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', +AttributeDatetime result = await databases.createDatetimeAttribute( + databaseId: '', + collectionId: '', key: '', xrequired: false, - ); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file + xdefault: '', // (optional) + array: false, // (optional) +); diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index 00d844d..b9d5eb0 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -1,26 +1,16 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = databases.createDocument( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', - documentId: '[DOCUMENT_ID]', - data: {}, - ); +Databases databases = Databases(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Document result = await databases.createDocument( + databaseId: '', + collectionId: '', + documentId: '', + data: {}, + permissions: ["read("any")"], // (optional) +); diff --git a/docs/examples/databases/create-email-attribute.md b/docs/examples/databases/create-email-attribute.md index 92fd320..15bf012 100644 --- a/docs/examples/databases/create-email-attribute.md +++ b/docs/examples/databases/create-email-attribute.md @@ -1,26 +1,17 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Databases databases = Databases(client); - Future result = databases.createEmailAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', +AttributeEmail result = await databases.createEmailAttribute( + databaseId: '', + collectionId: '', key: '', xrequired: false, - ); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file + xdefault: 'email@example.com', // (optional) + array: false, // (optional) +); diff --git a/docs/examples/databases/create-enum-attribute.md b/docs/examples/databases/create-enum-attribute.md index fa8ad92..f1df262 100644 --- a/docs/examples/databases/create-enum-attribute.md +++ b/docs/examples/databases/create-enum-attribute.md @@ -1,27 +1,18 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Databases databases = Databases(client); - Future result = databases.createEnumAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', +AttributeEnum result = await databases.createEnumAttribute( + databaseId: '', + collectionId: '', key: '', elements: [], xrequired: false, - ); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file + xdefault: '', // (optional) + array: false, // (optional) +); diff --git a/docs/examples/databases/create-float-attribute.md b/docs/examples/databases/create-float-attribute.md index 96047bf..548962a 100644 --- a/docs/examples/databases/create-float-attribute.md +++ b/docs/examples/databases/create-float-attribute.md @@ -1,26 +1,19 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Databases databases = Databases(client); - Future result = databases.createFloatAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', +AttributeFloat result = await databases.createFloatAttribute( + databaseId: '', + collectionId: '', key: '', xrequired: false, - ); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file + min: 0, // (optional) + max: 0, // (optional) + xdefault: 0, // (optional) + array: false, // (optional) +); diff --git a/docs/examples/databases/create-index.md b/docs/examples/databases/create-index.md index c16a027..7c97846 100644 --- a/docs/examples/databases/create-index.md +++ b/docs/examples/databases/create-index.md @@ -1,27 +1,17 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Databases databases = Databases(client); - Future result = databases.createIndex( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', +Index result = await databases.createIndex( + databaseId: '', + collectionId: '', key: '', - type: 'key', + type: IndexType.key, attributes: [], - ); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file + orders: [], // (optional) +); diff --git a/docs/examples/databases/create-integer-attribute.md b/docs/examples/databases/create-integer-attribute.md index bc4f12f..2449950 100644 --- a/docs/examples/databases/create-integer-attribute.md +++ b/docs/examples/databases/create-integer-attribute.md @@ -1,26 +1,19 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Databases databases = Databases(client); - Future result = databases.createIntegerAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', +AttributeInteger result = await databases.createIntegerAttribute( + databaseId: '', + collectionId: '', key: '', xrequired: false, - ); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file + min: 0, // (optional) + max: 0, // (optional) + xdefault: 0, // (optional) + array: false, // (optional) +); diff --git a/docs/examples/databases/create-ip-attribute.md b/docs/examples/databases/create-ip-attribute.md index ef3e985..05aa298 100644 --- a/docs/examples/databases/create-ip-attribute.md +++ b/docs/examples/databases/create-ip-attribute.md @@ -1,26 +1,17 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Databases databases = Databases(client); - Future result = databases.createIpAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', +AttributeIp result = await databases.createIpAttribute( + databaseId: '', + collectionId: '', key: '', xrequired: false, - ); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file + xdefault: '', // (optional) + array: false, // (optional) +); diff --git a/docs/examples/databases/create-relationship-attribute.md b/docs/examples/databases/create-relationship-attribute.md index 01f2b42..f838747 100644 --- a/docs/examples/databases/create-relationship-attribute.md +++ b/docs/examples/databases/create-relationship-attribute.md @@ -1,26 +1,19 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = databases.createRelationshipAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', - relatedCollectionId: '[RELATED_COLLECTION_ID]', - type: 'oneToOne', - ); +Databases databases = Databases(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +AttributeRelationship result = await databases.createRelationshipAttribute( + databaseId: '', + collectionId: '', + relatedCollectionId: '', + type: RelationshipType.oneToOne, + twoWay: false, // (optional) + key: '', // (optional) + twoWayKey: '', // (optional) + onDelete: RelationMutate.cascade, // (optional) +); diff --git a/docs/examples/databases/create-string-attribute.md b/docs/examples/databases/create-string-attribute.md index 14f2769..d4a4754 100644 --- a/docs/examples/databases/create-string-attribute.md +++ b/docs/examples/databases/create-string-attribute.md @@ -1,27 +1,19 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Databases databases = Databases(client); - Future result = databases.createStringAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', +AttributeString result = await databases.createStringAttribute( + databaseId: '', + collectionId: '', key: '', size: 1, xrequired: false, - ); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file + xdefault: '', // (optional) + array: false, // (optional) + encrypt: false, // (optional) +); diff --git a/docs/examples/databases/create-url-attribute.md b/docs/examples/databases/create-url-attribute.md index 4cf3e99..f427bba 100644 --- a/docs/examples/databases/create-url-attribute.md +++ b/docs/examples/databases/create-url-attribute.md @@ -1,26 +1,17 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Databases databases = Databases(client); - Future result = databases.createUrlAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', +AttributeUrl result = await databases.createUrlAttribute( + databaseId: '', + collectionId: '', key: '', xrequired: false, - ); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file + xdefault: 'https://example.com', // (optional) + array: false, // (optional) +); diff --git a/docs/examples/databases/create.md b/docs/examples/databases/create.md index cbaf3b7..01cd75c 100644 --- a/docs/examples/databases/create.md +++ b/docs/examples/databases/create.md @@ -1,24 +1,14 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = databases.create( - databaseId: '[DATABASE_ID]', - name: '[NAME]', - ); +Databases databases = Databases(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Database result = await databases.create( + databaseId: '', + name: '', + enabled: false, // (optional) +); diff --git a/docs/examples/databases/delete-attribute.md b/docs/examples/databases/delete-attribute.md index e9865bf..605220c 100644 --- a/docs/examples/databases/delete-attribute.md +++ b/docs/examples/databases/delete-attribute.md @@ -1,25 +1,14 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = databases.deleteAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', - key: '', - ); +Databases databases = Databases(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +await databases.deleteAttribute( + databaseId: '', + collectionId: '', + key: '', +); diff --git a/docs/examples/databases/delete-collection.md b/docs/examples/databases/delete-collection.md index 5886920..4243c8b 100644 --- a/docs/examples/databases/delete-collection.md +++ b/docs/examples/databases/delete-collection.md @@ -1,24 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = databases.deleteCollection( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', - ); +Databases databases = Databases(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +await databases.deleteCollection( + databaseId: '', + collectionId: '', +); diff --git a/docs/examples/databases/delete-document.md b/docs/examples/databases/delete-document.md index 0d298f3..8e1b233 100644 --- a/docs/examples/databases/delete-document.md +++ b/docs/examples/databases/delete-document.md @@ -1,25 +1,14 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = databases.deleteDocument( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', - documentId: '[DOCUMENT_ID]', - ); +Databases databases = Databases(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +await databases.deleteDocument( + databaseId: '', + collectionId: '', + documentId: '', +); diff --git a/docs/examples/databases/delete-index.md b/docs/examples/databases/delete-index.md index be5b2a5..df5a195 100644 --- a/docs/examples/databases/delete-index.md +++ b/docs/examples/databases/delete-index.md @@ -1,25 +1,14 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = databases.deleteIndex( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', - key: '', - ); +Databases databases = Databases(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +await databases.deleteIndex( + databaseId: '', + collectionId: '', + key: '', +); diff --git a/docs/examples/databases/delete.md b/docs/examples/databases/delete.md index ff19bee..5325af3 100644 --- a/docs/examples/databases/delete.md +++ b/docs/examples/databases/delete.md @@ -1,23 +1,12 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = databases.delete( - databaseId: '[DATABASE_ID]', - ); +Databases databases = Databases(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +await databases.delete( + databaseId: '', +); diff --git a/docs/examples/databases/get-attribute.md b/docs/examples/databases/get-attribute.md index c27ddb6..fc6129e 100644 --- a/docs/examples/databases/get-attribute.md +++ b/docs/examples/databases/get-attribute.md @@ -1,25 +1,14 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = databases.getAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', - key: '', - ); +Databases databases = Databases(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file + result = await databases.getAttribute( + databaseId: '', + collectionId: '', + key: '', +); diff --git a/docs/examples/databases/get-collection.md b/docs/examples/databases/get-collection.md index 359f0df..606018b 100644 --- a/docs/examples/databases/get-collection.md +++ b/docs/examples/databases/get-collection.md @@ -1,24 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = databases.getCollection( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', - ); +Databases databases = Databases(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Collection result = await databases.getCollection( + databaseId: '', + collectionId: '', +); diff --git a/docs/examples/databases/get-document.md b/docs/examples/databases/get-document.md index 2141abf..17b2ca6 100644 --- a/docs/examples/databases/get-document.md +++ b/docs/examples/databases/get-document.md @@ -1,25 +1,15 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = databases.getDocument( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', - documentId: '[DOCUMENT_ID]', - ); +Databases databases = Databases(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Document result = await databases.getDocument( + databaseId: '', + collectionId: '', + documentId: '', + queries: [], // (optional) +); diff --git a/docs/examples/databases/get-index.md b/docs/examples/databases/get-index.md index 2b8a903..0dac7f5 100644 --- a/docs/examples/databases/get-index.md +++ b/docs/examples/databases/get-index.md @@ -1,25 +1,14 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = databases.getIndex( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', - key: '', - ); +Databases databases = Databases(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Index result = await databases.getIndex( + databaseId: '', + collectionId: '', + key: '', +); diff --git a/docs/examples/databases/get.md b/docs/examples/databases/get.md index f0cc118..c0878b8 100644 --- a/docs/examples/databases/get.md +++ b/docs/examples/databases/get.md @@ -1,23 +1,12 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = databases.get( - databaseId: '[DATABASE_ID]', - ); +Databases databases = Databases(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Database result = await databases.get( + databaseId: '', +); diff --git a/docs/examples/databases/list-attributes.md b/docs/examples/databases/list-attributes.md index 60ca58f..fe51fc1 100644 --- a/docs/examples/databases/list-attributes.md +++ b/docs/examples/databases/list-attributes.md @@ -1,24 +1,14 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = databases.listAttributes( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', - ); +Databases databases = Databases(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +AttributeList result = await databases.listAttributes( + databaseId: '', + collectionId: '', + queries: [], // (optional) +); diff --git a/docs/examples/databases/list-collections.md b/docs/examples/databases/list-collections.md index a10038d..de25c40 100644 --- a/docs/examples/databases/list-collections.md +++ b/docs/examples/databases/list-collections.md @@ -1,23 +1,14 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = databases.listCollections( - databaseId: '[DATABASE_ID]', - ); +Databases databases = Databases(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +CollectionList result = await databases.listCollections( + databaseId: '', + queries: [], // (optional) + search: '', // (optional) +); diff --git a/docs/examples/databases/list-documents.md b/docs/examples/databases/list-documents.md index 7029977..d3caa08 100644 --- a/docs/examples/databases/list-documents.md +++ b/docs/examples/databases/list-documents.md @@ -1,24 +1,14 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = databases.listDocuments( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', - ); +Databases databases = Databases(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +DocumentList result = await databases.listDocuments( + databaseId: '', + collectionId: '', + queries: [], // (optional) +); diff --git a/docs/examples/databases/list-indexes.md b/docs/examples/databases/list-indexes.md index 6703ebf..a5c616c 100644 --- a/docs/examples/databases/list-indexes.md +++ b/docs/examples/databases/list-indexes.md @@ -1,24 +1,14 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = databases.listIndexes( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', - ); +Databases databases = Databases(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +IndexList result = await databases.listIndexes( + databaseId: '', + collectionId: '', + queries: [], // (optional) +); diff --git a/docs/examples/databases/list.md b/docs/examples/databases/list.md index d9bd06a..23d6830 100644 --- a/docs/examples/databases/list.md +++ b/docs/examples/databases/list.md @@ -1,22 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = databases.list( - ); +Databases databases = Databases(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +DatabaseList result = await databases.list( + queries: [], // (optional) + search: '', // (optional) +); diff --git a/docs/examples/databases/update-boolean-attribute.md b/docs/examples/databases/update-boolean-attribute.md index 94853d2..fe88c9e 100644 --- a/docs/examples/databases/update-boolean-attribute.md +++ b/docs/examples/databases/update-boolean-attribute.md @@ -1,27 +1,16 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Databases databases = Databases(client); - Future result = databases.updateBooleanAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', +AttributeBoolean result = await databases.updateBooleanAttribute( + databaseId: '', + collectionId: '', key: '', xrequired: false, xdefault: false, - ); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +); diff --git a/docs/examples/databases/update-collection.md b/docs/examples/databases/update-collection.md index a5f32de..a8c95b2 100644 --- a/docs/examples/databases/update-collection.md +++ b/docs/examples/databases/update-collection.md @@ -1,25 +1,17 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = databases.updateCollection( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', - name: '[NAME]', - ); +Databases databases = Databases(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Collection result = await databases.updateCollection( + databaseId: '', + collectionId: '', + name: '', + permissions: ["read("any")"], // (optional) + documentSecurity: false, // (optional) + enabled: false, // (optional) +); diff --git a/docs/examples/databases/update-datetime-attribute.md b/docs/examples/databases/update-datetime-attribute.md index f93aa81..d4bba10 100644 --- a/docs/examples/databases/update-datetime-attribute.md +++ b/docs/examples/databases/update-datetime-attribute.md @@ -1,27 +1,16 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Databases databases = Databases(client); - Future result = databases.updateDatetimeAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', +AttributeDatetime result = await databases.updateDatetimeAttribute( + databaseId: '', + collectionId: '', key: '', xrequired: false, xdefault: '', - ); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +); diff --git a/docs/examples/databases/update-document.md b/docs/examples/databases/update-document.md index fb08413..eccc98e 100644 --- a/docs/examples/databases/update-document.md +++ b/docs/examples/databases/update-document.md @@ -1,25 +1,16 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = databases.updateDocument( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', - documentId: '[DOCUMENT_ID]', - ); +Databases databases = Databases(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Document result = await databases.updateDocument( + databaseId: '', + collectionId: '', + documentId: '', + data: {}, // (optional) + permissions: ["read("any")"], // (optional) +); diff --git a/docs/examples/databases/update-email-attribute.md b/docs/examples/databases/update-email-attribute.md index 8fd104d..a5c72c9 100644 --- a/docs/examples/databases/update-email-attribute.md +++ b/docs/examples/databases/update-email-attribute.md @@ -1,27 +1,16 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Databases databases = Databases(client); - Future result = databases.updateEmailAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', +AttributeEmail result = await databases.updateEmailAttribute( + databaseId: '', + collectionId: '', key: '', xrequired: false, xdefault: 'email@example.com', - ); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +); diff --git a/docs/examples/databases/update-enum-attribute.md b/docs/examples/databases/update-enum-attribute.md index 20c4481..a3ebfe5 100644 --- a/docs/examples/databases/update-enum-attribute.md +++ b/docs/examples/databases/update-enum-attribute.md @@ -1,28 +1,17 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Databases databases = Databases(client); - Future result = databases.updateEnumAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', +AttributeEnum result = await databases.updateEnumAttribute( + databaseId: '', + collectionId: '', key: '', elements: [], xrequired: false, - xdefault: '[DEFAULT]', - ); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file + xdefault: '', +); diff --git a/docs/examples/databases/update-float-attribute.md b/docs/examples/databases/update-float-attribute.md index 5043254..fe86fa6 100644 --- a/docs/examples/databases/update-float-attribute.md +++ b/docs/examples/databases/update-float-attribute.md @@ -1,29 +1,18 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Databases databases = Databases(client); - Future result = databases.updateFloatAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', +AttributeFloat result = await databases.updateFloatAttribute( + databaseId: '', + collectionId: '', key: '', xrequired: false, min: 0, max: 0, xdefault: 0, - ); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +); diff --git a/docs/examples/databases/update-integer-attribute.md b/docs/examples/databases/update-integer-attribute.md index 2d3da6c..49a0b18 100644 --- a/docs/examples/databases/update-integer-attribute.md +++ b/docs/examples/databases/update-integer-attribute.md @@ -1,29 +1,18 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Databases databases = Databases(client); - Future result = databases.updateIntegerAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', +AttributeInteger result = await databases.updateIntegerAttribute( + databaseId: '', + collectionId: '', key: '', xrequired: false, min: 0, max: 0, xdefault: 0, - ); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +); diff --git a/docs/examples/databases/update-ip-attribute.md b/docs/examples/databases/update-ip-attribute.md index 8c4cf4f..3549d5c 100644 --- a/docs/examples/databases/update-ip-attribute.md +++ b/docs/examples/databases/update-ip-attribute.md @@ -1,27 +1,16 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Databases databases = Databases(client); - Future result = databases.updateIpAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', +AttributeIp result = await databases.updateIpAttribute( + databaseId: '', + collectionId: '', key: '', xrequired: false, xdefault: '', - ); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +); diff --git a/docs/examples/databases/update-relationship-attribute.md b/docs/examples/databases/update-relationship-attribute.md index 239e23d..e6dea66 100644 --- a/docs/examples/databases/update-relationship-attribute.md +++ b/docs/examples/databases/update-relationship-attribute.md @@ -1,25 +1,15 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = databases.updateRelationshipAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', - key: '', - ); +Databases databases = Databases(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +AttributeRelationship result = await databases.updateRelationshipAttribute( + databaseId: '', + collectionId: '', + key: '', + onDelete: RelationMutate.cascade, // (optional) +); diff --git a/docs/examples/databases/update-string-attribute.md b/docs/examples/databases/update-string-attribute.md index 7f24507..cb2a4b6 100644 --- a/docs/examples/databases/update-string-attribute.md +++ b/docs/examples/databases/update-string-attribute.md @@ -1,27 +1,16 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Databases databases = Databases(client); - Future result = databases.updateStringAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', +AttributeString result = await databases.updateStringAttribute( + databaseId: '', + collectionId: '', key: '', xrequired: false, - xdefault: '[DEFAULT]', - ); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file + xdefault: '', +); diff --git a/docs/examples/databases/update-url-attribute.md b/docs/examples/databases/update-url-attribute.md index d7dd675..4042ed5 100644 --- a/docs/examples/databases/update-url-attribute.md +++ b/docs/examples/databases/update-url-attribute.md @@ -1,27 +1,16 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Databases databases = Databases(client); - Future result = databases.updateUrlAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', +AttributeUrl result = await databases.updateUrlAttribute( + databaseId: '', + collectionId: '', key: '', xrequired: false, xdefault: 'https://example.com', - ); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +); diff --git a/docs/examples/databases/update.md b/docs/examples/databases/update.md index 59070ce..ad8a76e 100644 --- a/docs/examples/databases/update.md +++ b/docs/examples/databases/update.md @@ -1,24 +1,14 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Databases databases = Databases(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = databases.update( - databaseId: '[DATABASE_ID]', - name: '[NAME]', - ); +Databases databases = Databases(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Database result = await databases.update( + databaseId: '', + name: '', + enabled: false, // (optional) +); diff --git a/docs/examples/functions/create-build.md b/docs/examples/functions/create-build.md index 530ba6d..a90dc7c 100644 --- a/docs/examples/functions/create-build.md +++ b/docs/examples/functions/create-build.md @@ -1,25 +1,14 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Functions functions = Functions(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = functions.createBuild( - functionId: '[FUNCTION_ID]', - deploymentId: '[DEPLOYMENT_ID]', - buildId: '[BUILD_ID]', - ); +Functions functions = Functions(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file + result = await functions.createBuild( + functionId: '', + deploymentId: '', + buildId: '', +); diff --git a/docs/examples/functions/create-deployment.md b/docs/examples/functions/create-deployment.md index 8be0f1a..dd32c60 100644 --- a/docs/examples/functions/create-deployment.md +++ b/docs/examples/functions/create-deployment.md @@ -1,25 +1,16 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Functions functions = Functions(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Functions functions = Functions(client); - Future result = functions.createDeployment( - functionId: '[FUNCTION_ID]', +Deployment result = await functions.createDeployment( + functionId: '', code: InputFile(path: './path-to-files/image.jpg', filename: 'image.jpg'), activate: false, - ); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file + entrypoint: '', // (optional) + commands: '', // (optional) +); diff --git a/docs/examples/functions/create-execution.md b/docs/examples/functions/create-execution.md index f5de49f..8d3eb74 100644 --- a/docs/examples/functions/create-execution.md +++ b/docs/examples/functions/create-execution.md @@ -1,23 +1,17 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Functions functions = Functions(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = functions.createExecution( - functionId: '[FUNCTION_ID]', - ); +Functions functions = Functions(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Execution result = await functions.createExecution( + functionId: '', + body: '', // (optional) + xasync: false, // (optional) + path: '', // (optional) + method: ExecutionMethod.gET, // (optional) + headers: {}, // (optional) +); diff --git a/docs/examples/functions/create-variable.md b/docs/examples/functions/create-variable.md index 50cd063..7b4f062 100644 --- a/docs/examples/functions/create-variable.md +++ b/docs/examples/functions/create-variable.md @@ -1,25 +1,14 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Functions functions = Functions(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = functions.createVariable( - functionId: '[FUNCTION_ID]', - key: '[KEY]', - value: '[VALUE]', - ); +Functions functions = Functions(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Variable result = await functions.createVariable( + functionId: '', + key: '', + value: '', +); diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index 73d84fc..18e2d3e 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -1,25 +1,31 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Functions functions = Functions(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = functions.create( - functionId: '[FUNCTION_ID]', - name: '[NAME]', - runtime: 'node-18.0', - ); +Functions functions = Functions(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Func result = await functions.create( + functionId: '', + name: '', + runtime: .node145, + execute: ["any"], // (optional) + events: [], // (optional) + schedule: '', // (optional) + timeout: 1, // (optional) + enabled: false, // (optional) + logging: false, // (optional) + entrypoint: '', // (optional) + commands: '', // (optional) + installationId: '', // (optional) + providerRepositoryId: '', // (optional) + providerBranch: '', // (optional) + providerSilentMode: false, // (optional) + providerRootDirectory: '', // (optional) + templateRepository: '', // (optional) + templateOwner: '', // (optional) + templateRootDirectory: '', // (optional) + templateBranch: '', // (optional) +); diff --git a/docs/examples/functions/delete-deployment.md b/docs/examples/functions/delete-deployment.md index e65380c..a50d9e4 100644 --- a/docs/examples/functions/delete-deployment.md +++ b/docs/examples/functions/delete-deployment.md @@ -1,24 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Functions functions = Functions(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = functions.deleteDeployment( - functionId: '[FUNCTION_ID]', - deploymentId: '[DEPLOYMENT_ID]', - ); +Functions functions = Functions(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +await functions.deleteDeployment( + functionId: '', + deploymentId: '', +); diff --git a/docs/examples/functions/delete-variable.md b/docs/examples/functions/delete-variable.md index 87c7f40..d677576 100644 --- a/docs/examples/functions/delete-variable.md +++ b/docs/examples/functions/delete-variable.md @@ -1,24 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Functions functions = Functions(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = functions.deleteVariable( - functionId: '[FUNCTION_ID]', - variableId: '[VARIABLE_ID]', - ); +Functions functions = Functions(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +await functions.deleteVariable( + functionId: '', + variableId: '', +); diff --git a/docs/examples/functions/delete.md b/docs/examples/functions/delete.md index 5163366..bca7d18 100644 --- a/docs/examples/functions/delete.md +++ b/docs/examples/functions/delete.md @@ -1,23 +1,12 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Functions functions = Functions(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = functions.delete( - functionId: '[FUNCTION_ID]', - ); +Functions functions = Functions(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +await functions.delete( + functionId: '', +); diff --git a/docs/examples/functions/download-deployment.md b/docs/examples/functions/download-deployment.md index d77d3aa..40e39a2 100644 --- a/docs/examples/functions/download-deployment.md +++ b/docs/examples/functions/download-deployment.md @@ -1,24 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Functions functions = Functions(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = functions.downloadDeployment( - functionId: '[FUNCTION_ID]', - deploymentId: '[DEPLOYMENT_ID]', - ); +Functions functions = Functions(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +UInt8List result = await functions.downloadDeployment( + functionId: '', + deploymentId: '', +); diff --git a/docs/examples/functions/get-deployment.md b/docs/examples/functions/get-deployment.md index 9cab571..007e848 100644 --- a/docs/examples/functions/get-deployment.md +++ b/docs/examples/functions/get-deployment.md @@ -1,24 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Functions functions = Functions(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = functions.getDeployment( - functionId: '[FUNCTION_ID]', - deploymentId: '[DEPLOYMENT_ID]', - ); +Functions functions = Functions(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Deployment result = await functions.getDeployment( + functionId: '', + deploymentId: '', +); diff --git a/docs/examples/functions/get-execution.md b/docs/examples/functions/get-execution.md index 6cadde6..856b92b 100644 --- a/docs/examples/functions/get-execution.md +++ b/docs/examples/functions/get-execution.md @@ -1,24 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Functions functions = Functions(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = functions.getExecution( - functionId: '[FUNCTION_ID]', - executionId: '[EXECUTION_ID]', - ); +Functions functions = Functions(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Execution result = await functions.getExecution( + functionId: '', + executionId: '', +); diff --git a/docs/examples/functions/get-variable.md b/docs/examples/functions/get-variable.md index 924bee2..2328572 100644 --- a/docs/examples/functions/get-variable.md +++ b/docs/examples/functions/get-variable.md @@ -1,24 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Functions functions = Functions(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = functions.getVariable( - functionId: '[FUNCTION_ID]', - variableId: '[VARIABLE_ID]', - ); +Functions functions = Functions(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Variable result = await functions.getVariable( + functionId: '', + variableId: '', +); diff --git a/docs/examples/functions/get.md b/docs/examples/functions/get.md index 503ab20..b6d8c4c 100644 --- a/docs/examples/functions/get.md +++ b/docs/examples/functions/get.md @@ -1,23 +1,12 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Functions functions = Functions(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = functions.get( - functionId: '[FUNCTION_ID]', - ); +Functions functions = Functions(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Func result = await functions.get( + functionId: '', +); diff --git a/docs/examples/functions/list-deployments.md b/docs/examples/functions/list-deployments.md index b12f9eb..c9fbc11 100644 --- a/docs/examples/functions/list-deployments.md +++ b/docs/examples/functions/list-deployments.md @@ -1,23 +1,14 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Functions functions = Functions(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = functions.listDeployments( - functionId: '[FUNCTION_ID]', - ); +Functions functions = Functions(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +DeploymentList result = await functions.listDeployments( + functionId: '', + queries: [], // (optional) + search: '', // (optional) +); diff --git a/docs/examples/functions/list-executions.md b/docs/examples/functions/list-executions.md index 3d66a44..3b0af60 100644 --- a/docs/examples/functions/list-executions.md +++ b/docs/examples/functions/list-executions.md @@ -1,23 +1,14 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Functions functions = Functions(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = functions.listExecutions( - functionId: '[FUNCTION_ID]', - ); +Functions functions = Functions(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +ExecutionList result = await functions.listExecutions( + functionId: '', + queries: [], // (optional) + search: '', // (optional) +); diff --git a/docs/examples/functions/list-runtimes.md b/docs/examples/functions/list-runtimes.md index 091a111..199ccce 100644 --- a/docs/examples/functions/list-runtimes.md +++ b/docs/examples/functions/list-runtimes.md @@ -1,21 +1,10 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Functions functions = Functions(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = functions.listRuntimes(); +Functions functions = Functions(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +RuntimeList result = await functions.listRuntimes(); diff --git a/docs/examples/functions/list-variables.md b/docs/examples/functions/list-variables.md index f3c6655..4c8396b 100644 --- a/docs/examples/functions/list-variables.md +++ b/docs/examples/functions/list-variables.md @@ -1,23 +1,12 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Functions functions = Functions(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = functions.listVariables( - functionId: '[FUNCTION_ID]', - ); +Functions functions = Functions(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +VariableList result = await functions.listVariables( + functionId: '', +); diff --git a/docs/examples/functions/list.md b/docs/examples/functions/list.md index 4f2b114..d44b40a 100644 --- a/docs/examples/functions/list.md +++ b/docs/examples/functions/list.md @@ -1,22 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Functions functions = Functions(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = functions.list( - ); +Functions functions = Functions(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +FunctionList result = await functions.list( + queries: [], // (optional) + search: '', // (optional) +); diff --git a/docs/examples/functions/update-deployment.md b/docs/examples/functions/update-deployment.md index d503aec..78d5061 100644 --- a/docs/examples/functions/update-deployment.md +++ b/docs/examples/functions/update-deployment.md @@ -1,24 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Functions functions = Functions(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = functions.updateDeployment( - functionId: '[FUNCTION_ID]', - deploymentId: '[DEPLOYMENT_ID]', - ); +Functions functions = Functions(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Func result = await functions.updateDeployment( + functionId: '', + deploymentId: '', +); diff --git a/docs/examples/functions/update-variable.md b/docs/examples/functions/update-variable.md index 126d264..d534be3 100644 --- a/docs/examples/functions/update-variable.md +++ b/docs/examples/functions/update-variable.md @@ -1,25 +1,15 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Functions functions = Functions(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = functions.updateVariable( - functionId: '[FUNCTION_ID]', - variableId: '[VARIABLE_ID]', - key: '[KEY]', - ); +Functions functions = Functions(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Variable result = await functions.updateVariable( + functionId: '', + variableId: '', + key: '', + value: '', // (optional) +); diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index 2b92f55..bc069a0 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -1,24 +1,27 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Functions functions = Functions(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = functions.update( - functionId: '[FUNCTION_ID]', - name: '[NAME]', - ); +Functions functions = Functions(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Func result = await functions.update( + functionId: '', + name: '', + runtime: .node145, // (optional) + execute: ["any"], // (optional) + events: [], // (optional) + schedule: '', // (optional) + timeout: 1, // (optional) + enabled: false, // (optional) + logging: false, // (optional) + entrypoint: '', // (optional) + commands: '', // (optional) + installationId: '', // (optional) + providerRepositoryId: '', // (optional) + providerBranch: '', // (optional) + providerSilentMode: false, // (optional) + providerRootDirectory: '', // (optional) +); diff --git a/docs/examples/graphql/mutation.md b/docs/examples/graphql/mutation.md index 780ee09..75ba4cb 100644 --- a/docs/examples/graphql/mutation.md +++ b/docs/examples/graphql/mutation.md @@ -1,23 +1,12 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Graphql graphql = Graphql(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = graphql.mutation( - query: {}, - ); +Graphql graphql = Graphql(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Any result = await graphql.mutation( + query: {}, +); diff --git a/docs/examples/graphql/query.md b/docs/examples/graphql/query.md index 7f22f53..b69a6da 100644 --- a/docs/examples/graphql/query.md +++ b/docs/examples/graphql/query.md @@ -1,23 +1,12 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Graphql graphql = Graphql(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = graphql.query( - query: {}, - ); +Graphql graphql = Graphql(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Any result = await graphql.query( + query: {}, +); diff --git a/docs/examples/health/get-antivirus.md b/docs/examples/health/get-antivirus.md index 922dcfa..2c68b24 100644 --- a/docs/examples/health/get-antivirus.md +++ b/docs/examples/health/get-antivirus.md @@ -1,21 +1,10 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Health health = Health(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = health.getAntivirus(); +Health health = Health(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +HealthAntivirus result = await health.getAntivirus(); diff --git a/docs/examples/health/get-cache.md b/docs/examples/health/get-cache.md index 4b63ede..b379ce5 100644 --- a/docs/examples/health/get-cache.md +++ b/docs/examples/health/get-cache.md @@ -1,21 +1,10 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Health health = Health(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = health.getCache(); +Health health = Health(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +HealthStatus result = await health.getCache(); diff --git a/docs/examples/health/get-certificate.md b/docs/examples/health/get-certificate.md new file mode 100644 index 0000000..bd5c94e --- /dev/null +++ b/docs/examples/health/get-certificate.md @@ -0,0 +1,12 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Health health = Health(client); + +HealthCertificate result = await health.getCertificate( + domain: '', // (optional) +); diff --git a/docs/examples/health/get-d-b.md b/docs/examples/health/get-d-b.md index 65188c0..3363a24 100644 --- a/docs/examples/health/get-d-b.md +++ b/docs/examples/health/get-d-b.md @@ -1,21 +1,10 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Health health = Health(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = health.getDB(); +Health health = Health(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +HealthStatus result = await health.getDB(); diff --git a/docs/examples/health/get-failed-jobs.md b/docs/examples/health/get-failed-jobs.md new file mode 100644 index 0000000..5e241f0 --- /dev/null +++ b/docs/examples/health/get-failed-jobs.md @@ -0,0 +1,13 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Health health = Health(client); + +HealthQueue result = await health.getFailedJobs( + name: .v1Database, + threshold: 0, // (optional) +); diff --git a/docs/examples/health/get-pub-sub.md b/docs/examples/health/get-pub-sub.md index ef20bed..c683c97 100644 --- a/docs/examples/health/get-pub-sub.md +++ b/docs/examples/health/get-pub-sub.md @@ -1,21 +1,10 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Health health = Health(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = health.getPubSub(); +Health health = Health(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +HealthStatus result = await health.getPubSub(); diff --git a/docs/examples/health/get-queue-builds.md b/docs/examples/health/get-queue-builds.md index 9a21d45..ba71783 100644 --- a/docs/examples/health/get-queue-builds.md +++ b/docs/examples/health/get-queue-builds.md @@ -1,22 +1,12 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Health health = Health(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = health.getQueueBuilds( - ); +Health health = Health(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +HealthQueue result = await health.getQueueBuilds( + threshold: 0, // (optional) +); diff --git a/docs/examples/health/get-queue-certificates.md b/docs/examples/health/get-queue-certificates.md index e70f772..1f2f44e 100644 --- a/docs/examples/health/get-queue-certificates.md +++ b/docs/examples/health/get-queue-certificates.md @@ -1,22 +1,12 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Health health = Health(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = health.getQueueCertificates( - ); +Health health = Health(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +HealthQueue result = await health.getQueueCertificates( + threshold: 0, // (optional) +); diff --git a/docs/examples/health/get-queue-databases.md b/docs/examples/health/get-queue-databases.md index a1540fb..d10f47c 100644 --- a/docs/examples/health/get-queue-databases.md +++ b/docs/examples/health/get-queue-databases.md @@ -1,22 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Health health = Health(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = health.getQueueDatabases( - ); +Health health = Health(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +HealthQueue result = await health.getQueueDatabases( + name: '', // (optional) + threshold: 0, // (optional) +); diff --git a/docs/examples/health/get-queue-deletes.md b/docs/examples/health/get-queue-deletes.md index bdcb85c..340e107 100644 --- a/docs/examples/health/get-queue-deletes.md +++ b/docs/examples/health/get-queue-deletes.md @@ -1,22 +1,12 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Health health = Health(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = health.getQueueDeletes( - ); +Health health = Health(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +HealthQueue result = await health.getQueueDeletes( + threshold: 0, // (optional) +); diff --git a/docs/examples/health/get-queue-functions.md b/docs/examples/health/get-queue-functions.md index 4121cb5..73e7d14 100644 --- a/docs/examples/health/get-queue-functions.md +++ b/docs/examples/health/get-queue-functions.md @@ -1,22 +1,12 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Health health = Health(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = health.getQueueFunctions( - ); +Health health = Health(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +HealthQueue result = await health.getQueueFunctions( + threshold: 0, // (optional) +); diff --git a/docs/examples/health/get-queue-logs.md b/docs/examples/health/get-queue-logs.md index 310a1a3..f901273 100644 --- a/docs/examples/health/get-queue-logs.md +++ b/docs/examples/health/get-queue-logs.md @@ -1,22 +1,12 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Health health = Health(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = health.getQueueLogs( - ); +Health health = Health(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +HealthQueue result = await health.getQueueLogs( + threshold: 0, // (optional) +); diff --git a/docs/examples/health/get-queue-mails.md b/docs/examples/health/get-queue-mails.md index fcd67bb..a0f1429 100644 --- a/docs/examples/health/get-queue-mails.md +++ b/docs/examples/health/get-queue-mails.md @@ -1,22 +1,12 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Health health = Health(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = health.getQueueMails( - ); +Health health = Health(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +HealthQueue result = await health.getQueueMails( + threshold: 0, // (optional) +); diff --git a/docs/examples/health/get-queue-messaging.md b/docs/examples/health/get-queue-messaging.md index 30b5c8e..d4e09f9 100644 --- a/docs/examples/health/get-queue-messaging.md +++ b/docs/examples/health/get-queue-messaging.md @@ -1,22 +1,12 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Health health = Health(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = health.getQueueMessaging( - ); +Health health = Health(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +HealthQueue result = await health.getQueueMessaging( + threshold: 0, // (optional) +); diff --git a/docs/examples/health/get-queue-migrations.md b/docs/examples/health/get-queue-migrations.md index 375989c..42d8aa1 100644 --- a/docs/examples/health/get-queue-migrations.md +++ b/docs/examples/health/get-queue-migrations.md @@ -1,22 +1,12 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Health health = Health(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = health.getQueueMigrations( - ); +Health health = Health(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +HealthQueue result = await health.getQueueMigrations( + threshold: 0, // (optional) +); diff --git a/docs/examples/health/get-queue-usage-dump.md b/docs/examples/health/get-queue-usage-dump.md new file mode 100644 index 0000000..7b8d61e --- /dev/null +++ b/docs/examples/health/get-queue-usage-dump.md @@ -0,0 +1,12 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Health health = Health(client); + +HealthQueue result = await health.getQueueUsageDump( + threshold: 0, // (optional) +); diff --git a/docs/examples/health/get-queue-usage.md b/docs/examples/health/get-queue-usage.md new file mode 100644 index 0000000..2d08bb7 --- /dev/null +++ b/docs/examples/health/get-queue-usage.md @@ -0,0 +1,12 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Health health = Health(client); + +HealthQueue result = await health.getQueueUsage( + threshold: 0, // (optional) +); diff --git a/docs/examples/health/get-queue-webhooks.md b/docs/examples/health/get-queue-webhooks.md index ffb7acd..d1d4c3e 100644 --- a/docs/examples/health/get-queue-webhooks.md +++ b/docs/examples/health/get-queue-webhooks.md @@ -1,22 +1,12 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Health health = Health(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = health.getQueueWebhooks( - ); +Health health = Health(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +HealthQueue result = await health.getQueueWebhooks( + threshold: 0, // (optional) +); diff --git a/docs/examples/health/get-queue.md b/docs/examples/health/get-queue.md index 8b7c823..87f72f4 100644 --- a/docs/examples/health/get-queue.md +++ b/docs/examples/health/get-queue.md @@ -1,21 +1,10 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Health health = Health(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = health.getQueue(); +Health health = Health(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +HealthStatus result = await health.getQueue(); diff --git a/docs/examples/health/get-storage-local.md b/docs/examples/health/get-storage-local.md index 4a58669..22232c0 100644 --- a/docs/examples/health/get-storage-local.md +++ b/docs/examples/health/get-storage-local.md @@ -1,21 +1,10 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Health health = Health(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = health.getStorageLocal(); +Health health = Health(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +HealthStatus result = await health.getStorageLocal(); diff --git a/docs/examples/health/get-storage.md b/docs/examples/health/get-storage.md new file mode 100644 index 0000000..f02b535 --- /dev/null +++ b/docs/examples/health/get-storage.md @@ -0,0 +1,10 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Health health = Health(client); + +HealthStatus result = await health.getStorage(); diff --git a/docs/examples/health/get-time.md b/docs/examples/health/get-time.md index d8166dd..51f865c 100644 --- a/docs/examples/health/get-time.md +++ b/docs/examples/health/get-time.md @@ -1,21 +1,10 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Health health = Health(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = health.getTime(); +Health health = Health(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +HealthTime result = await health.getTime(); diff --git a/docs/examples/health/get.md b/docs/examples/health/get.md index 1be37e5..ebabd7f 100644 --- a/docs/examples/health/get.md +++ b/docs/examples/health/get.md @@ -1,21 +1,10 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Health health = Health(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = health.get(); +Health health = Health(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +HealthStatus result = await health.get(); diff --git a/docs/examples/locale/get.md b/docs/examples/locale/get.md index 9ecb18c..12dd074 100644 --- a/docs/examples/locale/get.md +++ b/docs/examples/locale/get.md @@ -1,21 +1,10 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Locale locale = Locale(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = locale.get(); +Locale locale = Locale(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Locale result = await locale.get(); diff --git a/docs/examples/locale/list-codes.md b/docs/examples/locale/list-codes.md index abc4528..40a62a9 100644 --- a/docs/examples/locale/list-codes.md +++ b/docs/examples/locale/list-codes.md @@ -1,21 +1,10 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Locale locale = Locale(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = locale.listCodes(); +Locale locale = Locale(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +LocaleCodeList result = await locale.listCodes(); diff --git a/docs/examples/locale/list-continents.md b/docs/examples/locale/list-continents.md index e684930..5adf67a 100644 --- a/docs/examples/locale/list-continents.md +++ b/docs/examples/locale/list-continents.md @@ -1,21 +1,10 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Locale locale = Locale(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = locale.listContinents(); +Locale locale = Locale(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +ContinentList result = await locale.listContinents(); diff --git a/docs/examples/locale/list-countries-e-u.md b/docs/examples/locale/list-countries-e-u.md index 2d1ddcf..14890ae 100644 --- a/docs/examples/locale/list-countries-e-u.md +++ b/docs/examples/locale/list-countries-e-u.md @@ -1,21 +1,10 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Locale locale = Locale(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = locale.listCountriesEU(); +Locale locale = Locale(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +CountryList result = await locale.listCountriesEU(); diff --git a/docs/examples/locale/list-countries-phones.md b/docs/examples/locale/list-countries-phones.md index 2305701..a476459 100644 --- a/docs/examples/locale/list-countries-phones.md +++ b/docs/examples/locale/list-countries-phones.md @@ -1,21 +1,10 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Locale locale = Locale(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = locale.listCountriesPhones(); +Locale locale = Locale(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +PhoneList result = await locale.listCountriesPhones(); diff --git a/docs/examples/locale/list-countries.md b/docs/examples/locale/list-countries.md index ef11583..5cc508b 100644 --- a/docs/examples/locale/list-countries.md +++ b/docs/examples/locale/list-countries.md @@ -1,21 +1,10 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Locale locale = Locale(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = locale.listCountries(); +Locale locale = Locale(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +CountryList result = await locale.listCountries(); diff --git a/docs/examples/locale/list-currencies.md b/docs/examples/locale/list-currencies.md index 0810f3d..afb4cf4 100644 --- a/docs/examples/locale/list-currencies.md +++ b/docs/examples/locale/list-currencies.md @@ -1,21 +1,10 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Locale locale = Locale(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = locale.listCurrencies(); +Locale locale = Locale(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +CurrencyList result = await locale.listCurrencies(); diff --git a/docs/examples/locale/list-languages.md b/docs/examples/locale/list-languages.md index f3d642c..2a83e2d 100644 --- a/docs/examples/locale/list-languages.md +++ b/docs/examples/locale/list-languages.md @@ -1,21 +1,10 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Locale locale = Locale(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = locale.listLanguages(); +Locale locale = Locale(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +LanguageList result = await locale.listLanguages(); diff --git a/docs/examples/messaging/create-apns-provider.md b/docs/examples/messaging/create-apns-provider.md new file mode 100644 index 0000000..fa6b867 --- /dev/null +++ b/docs/examples/messaging/create-apns-provider.md @@ -0,0 +1,19 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +Provider result = await messaging.createApnsProvider( + providerId: '', + name: '', + authKey: '', // (optional) + authKeyId: '', // (optional) + teamId: '', // (optional) + bundleId: '', // (optional) + sandbox: false, // (optional) + enabled: false, // (optional) +); diff --git a/docs/examples/messaging/create-email.md b/docs/examples/messaging/create-email.md new file mode 100644 index 0000000..56b542e --- /dev/null +++ b/docs/examples/messaging/create-email.md @@ -0,0 +1,23 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +Message result = await messaging.createEmail( + messageId: '', + subject: '', + content: '', + topics: [], // (optional) + users: [], // (optional) + targets: [], // (optional) + cc: [], // (optional) + bcc: [], // (optional) + attachments: [], // (optional) + draft: false, // (optional) + html: false, // (optional) + scheduledAt: '', // (optional) +); diff --git a/docs/examples/messaging/create-fcm-provider.md b/docs/examples/messaging/create-fcm-provider.md new file mode 100644 index 0000000..2f14a3d --- /dev/null +++ b/docs/examples/messaging/create-fcm-provider.md @@ -0,0 +1,15 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +Provider result = await messaging.createFcmProvider( + providerId: '', + name: '', + serviceAccountJSON: {}, // (optional) + enabled: false, // (optional) +); diff --git a/docs/examples/messaging/create-mailgun-provider.md b/docs/examples/messaging/create-mailgun-provider.md new file mode 100644 index 0000000..c418712 --- /dev/null +++ b/docs/examples/messaging/create-mailgun-provider.md @@ -0,0 +1,21 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +Provider result = await messaging.createMailgunProvider( + providerId: '', + name: '', + apiKey: '', // (optional) + domain: '', // (optional) + isEuRegion: false, // (optional) + fromName: '', // (optional) + fromEmail: 'email@example.com', // (optional) + replyToName: '', // (optional) + replyToEmail: 'email@example.com', // (optional) + enabled: false, // (optional) +); diff --git a/docs/examples/messaging/create-msg91provider.md b/docs/examples/messaging/create-msg91provider.md new file mode 100644 index 0000000..95c508f --- /dev/null +++ b/docs/examples/messaging/create-msg91provider.md @@ -0,0 +1,17 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +Provider result = await messaging.createMsg91Provider( + providerId: '', + name: '', + from: '+12065550100', // (optional) + senderId: '', // (optional) + authKey: '', // (optional) + enabled: false, // (optional) +); diff --git a/docs/examples/messaging/create-push.md b/docs/examples/messaging/create-push.md new file mode 100644 index 0000000..0249485 --- /dev/null +++ b/docs/examples/messaging/create-push.md @@ -0,0 +1,27 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +Message result = await messaging.createPush( + messageId: '', + title: '', + body: '<BODY>', + topics: [], // (optional) + users: [], // (optional) + targets: [], // (optional) + data: {}, // (optional) + action: '<ACTION>', // (optional) + image: '[ID1:ID2]', // (optional) + icon: '<ICON>', // (optional) + sound: '<SOUND>', // (optional) + color: '<COLOR>', // (optional) + tag: '<TAG>', // (optional) + badge: '<BADGE>', // (optional) + draft: false, // (optional) + scheduledAt: '', // (optional) +); diff --git a/docs/examples/messaging/create-sendgrid-provider.md b/docs/examples/messaging/create-sendgrid-provider.md new file mode 100644 index 0000000..7194fd6 --- /dev/null +++ b/docs/examples/messaging/create-sendgrid-provider.md @@ -0,0 +1,19 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +Provider result = await messaging.createSendgridProvider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', + apiKey: '<API_KEY>', // (optional) + fromName: '<FROM_NAME>', // (optional) + fromEmail: 'email@example.com', // (optional) + replyToName: '<REPLY_TO_NAME>', // (optional) + replyToEmail: 'email@example.com', // (optional) + enabled: false, // (optional) +); diff --git a/docs/examples/messaging/create-sms.md b/docs/examples/messaging/create-sms.md new file mode 100644 index 0000000..ed67261 --- /dev/null +++ b/docs/examples/messaging/create-sms.md @@ -0,0 +1,18 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // 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) +); diff --git a/docs/examples/messaging/create-smtp-provider.md b/docs/examples/messaging/create-smtp-provider.md new file mode 100644 index 0000000..7eb8f90 --- /dev/null +++ b/docs/examples/messaging/create-smtp-provider.md @@ -0,0 +1,25 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // 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@example.com', // (optional) + replyToName: '<REPLY_TO_NAME>', // (optional) + replyToEmail: 'email@example.com', // (optional) + enabled: false, // (optional) +); diff --git a/docs/examples/messaging/create-subscriber.md b/docs/examples/messaging/create-subscriber.md new file mode 100644 index 0000000..d7e3138 --- /dev/null +++ b/docs/examples/messaging/create-subscriber.md @@ -0,0 +1,14 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...'); // Your secret JSON Web Token + +Messaging messaging = Messaging(client); + +Subscriber result = await messaging.createSubscriber( + topicId: '<TOPIC_ID>', + subscriberId: '<SUBSCRIBER_ID>', + targetId: '<TARGET_ID>', +); diff --git a/docs/examples/messaging/create-telesign-provider.md b/docs/examples/messaging/create-telesign-provider.md new file mode 100644 index 0000000..b5c475c --- /dev/null +++ b/docs/examples/messaging/create-telesign-provider.md @@ -0,0 +1,17 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +Provider result = await messaging.createTelesignProvider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', + from: '+12065550100', // (optional) + customerId: '<CUSTOMER_ID>', // (optional) + apiKey: '<API_KEY>', // (optional) + enabled: false, // (optional) +); diff --git a/docs/examples/messaging/create-textmagic-provider.md b/docs/examples/messaging/create-textmagic-provider.md new file mode 100644 index 0000000..5b40a6a --- /dev/null +++ b/docs/examples/messaging/create-textmagic-provider.md @@ -0,0 +1,17 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +Provider result = await messaging.createTextmagicProvider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', + from: '+12065550100', // (optional) + username: '<USERNAME>', // (optional) + apiKey: '<API_KEY>', // (optional) + enabled: false, // (optional) +); diff --git a/docs/examples/messaging/create-topic.md b/docs/examples/messaging/create-topic.md new file mode 100644 index 0000000..f735285 --- /dev/null +++ b/docs/examples/messaging/create-topic.md @@ -0,0 +1,14 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +Topic result = await messaging.createTopic( + topicId: '<TOPIC_ID>', + name: '<NAME>', + subscribe: ["any"], // (optional) +); diff --git a/docs/examples/messaging/create-twilio-provider.md b/docs/examples/messaging/create-twilio-provider.md new file mode 100644 index 0000000..050e06a --- /dev/null +++ b/docs/examples/messaging/create-twilio-provider.md @@ -0,0 +1,17 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +Provider result = await messaging.createTwilioProvider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', + from: '+12065550100', // (optional) + accountSid: '<ACCOUNT_SID>', // (optional) + authToken: '<AUTH_TOKEN>', // (optional) + enabled: false, // (optional) +); diff --git a/docs/examples/messaging/create-vonage-provider.md b/docs/examples/messaging/create-vonage-provider.md new file mode 100644 index 0000000..31e3e82 --- /dev/null +++ b/docs/examples/messaging/create-vonage-provider.md @@ -0,0 +1,17 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +Provider result = await messaging.createVonageProvider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', + from: '+12065550100', // (optional) + apiKey: '<API_KEY>', // (optional) + apiSecret: '<API_SECRET>', // (optional) + enabled: false, // (optional) +); diff --git a/docs/examples/messaging/delete-provider.md b/docs/examples/messaging/delete-provider.md new file mode 100644 index 0000000..1761eb8 --- /dev/null +++ b/docs/examples/messaging/delete-provider.md @@ -0,0 +1,12 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +await messaging.deleteProvider( + providerId: '<PROVIDER_ID>', +); diff --git a/docs/examples/messaging/delete-subscriber.md b/docs/examples/messaging/delete-subscriber.md new file mode 100644 index 0000000..7a098dd --- /dev/null +++ b/docs/examples/messaging/delete-subscriber.md @@ -0,0 +1,13 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...'); // Your secret JSON Web Token + +Messaging messaging = Messaging(client); + +await messaging.deleteSubscriber( + topicId: '<TOPIC_ID>', + subscriberId: '<SUBSCRIBER_ID>', +); diff --git a/docs/examples/messaging/delete-topic.md b/docs/examples/messaging/delete-topic.md new file mode 100644 index 0000000..7455d50 --- /dev/null +++ b/docs/examples/messaging/delete-topic.md @@ -0,0 +1,12 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +await messaging.deleteTopic( + topicId: '<TOPIC_ID>', +); diff --git a/docs/examples/messaging/delete.md b/docs/examples/messaging/delete.md new file mode 100644 index 0000000..549c5eb --- /dev/null +++ b/docs/examples/messaging/delete.md @@ -0,0 +1,12 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +await messaging.delete( + messageId: '<MESSAGE_ID>', +); diff --git a/docs/examples/messaging/get-message.md b/docs/examples/messaging/get-message.md new file mode 100644 index 0000000..a89f803 --- /dev/null +++ b/docs/examples/messaging/get-message.md @@ -0,0 +1,12 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +Message result = await messaging.getMessage( + messageId: '<MESSAGE_ID>', +); diff --git a/docs/examples/messaging/get-provider.md b/docs/examples/messaging/get-provider.md new file mode 100644 index 0000000..3b1f233 --- /dev/null +++ b/docs/examples/messaging/get-provider.md @@ -0,0 +1,12 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +Provider result = await messaging.getProvider( + providerId: '<PROVIDER_ID>', +); diff --git a/docs/examples/messaging/get-subscriber.md b/docs/examples/messaging/get-subscriber.md new file mode 100644 index 0000000..33caa76 --- /dev/null +++ b/docs/examples/messaging/get-subscriber.md @@ -0,0 +1,13 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +Subscriber result = await messaging.getSubscriber( + topicId: '<TOPIC_ID>', + subscriberId: '<SUBSCRIBER_ID>', +); diff --git a/docs/examples/messaging/get-topic.md b/docs/examples/messaging/get-topic.md new file mode 100644 index 0000000..d90aea0 --- /dev/null +++ b/docs/examples/messaging/get-topic.md @@ -0,0 +1,12 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +Topic result = await messaging.getTopic( + topicId: '<TOPIC_ID>', +); diff --git a/docs/examples/messaging/list-message-logs.md b/docs/examples/messaging/list-message-logs.md new file mode 100644 index 0000000..c3f6a27 --- /dev/null +++ b/docs/examples/messaging/list-message-logs.md @@ -0,0 +1,13 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +LogList result = await messaging.listMessageLogs( + messageId: '<MESSAGE_ID>', + queries: [], // (optional) +); diff --git a/docs/examples/messaging/list-messages.md b/docs/examples/messaging/list-messages.md new file mode 100644 index 0000000..6532f0f --- /dev/null +++ b/docs/examples/messaging/list-messages.md @@ -0,0 +1,13 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +MessageList result = await messaging.listMessages( + queries: [], // (optional) + search: '<SEARCH>', // (optional) +); diff --git a/docs/examples/messaging/list-provider-logs.md b/docs/examples/messaging/list-provider-logs.md new file mode 100644 index 0000000..a21afd4 --- /dev/null +++ b/docs/examples/messaging/list-provider-logs.md @@ -0,0 +1,13 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +LogList result = await messaging.listProviderLogs( + providerId: '<PROVIDER_ID>', + queries: [], // (optional) +); diff --git a/docs/examples/messaging/list-providers.md b/docs/examples/messaging/list-providers.md new file mode 100644 index 0000000..072cb32 --- /dev/null +++ b/docs/examples/messaging/list-providers.md @@ -0,0 +1,13 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +ProviderList result = await messaging.listProviders( + queries: [], // (optional) + search: '<SEARCH>', // (optional) +); diff --git a/docs/examples/messaging/list-subscriber-logs.md b/docs/examples/messaging/list-subscriber-logs.md new file mode 100644 index 0000000..993b093 --- /dev/null +++ b/docs/examples/messaging/list-subscriber-logs.md @@ -0,0 +1,13 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +LogList result = await messaging.listSubscriberLogs( + subscriberId: '<SUBSCRIBER_ID>', + queries: [], // (optional) +); diff --git a/docs/examples/messaging/list-subscribers.md b/docs/examples/messaging/list-subscribers.md new file mode 100644 index 0000000..87a2e79 --- /dev/null +++ b/docs/examples/messaging/list-subscribers.md @@ -0,0 +1,14 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +SubscriberList result = await messaging.listSubscribers( + topicId: '<TOPIC_ID>', + queries: [], // (optional) + search: '<SEARCH>', // (optional) +); diff --git a/docs/examples/messaging/list-targets.md b/docs/examples/messaging/list-targets.md new file mode 100644 index 0000000..e3e9582 --- /dev/null +++ b/docs/examples/messaging/list-targets.md @@ -0,0 +1,13 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +TargetList result = await messaging.listTargets( + messageId: '<MESSAGE_ID>', + queries: [], // (optional) +); diff --git a/docs/examples/messaging/list-topic-logs.md b/docs/examples/messaging/list-topic-logs.md new file mode 100644 index 0000000..232d6ec --- /dev/null +++ b/docs/examples/messaging/list-topic-logs.md @@ -0,0 +1,13 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +LogList result = await messaging.listTopicLogs( + topicId: '<TOPIC_ID>', + queries: [], // (optional) +); diff --git a/docs/examples/messaging/list-topics.md b/docs/examples/messaging/list-topics.md new file mode 100644 index 0000000..5389374 --- /dev/null +++ b/docs/examples/messaging/list-topics.md @@ -0,0 +1,13 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +TopicList result = await messaging.listTopics( + queries: [], // (optional) + search: '<SEARCH>', // (optional) +); diff --git a/docs/examples/messaging/update-apns-provider.md b/docs/examples/messaging/update-apns-provider.md new file mode 100644 index 0000000..9c13397 --- /dev/null +++ b/docs/examples/messaging/update-apns-provider.md @@ -0,0 +1,19 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // 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) +); diff --git a/docs/examples/messaging/update-email.md b/docs/examples/messaging/update-email.md new file mode 100644 index 0000000..c4c6173 --- /dev/null +++ b/docs/examples/messaging/update-email.md @@ -0,0 +1,22 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +Message result = await messaging.updateEmail( + messageId: '<MESSAGE_ID>', + topics: [], // (optional) + users: [], // (optional) + targets: [], // (optional) + subject: '<SUBJECT>', // (optional) + content: '<CONTENT>', // (optional) + draft: false, // (optional) + html: false, // (optional) + cc: [], // (optional) + bcc: [], // (optional) + scheduledAt: '', // (optional) +); diff --git a/docs/examples/messaging/update-fcm-provider.md b/docs/examples/messaging/update-fcm-provider.md new file mode 100644 index 0000000..ec2ff34 --- /dev/null +++ b/docs/examples/messaging/update-fcm-provider.md @@ -0,0 +1,15 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +Provider result = await messaging.updateFcmProvider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', // (optional) + enabled: false, // (optional) + serviceAccountJSON: {}, // (optional) +); diff --git a/docs/examples/messaging/update-mailgun-provider.md b/docs/examples/messaging/update-mailgun-provider.md new file mode 100644 index 0000000..ddf4ef4 --- /dev/null +++ b/docs/examples/messaging/update-mailgun-provider.md @@ -0,0 +1,21 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +Provider result = await messaging.updateMailgunProvider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', // (optional) + apiKey: '<API_KEY>', // (optional) + domain: '<DOMAIN>', // (optional) + isEuRegion: false, // (optional) + enabled: false, // (optional) + fromName: '<FROM_NAME>', // (optional) + fromEmail: 'email@example.com', // (optional) + replyToName: '<REPLY_TO_NAME>', // (optional) + replyToEmail: '<REPLY_TO_EMAIL>', // (optional) +); diff --git a/docs/examples/messaging/update-msg91provider.md b/docs/examples/messaging/update-msg91provider.md new file mode 100644 index 0000000..6966b15 --- /dev/null +++ b/docs/examples/messaging/update-msg91provider.md @@ -0,0 +1,17 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +Provider result = await messaging.updateMsg91Provider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', // (optional) + enabled: false, // (optional) + senderId: '<SENDER_ID>', // (optional) + authKey: '<AUTH_KEY>', // (optional) + from: '<FROM>', // (optional) +); diff --git a/docs/examples/messaging/update-push.md b/docs/examples/messaging/update-push.md new file mode 100644 index 0000000..7b01b5c --- /dev/null +++ b/docs/examples/messaging/update-push.md @@ -0,0 +1,27 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +Message result = await messaging.updatePush( + messageId: '<MESSAGE_ID>', + topics: [], // (optional) + users: [], // (optional) + targets: [], // (optional) + title: '<TITLE>', // (optional) + body: '<BODY>', // (optional) + data: {}, // (optional) + action: '<ACTION>', // (optional) + image: '[ID1:ID2]', // (optional) + icon: '<ICON>', // (optional) + sound: '<SOUND>', // (optional) + color: '<COLOR>', // (optional) + tag: '<TAG>', // (optional) + badge: 0, // (optional) + draft: false, // (optional) + scheduledAt: '', // (optional) +); diff --git a/docs/examples/messaging/update-sendgrid-provider.md b/docs/examples/messaging/update-sendgrid-provider.md new file mode 100644 index 0000000..f23d036 --- /dev/null +++ b/docs/examples/messaging/update-sendgrid-provider.md @@ -0,0 +1,19 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +Provider result = await messaging.updateSendgridProvider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', // (optional) + enabled: false, // (optional) + apiKey: '<API_KEY>', // (optional) + fromName: '<FROM_NAME>', // (optional) + fromEmail: 'email@example.com', // (optional) + replyToName: '<REPLY_TO_NAME>', // (optional) + replyToEmail: '<REPLY_TO_EMAIL>', // (optional) +); diff --git a/docs/examples/messaging/update-sms.md b/docs/examples/messaging/update-sms.md new file mode 100644 index 0000000..054da06 --- /dev/null +++ b/docs/examples/messaging/update-sms.md @@ -0,0 +1,18 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // 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) +); diff --git a/docs/examples/messaging/update-smtp-provider.md b/docs/examples/messaging/update-smtp-provider.md new file mode 100644 index 0000000..5d3fff9 --- /dev/null +++ b/docs/examples/messaging/update-smtp-provider.md @@ -0,0 +1,25 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +Provider result = await messaging.updateSmtpProvider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', // (optional) + host: '<HOST>', // (optional) + 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@example.com', // (optional) + replyToName: '<REPLY_TO_NAME>', // (optional) + replyToEmail: '<REPLY_TO_EMAIL>', // (optional) + enabled: false, // (optional) +); diff --git a/docs/examples/messaging/update-telesign-provider.md b/docs/examples/messaging/update-telesign-provider.md new file mode 100644 index 0000000..d347df2 --- /dev/null +++ b/docs/examples/messaging/update-telesign-provider.md @@ -0,0 +1,17 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +Provider result = await messaging.updateTelesignProvider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', // (optional) + enabled: false, // (optional) + customerId: '<CUSTOMER_ID>', // (optional) + apiKey: '<API_KEY>', // (optional) + from: '<FROM>', // (optional) +); diff --git a/docs/examples/messaging/update-textmagic-provider.md b/docs/examples/messaging/update-textmagic-provider.md new file mode 100644 index 0000000..ef0be21 --- /dev/null +++ b/docs/examples/messaging/update-textmagic-provider.md @@ -0,0 +1,17 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +Provider result = await messaging.updateTextmagicProvider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', // (optional) + enabled: false, // (optional) + username: '<USERNAME>', // (optional) + apiKey: '<API_KEY>', // (optional) + from: '<FROM>', // (optional) +); diff --git a/docs/examples/messaging/update-topic.md b/docs/examples/messaging/update-topic.md new file mode 100644 index 0000000..29bda3d --- /dev/null +++ b/docs/examples/messaging/update-topic.md @@ -0,0 +1,14 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +Topic result = await messaging.updateTopic( + topicId: '<TOPIC_ID>', + name: '<NAME>', // (optional) + subscribe: ["any"], // (optional) +); diff --git a/docs/examples/messaging/update-twilio-provider.md b/docs/examples/messaging/update-twilio-provider.md new file mode 100644 index 0000000..7eb7cbf --- /dev/null +++ b/docs/examples/messaging/update-twilio-provider.md @@ -0,0 +1,17 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +Provider result = await messaging.updateTwilioProvider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', // (optional) + enabled: false, // (optional) + accountSid: '<ACCOUNT_SID>', // (optional) + authToken: '<AUTH_TOKEN>', // (optional) + from: '<FROM>', // (optional) +); diff --git a/docs/examples/messaging/update-vonage-provider.md b/docs/examples/messaging/update-vonage-provider.md new file mode 100644 index 0000000..9965229 --- /dev/null +++ b/docs/examples/messaging/update-vonage-provider.md @@ -0,0 +1,17 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Messaging messaging = Messaging(client); + +Provider result = await messaging.updateVonageProvider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', // (optional) + enabled: false, // (optional) + apiKey: '<API_KEY>', // (optional) + apiSecret: '<API_SECRET>', // (optional) + from: '<FROM>', // (optional) +); diff --git a/docs/examples/storage/create-bucket.md b/docs/examples/storage/create-bucket.md index 745a6b5..4cdc5b5 100644 --- a/docs/examples/storage/create-bucket.md +++ b/docs/examples/storage/create-bucket.md @@ -1,24 +1,21 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Storage storage = Storage(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = storage.createBucket( - bucketId: '[BUCKET_ID]', - name: '[NAME]', - ); +Storage storage = Storage(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Bucket result = await storage.createBucket( + bucketId: '<BUCKET_ID>', + name: '<NAME>', + permissions: ["read("any")"], // (optional) + fileSecurity: false, // (optional) + enabled: false, // (optional) + maximumFileSize: 1, // (optional) + allowedFileExtensions: [], // (optional) + compression: .none, // (optional) + encryption: false, // (optional) + antivirus: false, // (optional) +); diff --git a/docs/examples/storage/create-file.md b/docs/examples/storage/create-file.md index ab4c661..fb46c84 100644 --- a/docs/examples/storage/create-file.md +++ b/docs/examples/storage/create-file.md @@ -1,26 +1,16 @@ import 'dart:io'; import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Storage storage = Storage(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = storage.createFile( - bucketId: '[BUCKET_ID]', - fileId: '[FILE_ID]', - file: InputFile(path: './path-to-files/image.jpg', filename: 'image.jpg'), - ); +Storage storage = Storage(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +File result = await storage.createFile( + bucketId: '<BUCKET_ID>', + fileId: '<FILE_ID>', + file: InputFile(path: './path-to-files/image.jpg', filename: 'image.jpg'), + permissions: ["read("any")"], // (optional) +); diff --git a/docs/examples/storage/delete-bucket.md b/docs/examples/storage/delete-bucket.md index de51656..28b8a5f 100644 --- a/docs/examples/storage/delete-bucket.md +++ b/docs/examples/storage/delete-bucket.md @@ -1,23 +1,12 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Storage storage = Storage(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = storage.deleteBucket( - bucketId: '[BUCKET_ID]', - ); +Storage storage = Storage(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +await storage.deleteBucket( + bucketId: '<BUCKET_ID>', +); diff --git a/docs/examples/storage/delete-file.md b/docs/examples/storage/delete-file.md index 8e4460b..b50ebce 100644 --- a/docs/examples/storage/delete-file.md +++ b/docs/examples/storage/delete-file.md @@ -1,24 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Storage storage = Storage(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = storage.deleteFile( - bucketId: '[BUCKET_ID]', - fileId: '[FILE_ID]', - ); +Storage storage = Storage(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +await storage.deleteFile( + bucketId: '<BUCKET_ID>', + fileId: '<FILE_ID>', +); diff --git a/docs/examples/storage/get-bucket.md b/docs/examples/storage/get-bucket.md index 9e39076..b425a9f 100644 --- a/docs/examples/storage/get-bucket.md +++ b/docs/examples/storage/get-bucket.md @@ -1,23 +1,12 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Storage storage = Storage(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = storage.getBucket( - bucketId: '[BUCKET_ID]', - ); +Storage storage = Storage(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Bucket result = await storage.getBucket( + bucketId: '<BUCKET_ID>', +); diff --git a/docs/examples/storage/get-file-download.md b/docs/examples/storage/get-file-download.md index 6534fe3..0661263 100644 --- a/docs/examples/storage/get-file-download.md +++ b/docs/examples/storage/get-file-download.md @@ -1,24 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Storage storage = Storage(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = storage.getFileDownload( - bucketId: '[BUCKET_ID]', - fileId: '[FILE_ID]', - ); +Storage storage = Storage(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +UInt8List result = await storage.getFileDownload( + bucketId: '<BUCKET_ID>', + fileId: '<FILE_ID>', +); diff --git a/docs/examples/storage/get-file-preview.md b/docs/examples/storage/get-file-preview.md index ca16d63..70a2332 100644 --- a/docs/examples/storage/get-file-preview.md +++ b/docs/examples/storage/get-file-preview.md @@ -1,24 +1,24 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Storage storage = Storage(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = storage.getFilePreview( - bucketId: '[BUCKET_ID]', - fileId: '[FILE_ID]', - ); +Storage storage = Storage(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +UInt8List result = await storage.getFilePreview( + bucketId: '<BUCKET_ID>', + fileId: '<FILE_ID>', + width: 0, // (optional) + height: 0, // (optional) + gravity: ImageGravity.center, // (optional) + quality: 0, // (optional) + borderWidth: 0, // (optional) + borderColor: '', // (optional) + borderRadius: 0, // (optional) + opacity: 0, // (optional) + rotation: -360, // (optional) + background: '', // (optional) + output: ImageFormat.jpg, // (optional) +); diff --git a/docs/examples/storage/get-file-view.md b/docs/examples/storage/get-file-view.md index 5c3d69d..fa14710 100644 --- a/docs/examples/storage/get-file-view.md +++ b/docs/examples/storage/get-file-view.md @@ -1,24 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Storage storage = Storage(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = storage.getFileView( - bucketId: '[BUCKET_ID]', - fileId: '[FILE_ID]', - ); +Storage storage = Storage(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +UInt8List result = await storage.getFileView( + bucketId: '<BUCKET_ID>', + fileId: '<FILE_ID>', +); diff --git a/docs/examples/storage/get-file.md b/docs/examples/storage/get-file.md index bc45c3f..c5ca618 100644 --- a/docs/examples/storage/get-file.md +++ b/docs/examples/storage/get-file.md @@ -1,24 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Storage storage = Storage(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = storage.getFile( - bucketId: '[BUCKET_ID]', - fileId: '[FILE_ID]', - ); +Storage storage = Storage(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +File result = await storage.getFile( + bucketId: '<BUCKET_ID>', + fileId: '<FILE_ID>', +); diff --git a/docs/examples/storage/list-buckets.md b/docs/examples/storage/list-buckets.md index 6a35feb..d5e26a2 100644 --- a/docs/examples/storage/list-buckets.md +++ b/docs/examples/storage/list-buckets.md @@ -1,22 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Storage storage = Storage(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = storage.listBuckets( - ); +Storage storage = Storage(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +BucketList result = await storage.listBuckets( + queries: [], // (optional) + search: '<SEARCH>', // (optional) +); diff --git a/docs/examples/storage/list-files.md b/docs/examples/storage/list-files.md index 40b8d3b..45555f2 100644 --- a/docs/examples/storage/list-files.md +++ b/docs/examples/storage/list-files.md @@ -1,23 +1,14 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Storage storage = Storage(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = storage.listFiles( - bucketId: '[BUCKET_ID]', - ); +Storage storage = Storage(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +FileList result = await storage.listFiles( + bucketId: '<BUCKET_ID>', + queries: [], // (optional) + search: '<SEARCH>', // (optional) +); diff --git a/docs/examples/storage/update-bucket.md b/docs/examples/storage/update-bucket.md index 064d2f2..2021576 100644 --- a/docs/examples/storage/update-bucket.md +++ b/docs/examples/storage/update-bucket.md @@ -1,24 +1,21 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Storage storage = Storage(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = storage.updateBucket( - bucketId: '[BUCKET_ID]', - name: '[NAME]', - ); +Storage storage = Storage(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Bucket result = await storage.updateBucket( + bucketId: '<BUCKET_ID>', + name: '<NAME>', + permissions: ["read("any")"], // (optional) + fileSecurity: false, // (optional) + enabled: false, // (optional) + maximumFileSize: 1, // (optional) + allowedFileExtensions: [], // (optional) + compression: .none, // (optional) + encryption: false, // (optional) + antivirus: false, // (optional) +); diff --git a/docs/examples/storage/update-file.md b/docs/examples/storage/update-file.md index 2fa999a..5801bfd 100644 --- a/docs/examples/storage/update-file.md +++ b/docs/examples/storage/update-file.md @@ -1,24 +1,15 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Storage storage = Storage(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = storage.updateFile( - bucketId: '[BUCKET_ID]', - fileId: '[FILE_ID]', - ); +Storage storage = Storage(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +File result = await storage.updateFile( + bucketId: '<BUCKET_ID>', + fileId: '<FILE_ID>', + name: '<NAME>', // (optional) + permissions: ["read("any")"], // (optional) +); diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index cc86118..679a9c0 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -1,24 +1,18 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Teams teams = Teams(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = teams.createMembership( - teamId: '[TEAM_ID]', - roles: [], - ); +Teams teams = Teams(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Membership result = await teams.createMembership( + teamId: '<TEAM_ID>', + roles: [], + email: 'email@example.com', // (optional) + userId: '<USER_ID>', // (optional) + phone: '+12065550100', // (optional) + url: 'https://example.com', // (optional) + name: '<NAME>', // (optional) +); diff --git a/docs/examples/teams/create.md b/docs/examples/teams/create.md index 74895b2..1606dfb 100644 --- a/docs/examples/teams/create.md +++ b/docs/examples/teams/create.md @@ -1,24 +1,14 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Teams teams = Teams(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = teams.create( - teamId: '[TEAM_ID]', - name: '[NAME]', - ); +Teams teams = Teams(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Team result = await teams.create( + teamId: '<TEAM_ID>', + name: '<NAME>', + roles: [], // (optional) +); diff --git a/docs/examples/teams/delete-membership.md b/docs/examples/teams/delete-membership.md index 8c13599..f439610 100644 --- a/docs/examples/teams/delete-membership.md +++ b/docs/examples/teams/delete-membership.md @@ -1,24 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Teams teams = Teams(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = teams.deleteMembership( - teamId: '[TEAM_ID]', - membershipId: '[MEMBERSHIP_ID]', - ); +Teams teams = Teams(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +await teams.deleteMembership( + teamId: '<TEAM_ID>', + membershipId: '<MEMBERSHIP_ID>', +); diff --git a/docs/examples/teams/delete.md b/docs/examples/teams/delete.md index a5fee4d..c41fbd9 100644 --- a/docs/examples/teams/delete.md +++ b/docs/examples/teams/delete.md @@ -1,23 +1,12 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Teams teams = Teams(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = teams.delete( - teamId: '[TEAM_ID]', - ); +Teams teams = Teams(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +await teams.delete( + teamId: '<TEAM_ID>', +); diff --git a/docs/examples/teams/get-membership.md b/docs/examples/teams/get-membership.md index 4193b24..5b8b51f 100644 --- a/docs/examples/teams/get-membership.md +++ b/docs/examples/teams/get-membership.md @@ -1,24 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Teams teams = Teams(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = teams.getMembership( - teamId: '[TEAM_ID]', - membershipId: '[MEMBERSHIP_ID]', - ); +Teams teams = Teams(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Membership result = await teams.getMembership( + teamId: '<TEAM_ID>', + membershipId: '<MEMBERSHIP_ID>', +); diff --git a/docs/examples/teams/get-prefs.md b/docs/examples/teams/get-prefs.md index 27f2ef1..4038c09 100644 --- a/docs/examples/teams/get-prefs.md +++ b/docs/examples/teams/get-prefs.md @@ -1,23 +1,12 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Teams teams = Teams(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token - ; + .setSession(''); // The user session to authenticate with - Future result = teams.getPrefs( - teamId: '[TEAM_ID]', - ); +Teams teams = Teams(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Preferences result = await teams.getPrefs( + teamId: '<TEAM_ID>', +); diff --git a/docs/examples/teams/get.md b/docs/examples/teams/get.md index daa67c4..677c708 100644 --- a/docs/examples/teams/get.md +++ b/docs/examples/teams/get.md @@ -1,23 +1,12 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Teams teams = Teams(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = teams.get( - teamId: '[TEAM_ID]', - ); +Teams teams = Teams(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Team result = await teams.get( + teamId: '<TEAM_ID>', +); diff --git a/docs/examples/teams/list-memberships.md b/docs/examples/teams/list-memberships.md index 74c66c0..6c1da3f 100644 --- a/docs/examples/teams/list-memberships.md +++ b/docs/examples/teams/list-memberships.md @@ -1,23 +1,14 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Teams teams = Teams(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = teams.listMemberships( - teamId: '[TEAM_ID]', - ); +Teams teams = Teams(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +MembershipList result = await teams.listMemberships( + teamId: '<TEAM_ID>', + queries: [], // (optional) + search: '<SEARCH>', // (optional) +); diff --git a/docs/examples/teams/list.md b/docs/examples/teams/list.md index 11033f3..09a4548 100644 --- a/docs/examples/teams/list.md +++ b/docs/examples/teams/list.md @@ -1,22 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Teams teams = Teams(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = teams.list( - ); +Teams teams = Teams(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +TeamList result = await teams.list( + queries: [], // (optional) + search: '<SEARCH>', // (optional) +); diff --git a/docs/examples/teams/update-membership-status.md b/docs/examples/teams/update-membership-status.md index ca704e0..befb753 100644 --- a/docs/examples/teams/update-membership-status.md +++ b/docs/examples/teams/update-membership-status.md @@ -1,26 +1,15 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Teams teams = Teams(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token - ; + .setSession(''); // The user session to authenticate with - Future result = teams.updateMembershipStatus( - teamId: '[TEAM_ID]', - membershipId: '[MEMBERSHIP_ID]', - userId: '[USER_ID]', - secret: '[SECRET]', - ); +Teams teams = Teams(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Membership result = await teams.updateMembershipStatus( + teamId: '<TEAM_ID>', + membershipId: '<MEMBERSHIP_ID>', + userId: '<USER_ID>', + secret: '<SECRET>', +); diff --git a/docs/examples/teams/update-membership.md b/docs/examples/teams/update-membership.md index 85b126c..5e97688 100644 --- a/docs/examples/teams/update-membership.md +++ b/docs/examples/teams/update-membership.md @@ -1,25 +1,14 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Teams teams = Teams(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = teams.updateMembership( - teamId: '[TEAM_ID]', - membershipId: '[MEMBERSHIP_ID]', - roles: [], - ); +Teams teams = Teams(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Membership result = await teams.updateMembership( + teamId: '<TEAM_ID>', + membershipId: '<MEMBERSHIP_ID>', + roles: [], +); diff --git a/docs/examples/teams/update-name.md b/docs/examples/teams/update-name.md index 088a5cf..93e2e3c 100644 --- a/docs/examples/teams/update-name.md +++ b/docs/examples/teams/update-name.md @@ -1,24 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Teams teams = Teams(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setSession(''); // The user session to authenticate with - Future result = teams.updateName( - teamId: '[TEAM_ID]', - name: '[NAME]', - ); +Teams teams = Teams(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Team result = await teams.updateName( + teamId: '<TEAM_ID>', + name: '<NAME>', +); diff --git a/docs/examples/teams/update-prefs.md b/docs/examples/teams/update-prefs.md index d99e821..22c13da 100644 --- a/docs/examples/teams/update-prefs.md +++ b/docs/examples/teams/update-prefs.md @@ -1,24 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Teams teams = Teams(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token - ; + .setSession(''); // The user session to authenticate with - Future result = teams.updatePrefs( - teamId: '[TEAM_ID]', - prefs: {}, - ); +Teams teams = Teams(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Preferences result = await teams.updatePrefs( + teamId: '<TEAM_ID>', + prefs: {}, +); diff --git a/docs/examples/users/create-argon2user.md b/docs/examples/users/create-argon2user.md index a40b3af..080e66a 100644 --- a/docs/examples/users/create-argon2user.md +++ b/docs/examples/users/create-argon2user.md @@ -1,25 +1,15 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Users users = Users(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Users users = Users(client); - Future result = users.createArgon2User( - userId: '[USER_ID]', +User result = await users.createArgon2User( + userId: '<USER_ID>', email: 'email@example.com', password: 'password', - ); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file + name: '<NAME>', // (optional) +); diff --git a/docs/examples/users/create-bcrypt-user.md b/docs/examples/users/create-bcrypt-user.md index 8b55d65..afddc2c 100644 --- a/docs/examples/users/create-bcrypt-user.md +++ b/docs/examples/users/create-bcrypt-user.md @@ -1,25 +1,15 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Users users = Users(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Users users = Users(client); - Future result = users.createBcryptUser( - userId: '[USER_ID]', +User result = await users.createBcryptUser( + userId: '<USER_ID>', email: 'email@example.com', password: 'password', - ); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file + name: '<NAME>', // (optional) +); diff --git a/docs/examples/users/create-m-d5user.md b/docs/examples/users/create-m-d5user.md index 3ab8901..05a9cc1 100644 --- a/docs/examples/users/create-m-d5user.md +++ b/docs/examples/users/create-m-d5user.md @@ -1,25 +1,15 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Users users = Users(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Users users = Users(client); - Future result = users.createMD5User( - userId: '[USER_ID]', +User result = await users.createMD5User( + userId: '<USER_ID>', email: 'email@example.com', password: 'password', - ); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file + name: '<NAME>', // (optional) +); diff --git a/docs/examples/users/create-mfa-recovery-codes.md b/docs/examples/users/create-mfa-recovery-codes.md new file mode 100644 index 0000000..15cc9c1 --- /dev/null +++ b/docs/examples/users/create-mfa-recovery-codes.md @@ -0,0 +1,12 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Users users = Users(client); + +MfaRecoveryCodes result = await users.createMfaRecoveryCodes( + userId: '<USER_ID>', +); diff --git a/docs/examples/users/create-p-h-pass-user.md b/docs/examples/users/create-p-h-pass-user.md index bedb44f..952584d 100644 --- a/docs/examples/users/create-p-h-pass-user.md +++ b/docs/examples/users/create-p-h-pass-user.md @@ -1,25 +1,15 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Users users = Users(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Users users = Users(client); - Future result = users.createPHPassUser( - userId: '[USER_ID]', +User result = await users.createPHPassUser( + userId: '<USER_ID>', email: 'email@example.com', password: 'password', - ); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file + name: '<NAME>', // (optional) +); diff --git a/docs/examples/users/create-s-h-a-user.md b/docs/examples/users/create-s-h-a-user.md index 361f309..9b29c5b 100644 --- a/docs/examples/users/create-s-h-a-user.md +++ b/docs/examples/users/create-s-h-a-user.md @@ -1,25 +1,16 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Users users = Users(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Users users = Users(client); - Future result = users.createSHAUser( - userId: '[USER_ID]', +User result = await users.createSHAUser( + userId: '<USER_ID>', email: 'email@example.com', password: 'password', - ); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file + passwordVersion: PasswordHash.sha1, // (optional) + name: '<NAME>', // (optional) +); diff --git a/docs/examples/users/create-scrypt-modified-user.md b/docs/examples/users/create-scrypt-modified-user.md index fa5b805..967fc38 100644 --- a/docs/examples/users/create-scrypt-modified-user.md +++ b/docs/examples/users/create-scrypt-modified-user.md @@ -1,28 +1,18 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Users users = Users(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Users users = Users(client); - Future result = users.createScryptModifiedUser( - userId: '[USER_ID]', +User result = await users.createScryptModifiedUser( + userId: '<USER_ID>', email: 'email@example.com', password: 'password', - passwordSalt: '[PASSWORD_SALT]', - passwordSaltSeparator: '[PASSWORD_SALT_SEPARATOR]', - passwordSignerKey: '[PASSWORD_SIGNER_KEY]', - ); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file + passwordSalt: '<PASSWORD_SALT>', + passwordSaltSeparator: '<PASSWORD_SALT_SEPARATOR>', + passwordSignerKey: '<PASSWORD_SIGNER_KEY>', + name: '<NAME>', // (optional) +); diff --git a/docs/examples/users/create-scrypt-user.md b/docs/examples/users/create-scrypt-user.md index 91e1f7d..ba4fce8 100644 --- a/docs/examples/users/create-scrypt-user.md +++ b/docs/examples/users/create-scrypt-user.md @@ -1,30 +1,20 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Users users = Users(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Users users = Users(client); - Future result = users.createScryptUser( - userId: '[USER_ID]', +User result = await users.createScryptUser( + userId: '<USER_ID>', email: 'email@example.com', password: 'password', - passwordSalt: '[PASSWORD_SALT]', + passwordSalt: '<PASSWORD_SALT>', passwordCpu: 0, passwordMemory: 0, passwordParallel: 0, passwordLength: 0, - ); - - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file + name: '<NAME>', // (optional) +); diff --git a/docs/examples/users/create-session.md b/docs/examples/users/create-session.md new file mode 100644 index 0000000..8efc2d9 --- /dev/null +++ b/docs/examples/users/create-session.md @@ -0,0 +1,12 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Users users = Users(client); + +Session result = await users.createSession( + userId: '<USER_ID>', +); diff --git a/docs/examples/users/create-target.md b/docs/examples/users/create-target.md new file mode 100644 index 0000000..630afbf --- /dev/null +++ b/docs/examples/users/create-target.md @@ -0,0 +1,17 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Users users = Users(client); + +Target result = await users.createTarget( + userId: '<USER_ID>', + targetId: '<TARGET_ID>', + providerType: MessagingProviderType.email, + identifier: '<IDENTIFIER>', + providerId: '<PROVIDER_ID>', // (optional) + name: '<NAME>', // (optional) +); diff --git a/docs/examples/users/create-token.md b/docs/examples/users/create-token.md new file mode 100644 index 0000000..51a9892 --- /dev/null +++ b/docs/examples/users/create-token.md @@ -0,0 +1,14 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Users users = Users(client); + +Token result = await users.createToken( + userId: '<USER_ID>', + length: 4, // (optional) + expire: 60, // (optional) +); diff --git a/docs/examples/users/create.md b/docs/examples/users/create.md index 517cd22..8faa909 100644 --- a/docs/examples/users/create.md +++ b/docs/examples/users/create.md @@ -1,23 +1,16 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Users users = Users(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = users.create( - userId: '[USER_ID]', - ); +Users users = Users(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +User result = await users.create( + userId: '<USER_ID>', + email: 'email@example.com', // (optional) + phone: '+12065550100', // (optional) + password: '', // (optional) + name: '<NAME>', // (optional) +); diff --git a/docs/examples/users/delete-identity.md b/docs/examples/users/delete-identity.md index 4bcfd6d..3ad24e3 100644 --- a/docs/examples/users/delete-identity.md +++ b/docs/examples/users/delete-identity.md @@ -1,23 +1,12 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Users users = Users(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = users.deleteIdentity( - identityId: '[IDENTITY_ID]', - ); +Users users = Users(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +await users.deleteIdentity( + identityId: '<IDENTITY_ID>', +); diff --git a/docs/examples/users/delete-mfa-authenticator.md b/docs/examples/users/delete-mfa-authenticator.md new file mode 100644 index 0000000..8c67955 --- /dev/null +++ b/docs/examples/users/delete-mfa-authenticator.md @@ -0,0 +1,13 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Users users = Users(client); + +await users.deleteMfaAuthenticator( + userId: '<USER_ID>', + type: AuthenticatorType.totp, +); diff --git a/docs/examples/users/delete-session.md b/docs/examples/users/delete-session.md index 3f76118..4cca314 100644 --- a/docs/examples/users/delete-session.md +++ b/docs/examples/users/delete-session.md @@ -1,24 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Users users = Users(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = users.deleteSession( - userId: '[USER_ID]', - sessionId: '[SESSION_ID]', - ); +Users users = Users(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +await users.deleteSession( + userId: '<USER_ID>', + sessionId: '<SESSION_ID>', +); diff --git a/docs/examples/users/delete-sessions.md b/docs/examples/users/delete-sessions.md index 69cbc5e..df0c5f1 100644 --- a/docs/examples/users/delete-sessions.md +++ b/docs/examples/users/delete-sessions.md @@ -1,23 +1,12 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Users users = Users(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = users.deleteSessions( - userId: '[USER_ID]', - ); +Users users = Users(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +await users.deleteSessions( + userId: '<USER_ID>', +); diff --git a/docs/examples/users/delete-target.md b/docs/examples/users/delete-target.md new file mode 100644 index 0000000..34283a1 --- /dev/null +++ b/docs/examples/users/delete-target.md @@ -0,0 +1,13 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Users users = Users(client); + +await users.deleteTarget( + userId: '<USER_ID>', + targetId: '<TARGET_ID>', +); diff --git a/docs/examples/users/delete.md b/docs/examples/users/delete.md index 1e1311d..6801e13 100644 --- a/docs/examples/users/delete.md +++ b/docs/examples/users/delete.md @@ -1,23 +1,12 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Users users = Users(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = users.delete( - userId: '[USER_ID]', - ); +Users users = Users(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +await users.delete( + userId: '<USER_ID>', +); diff --git a/docs/examples/users/get-mfa-recovery-codes.md b/docs/examples/users/get-mfa-recovery-codes.md new file mode 100644 index 0000000..95f5543 --- /dev/null +++ b/docs/examples/users/get-mfa-recovery-codes.md @@ -0,0 +1,12 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Users users = Users(client); + +MfaRecoveryCodes result = await users.getMfaRecoveryCodes( + userId: '<USER_ID>', +); diff --git a/docs/examples/users/get-prefs.md b/docs/examples/users/get-prefs.md index eb33ae6..54da404 100644 --- a/docs/examples/users/get-prefs.md +++ b/docs/examples/users/get-prefs.md @@ -1,23 +1,12 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Users users = Users(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = users.getPrefs( - userId: '[USER_ID]', - ); +Users users = Users(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Preferences result = await users.getPrefs( + userId: '<USER_ID>', +); diff --git a/docs/examples/users/get-target.md b/docs/examples/users/get-target.md new file mode 100644 index 0000000..4f1f1b4 --- /dev/null +++ b/docs/examples/users/get-target.md @@ -0,0 +1,13 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Users users = Users(client); + +Target result = await users.getTarget( + userId: '<USER_ID>', + targetId: '<TARGET_ID>', +); diff --git a/docs/examples/users/get.md b/docs/examples/users/get.md index c568529..d57f980 100644 --- a/docs/examples/users/get.md +++ b/docs/examples/users/get.md @@ -1,23 +1,12 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Users users = Users(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = users.get( - userId: '[USER_ID]', - ); +Users users = Users(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +User result = await users.get( + userId: '<USER_ID>', +); diff --git a/docs/examples/users/list-identities.md b/docs/examples/users/list-identities.md index b19fed0..d811428 100644 --- a/docs/examples/users/list-identities.md +++ b/docs/examples/users/list-identities.md @@ -1,22 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Users users = Users(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = users.listIdentities( - ); +Users users = Users(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +IdentityList result = await users.listIdentities( + queries: [], // (optional) + search: '<SEARCH>', // (optional) +); diff --git a/docs/examples/users/list-logs.md b/docs/examples/users/list-logs.md index 0d2143a..539710a 100644 --- a/docs/examples/users/list-logs.md +++ b/docs/examples/users/list-logs.md @@ -1,23 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Users users = Users(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = users.listLogs( - userId: '[USER_ID]', - ); +Users users = Users(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +LogList result = await users.listLogs( + userId: '<USER_ID>', + queries: [], // (optional) +); diff --git a/docs/examples/users/list-memberships.md b/docs/examples/users/list-memberships.md index 36a83ed..bc1bf36 100644 --- a/docs/examples/users/list-memberships.md +++ b/docs/examples/users/list-memberships.md @@ -1,23 +1,12 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Users users = Users(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = users.listMemberships( - userId: '[USER_ID]', - ); +Users users = Users(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +MembershipList result = await users.listMemberships( + userId: '<USER_ID>', +); diff --git a/docs/examples/users/list-mfa-factors.md b/docs/examples/users/list-mfa-factors.md new file mode 100644 index 0000000..b70fcc5 --- /dev/null +++ b/docs/examples/users/list-mfa-factors.md @@ -0,0 +1,12 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Users users = Users(client); + +MfaFactors result = await users.listMfaFactors( + userId: '<USER_ID>', +); diff --git a/docs/examples/users/list-sessions.md b/docs/examples/users/list-sessions.md index 5f77fdb..108fd27 100644 --- a/docs/examples/users/list-sessions.md +++ b/docs/examples/users/list-sessions.md @@ -1,23 +1,12 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Users users = Users(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = users.listSessions( - userId: '[USER_ID]', - ); +Users users = Users(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +SessionList result = await users.listSessions( + userId: '<USER_ID>', +); diff --git a/docs/examples/users/list-targets.md b/docs/examples/users/list-targets.md new file mode 100644 index 0000000..a4831fe --- /dev/null +++ b/docs/examples/users/list-targets.md @@ -0,0 +1,13 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Users users = Users(client); + +TargetList result = await users.listTargets( + userId: '<USER_ID>', + queries: [], // (optional) +); diff --git a/docs/examples/users/list.md b/docs/examples/users/list.md index 34498c0..6da9d81 100644 --- a/docs/examples/users/list.md +++ b/docs/examples/users/list.md @@ -1,22 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Users users = Users(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = users.list( - ); +Users users = Users(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +UserList result = await users.list( + queries: [], // (optional) + search: '<SEARCH>', // (optional) +); diff --git a/docs/examples/users/update-email-verification.md b/docs/examples/users/update-email-verification.md index 8853f86..8f373b9 100644 --- a/docs/examples/users/update-email-verification.md +++ b/docs/examples/users/update-email-verification.md @@ -1,24 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Users users = Users(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = users.updateEmailVerification( - userId: '[USER_ID]', - emailVerification: false, - ); +Users users = Users(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +User result = await users.updateEmailVerification( + userId: '<USER_ID>', + emailVerification: false, +); diff --git a/docs/examples/users/update-email.md b/docs/examples/users/update-email.md index 8813e11..5391891 100644 --- a/docs/examples/users/update-email.md +++ b/docs/examples/users/update-email.md @@ -1,24 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Users users = Users(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = users.updateEmail( - userId: '[USER_ID]', - email: 'email@example.com', - ); +Users users = Users(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +User result = await users.updateEmail( + userId: '<USER_ID>', + email: 'email@example.com', +); diff --git a/docs/examples/users/update-labels.md b/docs/examples/users/update-labels.md index ecd06e7..115e0e8 100644 --- a/docs/examples/users/update-labels.md +++ b/docs/examples/users/update-labels.md @@ -1,24 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Users users = Users(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = users.updateLabels( - userId: '[USER_ID]', - labels: [], - ); +Users users = Users(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +User result = await users.updateLabels( + userId: '<USER_ID>', + labels: [], +); diff --git a/docs/examples/users/update-mfa-recovery-codes.md b/docs/examples/users/update-mfa-recovery-codes.md new file mode 100644 index 0000000..15f0f6b --- /dev/null +++ b/docs/examples/users/update-mfa-recovery-codes.md @@ -0,0 +1,12 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Users users = Users(client); + +MfaRecoveryCodes result = await users.updateMfaRecoveryCodes( + userId: '<USER_ID>', +); diff --git a/docs/examples/users/update-mfa.md b/docs/examples/users/update-mfa.md new file mode 100644 index 0000000..be50cb6 --- /dev/null +++ b/docs/examples/users/update-mfa.md @@ -0,0 +1,13 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Users users = Users(client); + +User result = await users.updateMfa( + userId: '<USER_ID>', + mfa: false, +); diff --git a/docs/examples/users/update-name.md b/docs/examples/users/update-name.md index 56797d5..bd39acd 100644 --- a/docs/examples/users/update-name.md +++ b/docs/examples/users/update-name.md @@ -1,24 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Users users = Users(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = users.updateName( - userId: '[USER_ID]', - name: '[NAME]', - ); +Users users = Users(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +User result = await users.updateName( + userId: '<USER_ID>', + name: '<NAME>', +); diff --git a/docs/examples/users/update-password.md b/docs/examples/users/update-password.md index 3dfedb4..532f4c6 100644 --- a/docs/examples/users/update-password.md +++ b/docs/examples/users/update-password.md @@ -1,24 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Users users = Users(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = users.updatePassword( - userId: '[USER_ID]', - password: '', - ); +Users users = Users(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +User result = await users.updatePassword( + userId: '<USER_ID>', + password: '', +); diff --git a/docs/examples/users/update-phone-verification.md b/docs/examples/users/update-phone-verification.md index 37c3ced..f778474 100644 --- a/docs/examples/users/update-phone-verification.md +++ b/docs/examples/users/update-phone-verification.md @@ -1,24 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Users users = Users(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = users.updatePhoneVerification( - userId: '[USER_ID]', - phoneVerification: false, - ); +Users users = Users(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +User result = await users.updatePhoneVerification( + userId: '<USER_ID>', + phoneVerification: false, +); diff --git a/docs/examples/users/update-phone.md b/docs/examples/users/update-phone.md index 4d5e311..684cd1d 100644 --- a/docs/examples/users/update-phone.md +++ b/docs/examples/users/update-phone.md @@ -1,24 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Users users = Users(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = users.updatePhone( - userId: '[USER_ID]', - number: '+12065550100', - ); +Users users = Users(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +User result = await users.updatePhone( + userId: '<USER_ID>', + number: '+12065550100', +); diff --git a/docs/examples/users/update-prefs.md b/docs/examples/users/update-prefs.md index c6c1bbe..1ee538f 100644 --- a/docs/examples/users/update-prefs.md +++ b/docs/examples/users/update-prefs.md @@ -1,24 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Users users = Users(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = users.updatePrefs( - userId: '[USER_ID]', - prefs: {}, - ); +Users users = Users(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +Preferences result = await users.updatePrefs( + userId: '<USER_ID>', + prefs: {}, +); diff --git a/docs/examples/users/update-status.md b/docs/examples/users/update-status.md index 6f80745..82b57cf 100644 --- a/docs/examples/users/update-status.md +++ b/docs/examples/users/update-status.md @@ -1,24 +1,13 @@ import 'package:dart_appwrite/dart_appwrite.dart'; -void main() { // Init SDK - Client client = Client(); - Users users = Users(client); - - client +Client client = Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID - .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key - ; + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key - Future result = users.updateStatus( - userId: '[USER_ID]', - status: false, - ); +Users users = Users(client); - result - .then((response) { - print(response); - }).catchError((error) { - print(error.response); - }); -} \ No newline at end of file +User result = await users.updateStatus( + userId: '<USER_ID>', + status: false, +); diff --git a/docs/examples/users/update-target.md b/docs/examples/users/update-target.md new file mode 100644 index 0000000..0713439 --- /dev/null +++ b/docs/examples/users/update-target.md @@ -0,0 +1,16 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + .setKey('919c2d18fb5d4...a2ae413da83346ad2'); // Your secret API key + +Users users = Users(client); + +Target result = await users.updateTarget( + userId: '<USER_ID>', + targetId: '<TARGET_ID>', + identifier: '<IDENTIFIER>', // (optional) + providerId: '<PROVIDER_ID>', // (optional) + name: '<NAME>', // (optional) +); diff --git a/example/README.md b/example/README.md index 208cc7f..fc2c6d0 100644 --- a/example/README.md +++ b/example/README.md @@ -18,9 +18,11 @@ Create a new user: Users users = Users(client); User result = await users.create( - userId: '[USER_ID]', - email: 'email@example.com', - password: 'password', + userId: ID.unique(), + email: "email@example.com", + phone: "+123456789", + password: "password", + name: "Walter O'Brien" ); ``` @@ -57,4 +59,4 @@ storage.createFile( }); ``` -All examples and API features are available at the [official Appwrite docs](https://appwrite.io/docs) \ No newline at end of file +All examples and API features are available at the [official Appwrite docs](https://appwrite.io/docs) diff --git a/lib/dart_appwrite.dart b/lib/dart_appwrite.dart index 2d5becc..7e9498a 100644 --- a/lib/dart_appwrite.dart +++ b/lib/dart_appwrite.dart @@ -1,18 +1,20 @@ /// Appwrite Dart SDK /// -/// This SDK is compatible with Appwrite server version 1.4.x. +/// This SDK is compatible with Appwrite server version 1.5.x. /// For older versions, please check /// [previous releases](https://github.com/appwrite/sdk-for-dart/releases). library dart_appwrite; import 'dart:async'; import 'dart:typed_data'; +import 'dart:convert'; import 'src/enums.dart'; import 'src/service.dart'; import 'src/input_file.dart'; import 'src/upload_progress.dart'; import 'models.dart' as models; +import 'enums.dart' as enums; export 'src/response.dart'; export 'src/client.dart'; @@ -31,6 +33,7 @@ part 'services/functions.dart'; part 'services/graphql.dart'; part 'services/health.dart'; part 'services/locale.dart'; +part 'services/messaging.dart'; part 'services/storage.dart'; part 'services/teams.dart'; part 'services/users.dart'; diff --git a/lib/enums.dart b/lib/enums.dart new file mode 100644 index 0000000..1e85822 --- /dev/null +++ b/lib/enums.dart @@ -0,0 +1,21 @@ +/// Appwrite Enums +library dart_appwrite.enums; + +part 'src/enums/authenticator_type.dart'; +part 'src/enums/authentication_factor.dart'; +part 'src/enums/o_auth_provider.dart'; +part 'src/enums/browser.dart'; +part 'src/enums/credit_card.dart'; +part 'src/enums/flag.dart'; +part 'src/enums/relationship_type.dart'; +part 'src/enums/relation_mutate.dart'; +part 'src/enums/index_type.dart'; +part 'src/enums/runtime.dart'; +part 'src/enums/execution_method.dart'; +part 'src/enums/name.dart'; +part 'src/enums/smtp_encryption.dart'; +part 'src/enums/compression.dart'; +part 'src/enums/image_gravity.dart'; +part 'src/enums/image_format.dart'; +part 'src/enums/password_hash.dart'; +part 'src/enums/messaging_provider_type.dart'; diff --git a/lib/models.dart b/lib/models.dart index b3b2c7d..62b5946 100644 --- a/lib/models.dart +++ b/lib/models.dart @@ -25,6 +25,11 @@ part 'src/models/currency_list.dart'; part 'src/models/phone_list.dart'; part 'src/models/variable_list.dart'; part 'src/models/locale_code_list.dart'; +part 'src/models/provider_list.dart'; +part 'src/models/message_list.dart'; +part 'src/models/topic_list.dart'; +part 'src/models/subscriber_list.dart'; +part 'src/models/target_list.dart'; part 'src/models/database.dart'; part 'src/models/collection.dart'; part 'src/models/attribute_list.dart'; @@ -53,6 +58,7 @@ part 'src/models/preferences.dart'; part 'src/models/session.dart'; part 'src/models/identity.dart'; part 'src/models/token.dart'; +part 'src/models/jwt.dart'; part 'src/models/locale.dart'; part 'src/models/locale_code.dart'; part 'src/models/file.dart'; @@ -72,5 +78,15 @@ part 'src/models/phone.dart'; part 'src/models/health_antivirus.dart'; part 'src/models/health_queue.dart'; part 'src/models/health_status.dart'; +part 'src/models/health_certificate.dart'; part 'src/models/health_time.dart'; part 'src/models/headers.dart'; +part 'src/models/mfa_challenge.dart'; +part 'src/models/mfa_recovery_codes.dart'; +part 'src/models/mfa_type.dart'; +part 'src/models/mfa_factors.dart'; +part 'src/models/provider.dart'; +part 'src/models/message.dart'; +part 'src/models/topic.dart'; +part 'src/models/subscriber.dart'; +part 'src/models/target.dart'; diff --git a/lib/query.dart b/lib/query.dart index 5e16445..6fc8003 100644 --- a/lib/query.dart +++ b/lib/query.dart @@ -1,8 +1,32 @@ part of dart_appwrite; + /// Helper class to generate query strings. class Query { - Query._(); + final String method; + final String? attribute; + final dynamic values; + + Query._(this.method, [this.attribute = null, this.values = null]); + + Map<String, dynamic> toJson() { + final map = <String, dynamic>{ + 'method': method, + }; + + if(attribute != null) { + map['attribute'] = attribute; + } + + if(values != null) { + map['values'] = values is List ? values : [values]; + } + + return map; + } + + @override + String toString() => jsonEncode(toJson()); /// Filter resources where [attribute] is equal to [value]. /// @@ -10,90 +34,90 @@ class Query { /// the query will return resources where [attribute] is equal /// to any of the values in the list. static String equal(String attribute, dynamic value) => - _addQuery(attribute, 'equal', value); + Query._('equal', attribute, value).toString(); /// Filter resources where [attribute] is not equal to [value]. - /// - /// [value] can be a single value or a list. If a list is used - /// the query will return resources where [attribute] is equal - /// to any of the values in the list. static String notEqual(String attribute, dynamic value) => - _addQuery(attribute, 'notEqual', value); + Query._('notEqual', attribute, [value]).toString(); /// Filter resources where [attribute] is less than [value]. static String lessThan(String attribute, dynamic value) => - _addQuery(attribute, 'lessThan', value); + Query._('lessThan', attribute, value).toString(); /// Filter resources where [attribute] is less than or equal to [value]. static String lessThanEqual(String attribute, dynamic value) => - _addQuery(attribute, 'lessThanEqual', value); + Query._('lessThanEqual', attribute, value).toString(); /// Filter resources where [attribute] is greater than [value]. static String greaterThan(String attribute, dynamic value) => - _addQuery(attribute, 'greaterThan', value); + Query._('greaterThan', attribute, value).toString(); /// Filter resources where [attribute] is greater than or equal to [value]. static String greaterThanEqual(String attribute, dynamic value) => - _addQuery(attribute, 'greaterThanEqual', value); + Query._('greaterThanEqual', attribute, value).toString(); /// Filter resources where by searching [attribute] for [value]. static String search(String attribute, String value) => - _addQuery(attribute, 'search', value); + Query._('search', attribute, value).toString(); /// Filter resources where [attribute] is null. - static String isNull(String attribute) => 'isNull("$attribute")'; + static String isNull(String attribute) => Query._('isNull', attribute).toString(); /// Filter resources where [attribute] is not null. - static String isNotNull(String attribute) => 'isNotNull("$attribute")'; + static String isNotNull(String attribute) => Query._('isNotNull', attribute).toString(); /// Filter resources where [attribute] is between [start] and [end] (inclusive). static String between(String attribute, dynamic start, dynamic end) => - 'between("$attribute", ${_parseValues(start)}, ${_parseValues(end)})'; + Query._('between', attribute, [start, end]).toString(); /// Filter resources where [attribute] starts with [value]. static String startsWith(String attribute, String value) => - _addQuery(attribute, 'startsWith', value); + Query._('startsWith', attribute, value).toString(); /// Filter resources where [attribute] ends with [value]. static String endsWith(String attribute, String value) => - _addQuery(attribute, 'endsWith', value); + Query._('endsWith', attribute, value).toString(); + + /// Filter resources where [attribute] contains [value] + /// [value] can be a single value or a list. + static String contains(String attribute, dynamic value) => + Query._('contains', attribute, value).toString(); + + static String or(List<String> queries) => + Query._('or', null, queries.map((query) => jsonDecode(query)).toList()).toString(); + + static String and(List<String> queries) => + Query._('and', null, queries.map((query) => jsonDecode(query)).toList()).toString(); /// Specify which attributes should be returned by the API call. static String select(List<String> attributes) => - 'select([${attributes.map((attr) => "\"$attr\"").join(",")}])'; + Query._('select', null, attributes).toString(); /// Sort results by [attribute] ascending. - static String orderAsc(String attribute) => 'orderAsc("$attribute")'; + static String orderAsc(String attribute) => Query._('orderAsc', attribute).toString(); /// Sort results by [attribute] descending. - static String orderDesc(String attribute) => 'orderDesc("$attribute")'; + static String orderDesc(String attribute) => Query._('orderDesc', attribute).toString(); /// Return results before [id]. /// /// Refer to the [Cursor Based Pagination](https://appwrite.io/docs/pagination#cursor-pagination) /// docs for more information. - static String cursorBefore(String id) => 'cursorBefore("$id")'; + static String cursorBefore(String id) => Query._('cursorBefore', null, id).toString(); /// Return results after [id]. /// /// Refer to the [Cursor Based Pagination](https://appwrite.io/docs/pagination#cursor-pagination) /// docs for more information. - static String cursorAfter(String id) => 'cursorAfter("$id")'; + static String cursorAfter(String id) => Query._('cursorAfter', null, id).toString(); /// Return only [limit] results. - static String limit(int limit) => 'limit($limit)'; + static String limit(int limit) => Query._('limit', null, limit).toString(); /// Return results from [offset]. /// /// Refer to the [Offset Pagination](https://appwrite.io/docs/pagination#offset-pagination) /// docs for more information. - static String offset(int offset) => 'offset($offset)'; - - static String _addQuery(String attribute, String method, dynamic value) => (value - is List) - ? '$method("$attribute", [${value.map((item) => _parseValues(item)).join(",")}])' - : '$method("$attribute", [${_parseValues(value)}])'; + static String offset(int offset) => Query._('offset', null, offset).toString(); - static String _parseValues(dynamic value) => - (value is String) ? '"$value"' : '$value'; } \ No newline at end of file diff --git a/lib/services/account.dart b/lib/services/account.dart index bf76309..3d4c582 100644 --- a/lib/services/account.dart +++ b/lib/services/account.dart @@ -26,6 +26,38 @@ class Account extends Service { } + /// Create account + /// + /// Use this endpoint to allow a new user to register a new account in your + /// project. After the user registration completes successfully, you can use + /// the + /// [/account/verfication](https://appwrite.io/docs/references/cloud/client-web/account#createVerification) + /// route to start verifying the user email address. To allow the new user to + /// login to their new account, you need to create a new [account + /// session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession). + Future<models.User> create({required String userId, required String email, required String password, String? name}) async { + final String apiPath = '/account'; + + final Map<String, dynamic> apiParams = { + + 'userId': userId, +'email': email, +'password': password, +'name': name, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.User.fromMap(res.data); + + } + /// Update email /// /// Update currently logged in user account email address. After changing user @@ -60,7 +92,7 @@ class Account extends Service { /// List Identities /// /// Get the list of identities for the currently logged in user. - Future<models.IdentityList> listIdentities({String? queries}) async { + Future<models.IdentityList> listIdentities({List<String>? queries}) async { final String apiPath = '/account/identities'; final Map<String, dynamic> apiParams = { @@ -80,7 +112,7 @@ class Account extends Service { } - /// Delete Identity + /// Delete identity /// /// Delete an identity by its unique ID. Future deleteIdentity({required String identityId}) async { @@ -102,6 +134,32 @@ class Account extends Service { } + /// Create JWT + /// + /// Use this endpoint to create a JSON Web Token. You can use the resulting JWT + /// to authenticate on behalf of the current user when working with the + /// Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes + /// from its creation and will be invalid if the user will logout in that time + /// frame. + Future<models.Jwt> createJWT() async { + final String apiPath = '/account/jwt'; + + final Map<String, dynamic> apiParams = { + + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Jwt.fromMap(res.data); + + } + /// List logs /// /// Get the list of latest security activity logs for the currently logged in @@ -126,6 +184,253 @@ class Account extends Service { } + /// Update MFA + /// + /// Enable or disable MFA on an account. + Future<models.User> updateMFA({required bool mfa}) async { + final String apiPath = '/account/mfa'; + + final Map<String, dynamic> apiParams = { + + 'mfa': mfa, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.User.fromMap(res.data); + + } + + /// Add Authenticator + /// + /// Add an authenticator app to be used as an MFA factor. Verify the + /// authenticator using the [verify + /// authenticator](/docs/references/cloud/client-web/account#verifyAuthenticator) + /// method. + Future<models.MfaType> createMfaAuthenticator({required enums.AuthenticatorType type}) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + + final Map<String, dynamic> apiParams = { + + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaType.fromMap(res.data); + + } + + /// Verify Authenticator + /// + /// Verify an authenticator app after adding it using the [add + /// authenticator](/docs/references/cloud/client-web/account#addAuthenticator) + /// method. + Future<models.User> updateMfaAuthenticator({required enums.AuthenticatorType type, required String otp}) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + + final Map<String, dynamic> apiParams = { + + 'otp': otp, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.User.fromMap(res.data); + + } + + /// Delete Authenticator + /// + /// Delete an authenticator for a user by ID. + Future<models.User> deleteMfaAuthenticator({required enums.AuthenticatorType type, required String otp}) async { + final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value); + + final Map<String, dynamic> apiParams = { + + 'otp': otp, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.User.fromMap(res.data); + + } + + /// Create 2FA Challenge + /// + /// Begin the process of MFA verification after sign-in. Finish the flow with + /// [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) + /// method. + Future<models.MfaChallenge> createMfaChallenge({required enums.AuthenticationFactor factor}) async { + final String apiPath = '/account/mfa/challenge'; + + final Map<String, dynamic> apiParams = { + + 'factor': factor, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaChallenge.fromMap(res.data); + + } + + /// Create MFA Challenge (confirmation) + /// + /// Complete the MFA challenge by providing the one-time password. Finish the + /// process of MFA verification by providing the one-time password. To begin + /// the flow, use + /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) + /// method. + Future updateMfaChallenge({required String challengeId, required String otp}) async { + final String apiPath = '/account/mfa/challenge'; + + final Map<String, dynamic> apiParams = { + + 'challengeId': challengeId, +'otp': otp, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; + + } + + /// List Factors + /// + /// List the factors available on the account to be used as a MFA challange. + Future<models.MfaFactors> listMfaFactors() async { + final String apiPath = '/account/mfa/factors'; + + final Map<String, dynamic> apiParams = { + + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaFactors.fromMap(res.data); + + } + + /// Get MFA Recovery Codes + /// + /// Get recovery codes that can be used as backup for MFA flow. Before getting + /// codes, they must be generated using + /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) + /// method. An OTP challenge is required to read recovery codes. + Future<models.MfaRecoveryCodes> getMfaRecoveryCodes() async { + final String apiPath = '/account/mfa/recovery-codes'; + + final Map<String, dynamic> apiParams = { + + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaRecoveryCodes.fromMap(res.data); + + } + + /// Create MFA Recovery Codes + /// + /// Generate recovery codes as backup for MFA flow. It's recommended to + /// generate and show then immediately after user successfully adds their + /// authehticator. Recovery codes can be used as a MFA verification type in + /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) + /// method. + Future<models.MfaRecoveryCodes> createMfaRecoveryCodes() async { + final String apiPath = '/account/mfa/recovery-codes'; + + final Map<String, dynamic> apiParams = { + + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaRecoveryCodes.fromMap(res.data); + + } + + /// Regenerate MFA Recovery Codes + /// + /// Regenerate recovery codes that can be used as backup for MFA flow. Before + /// regenerating codes, they must be first generated using + /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) + /// method. An OTP challenge is required to regenreate recovery codes. + Future<models.MfaRecoveryCodes> updateMfaRecoveryCodes() async { + final String apiPath = '/account/mfa/recovery-codes'; + + final Map<String, dynamic> apiParams = { + + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaRecoveryCodes.fromMap(res.data); + + } + /// Update name /// /// Update currently logged in user account name. @@ -293,7 +598,7 @@ class Account extends Service { /// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) /// the only valid redirect URLs are the ones from domains you have set when /// adding your platforms in the console interface. - Future<models.Token> updateRecovery({required String userId, required String secret, required String password, required String passwordAgain}) async { + Future<models.Token> updateRecovery({required String userId, required String secret, required String password}) async { final String apiPath = '/account/recovery'; final Map<String, dynamic> apiParams = { @@ -301,7 +606,6 @@ class Account extends Service { 'userId': userId, 'secret': secret, 'password': password, -'passwordAgain': passwordAgain, }; @@ -362,6 +666,141 @@ class Account extends Service { } + /// Create anonymous session + /// + /// Use this endpoint to allow a new user to register an anonymous account in + /// your project. This route will also create a new session for the user. To + /// allow the new user to convert an anonymous account to a normal account, you + /// need to update its [email and + /// password](https://appwrite.io/docs/references/cloud/client-web/account#updateEmail) + /// or create an [OAuth2 + /// session](https://appwrite.io/docs/references/cloud/client-web/account#CreateOAuth2Session). + Future<models.Session> createAnonymousSession() async { + final String apiPath = '/account/sessions/anonymous'; + + final Map<String, dynamic> apiParams = { + + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Session.fromMap(res.data); + + } + + /// Create email password session + /// + /// Allow the user to login into their account by providing a valid email and + /// password combination. This route will create a new session for the user. + /// + /// A user is limited to 10 active sessions at a time by default. [Learn more + /// about session + /// limits](https://appwrite.io/docs/authentication-security#limits). + Future<models.Session> createEmailPasswordSession({required String email, required String password}) async { + final String apiPath = '/account/sessions/email'; + + final Map<String, dynamic> apiParams = { + + 'email': email, +'password': password, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Session.fromMap(res.data); + + } + + /// Update magic URL session + /// + /// Use this endpoint to create a session from token. Provide the **userId** + /// and **secret** parameters from the successful response of authentication + /// flows initiated by token creation. For example, magic URL and phone login. + Future<models.Session> updateMagicURLSession({required String userId, required String secret}) async { + final String apiPath = '/account/sessions/magic-url'; + + final Map<String, dynamic> apiParams = { + + 'userId': userId, +'secret': secret, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Session.fromMap(res.data); + + } + + /// Update phone session + /// + /// Use this endpoint to create a session from token. Provide the **userId** + /// and **secret** parameters from the successful response of authentication + /// flows initiated by token creation. For example, magic URL and phone login. + Future<models.Session> updatePhoneSession({required String userId, required String secret}) async { + final String apiPath = '/account/sessions/phone'; + + final Map<String, dynamic> apiParams = { + + 'userId': userId, +'secret': secret, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Session.fromMap(res.data); + + } + + /// Create session + /// + /// Use this endpoint to create a session from token. Provide the **userId** + /// and **secret** parameters from the successful response of authentication + /// flows initiated by token creation. For example, magic URL and phone login. + Future<models.Session> createSession({required String userId, required String secret}) async { + final String apiPath = '/account/sessions/token'; + + final Map<String, dynamic> apiParams = { + + 'userId': userId, +'secret': secret, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Session.fromMap(res.data); + + } + /// Get session /// /// Use this endpoint to get a logged in user's session using a Session ID. @@ -385,11 +824,11 @@ class Account extends Service { } - /// Update OAuth session (refresh tokens) + /// Update session /// - /// Access tokens have limited lifespan and expire to mitigate security risks. - /// If session was created using an OAuth provider, this route can be used to - /// "refresh" the access token. + /// Use this endpoint to extend a session's length. Extending a session is + /// useful when session expiry is short. If the session was created using an + /// OAuth provider, this endpoint refreshes the access token from the provider. Future<models.Session> updateSession({required String sessionId}) async { final String apiPath = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); @@ -459,6 +898,165 @@ class Account extends Service { } + /// Create email token (OTP) + /// + /// Sends the user an email with a secret key for creating a session. If the + /// provided user ID has not be registered, a new user will be created. Use the + /// returned user ID and secret and submit a request to the [POST + /// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) + /// endpoint to complete the login process. The secret sent to the user's email + /// is valid for 15 minutes. + /// + /// A user is limited to 10 active sessions at a time by default. [Learn more + /// about session + /// limits](https://appwrite.io/docs/authentication-security#limits). + Future<models.Token> createEmailToken({required String userId, required String email, bool? phrase}) async { + final String apiPath = '/account/tokens/email'; + + final Map<String, dynamic> apiParams = { + + 'userId': userId, +'email': email, +'phrase': phrase, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Token.fromMap(res.data); + + } + + /// Create magic URL token + /// + /// Sends the user an email with a secret key for creating a session. If the + /// provided user ID has not been registered, a new user will be created. When + /// the user clicks the link in the email, the user is redirected back to the + /// URL you provided with the secret key and userId values attached to the URL + /// query string. Use the query string parameters to submit a request to the + /// [POST + /// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) + /// endpoint to complete the login process. The link sent to the user's email + /// address is valid for 1 hour. If you are on a mobile device you can leave + /// the URL parameter empty, so that the login completion will be handled by + /// your Appwrite instance by default. + /// + /// A user is limited to 10 active sessions at a time by default. [Learn more + /// about session + /// limits](https://appwrite.io/docs/authentication-security#limits). + /// + Future<models.Token> createMagicURLToken({required String userId, required String email, String? url, bool? phrase}) async { + final String apiPath = '/account/tokens/magic-url'; + + final Map<String, dynamic> apiParams = { + + 'userId': userId, +'email': email, +'url': url, +'phrase': phrase, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Token.fromMap(res.data); + + } + + /// Create OAuth2 token + /// + /// Allow the user to login to their account using the OAuth2 provider of their + /// choice. Each OAuth2 provider should be enabled from the Appwrite console + /// first. Use the success and failure arguments to provide a redirect URL's + /// back to your app when login is completed. + /// + /// If authentication succeeds, `userId` and `secret` of a token will be + /// appended to the success URL as query parameters. These can be used to + /// create a new session using the [Create + /// session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) + /// endpoint. + /// + /// A user is limited to 10 active sessions at a time by default. [Learn more + /// about session + /// limits](https://appwrite.io/docs/authentication-security#limits). + Future createOAuth2Token({required enums.OAuthProvider provider, String? success, String? failure, List<String>? scopes}) async { + final String apiPath = '/account/tokens/oauth2/{provider}'.replaceAll('{provider}', provider.value); + + final Map<String, dynamic> params = { + 'success': success, +'failure': failure, +'scopes': scopes, + + + 'project': client.config['project'], + }; + + final List query = []; + + params.forEach((key, value) { + if (value is List) { + for (var item in value) { + query.add(Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item)); + } + } else if(value != null) { + query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value)); + } + }); + + Uri endpoint = Uri.parse(client.endPoint); + Uri url = Uri(scheme: endpoint.scheme, + host: endpoint.host, + port: endpoint.port, + path: endpoint.path + apiPath, + query: query.join('&') + ); + + return client.webAuth(url); + } + + /// Create phone token + /// + /// Sends the user an SMS with a secret key for creating a session. If the + /// provided user ID has not be registered, a new user will be created. Use the + /// returned user ID and secret and submit a request to the [POST + /// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) + /// endpoint to complete the login process. The secret sent to the user's phone + /// is valid for 15 minutes. + /// + /// A user is limited to 10 active sessions at a time by default. [Learn more + /// about session + /// limits](https://appwrite.io/docs/authentication-security#limits). + Future<models.Token> createPhoneToken({required String userId, required String phone}) async { + final String apiPath = '/account/tokens/phone'; + + final Map<String, dynamic> apiParams = { + + 'userId': userId, +'phone': phone, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Token.fromMap(res.data); + + } + /// Create email verification /// /// Use this endpoint to send a verification message to your user email address diff --git a/lib/services/avatars.dart b/lib/services/avatars.dart index d800419..f3f3a95 100644 --- a/lib/services/avatars.dart +++ b/lib/services/avatars.dart @@ -17,8 +17,8 @@ class Avatars extends Service { /// with preserved aspect ratio. If both dimensions are 0, the API provides an /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. - Future<Uint8List> getBrowser({required String code, int? width, int? height, int? quality}) async { - final String apiPath = '/avatars/browsers/{code}'.replaceAll('{code}', code); + Future<Uint8List> getBrowser({required enums.Browser code, int? width, int? height, int? quality}) async { + final String apiPath = '/avatars/browsers/{code}'.replaceAll('{code}', code.value); final Map<String, dynamic> params = { 'width': width, @@ -27,7 +27,7 @@ class Avatars extends Service { 'project': client.config['project'], - 'key': client.config['key'], + 'session': client.config['session'], }; final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); @@ -45,8 +45,8 @@ class Avatars extends Service { /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. /// - Future<Uint8List> getCreditCard({required String code, int? width, int? height, int? quality}) async { - final String apiPath = '/avatars/credit-cards/{code}'.replaceAll('{code}', code); + Future<Uint8List> getCreditCard({required enums.CreditCard code, int? width, int? height, int? quality}) async { + final String apiPath = '/avatars/credit-cards/{code}'.replaceAll('{code}', code.value); final Map<String, dynamic> params = { 'width': width, @@ -55,7 +55,7 @@ class Avatars extends Service { 'project': client.config['project'], - 'key': client.config['key'], + 'session': client.config['session'], }; final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); @@ -75,7 +75,7 @@ class Avatars extends Service { 'project': client.config['project'], - 'key': client.config['key'], + 'session': client.config['session'], }; final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); @@ -94,8 +94,8 @@ class Avatars extends Service { /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. /// - Future<Uint8List> getFlag({required String code, int? width, int? height, int? quality}) async { - final String apiPath = '/avatars/flags/{code}'.replaceAll('{code}', code); + Future<Uint8List> getFlag({required enums.Flag code, int? width, int? height, int? quality}) async { + final String apiPath = '/avatars/flags/{code}'.replaceAll('{code}', code.value); final Map<String, dynamic> params = { 'width': width, @@ -104,7 +104,7 @@ class Avatars extends Service { 'project': client.config['project'], - 'key': client.config['key'], + 'session': client.config['session'], }; final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); @@ -133,7 +133,7 @@ class Avatars extends Service { 'project': client.config['project'], - 'key': client.config['key'], + 'session': client.config['session'], }; final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); @@ -169,7 +169,7 @@ class Avatars extends Service { 'project': client.config['project'], - 'key': client.config['key'], + 'session': client.config['session'], }; final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); @@ -192,7 +192,7 @@ class Avatars extends Service { 'project': client.config['project'], - 'key': client.config['key'], + 'session': client.config['session'], }; final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); diff --git a/lib/services/databases.dart b/lib/services/databases.dart index 360a8d3..546c92e 100644 --- a/lib/services/databases.dart +++ b/lib/services/databases.dart @@ -255,6 +255,7 @@ class Databases extends Service { /// List attributes /// + /// List attributes in the collection. Future<models.AttributeList> listAttributes({required String databaseId, required String collectionId, List<String>? queries}) async { final String apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); @@ -304,6 +305,8 @@ class Databases extends Service { /// Update boolean attribute /// + /// Update a boolean attribute. Changing the `default` value will not update + /// already existing documents. Future<models.AttributeBoolean> updateBooleanAttribute({required String databaseId, required String collectionId, required String key, required bool xrequired, required bool? xdefault}) async { final String apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); @@ -327,6 +330,7 @@ class Databases extends Service { /// Create datetime attribute /// + /// Create a date time attribute according to the ISO 8601 standard. Future<models.AttributeDatetime> createDatetimeAttribute({required String databaseId, required String collectionId, required String key, required bool xrequired, String? xdefault, bool? array}) async { final String apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); @@ -352,6 +356,8 @@ class Databases extends Service { /// Update dateTime attribute /// + /// Update a date time attribute. Changing the `default` value will not update + /// already existing documents. Future<models.AttributeDatetime> updateDatetimeAttribute({required String databaseId, required String collectionId, required String key, required bool xrequired, required String? xdefault}) async { final String apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); @@ -428,6 +434,9 @@ class Databases extends Service { /// Create enum attribute /// + /// Create an enumeration attribute. The `elements` param acts as a white-list + /// of accepted values for this attribute. + /// Future<models.AttributeEnum> createEnumAttribute({required String databaseId, required String collectionId, required String key, required List<String> elements, required bool xrequired, String? xdefault, bool? array}) async { final String apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/enum'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); @@ -653,7 +662,7 @@ class Databases extends Service { /// Create relationship attribute. [Learn more about relationship /// attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). /// - Future<models.AttributeRelationship> createRelationshipAttribute({required String databaseId, required String collectionId, required String relatedCollectionId, required String type, bool? twoWay, String? key, String? twoWayKey, String? onDelete}) async { + Future<models.AttributeRelationship> createRelationshipAttribute({required String databaseId, required String collectionId, required String relatedCollectionId, required enums.RelationshipType type, bool? twoWay, String? key, String? twoWayKey, enums.RelationMutate? onDelete}) async { final String apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); final Map<String, dynamic> apiParams = { @@ -788,6 +797,7 @@ class Databases extends Service { /// Get attribute /// + /// Get attribute by ID. Future getAttribute({required String databaseId, required String collectionId, required String key}) async { final String apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); @@ -809,6 +819,7 @@ class Databases extends Service { /// Delete attribute /// + /// Deletes an attribute. Future deleteAttribute({required String databaseId, required String collectionId, required String key}) async { final String apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); @@ -833,7 +844,7 @@ class Databases extends Service { /// Update relationship attribute. [Learn more about relationship /// attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). /// - Future<models.AttributeRelationship> updateRelationshipAttribute({required String databaseId, required String collectionId, required String key, String? onDelete}) async { + Future<models.AttributeRelationship> updateRelationshipAttribute({required String databaseId, required String collectionId, required String key, enums.RelationMutate? onDelete}) async { final String apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}/relationship'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); final Map<String, dynamic> apiParams = { @@ -978,6 +989,7 @@ class Databases extends Service { /// List indexes /// + /// List indexes in the collection. Future<models.IndexList> listIndexes({required String databaseId, required String collectionId, List<String>? queries}) async { final String apiPath = '/databases/{databaseId}/collections/{collectionId}/indexes'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); @@ -1000,7 +1012,10 @@ class Databases extends Service { /// Create index /// - Future<models.Index> createIndex({required String databaseId, required String collectionId, required String key, required String type, required List<String> attributes, List<String>? orders}) async { + /// Creates an index on the attributes listed. Your index should include all + /// the attributes you will query in a single request. + /// Attributes can be `key`, `fulltext`, and `unique`. + Future<models.Index> createIndex({required String databaseId, required String collectionId, required String key, required enums.IndexType type, required List<String> attributes, List<String>? orders}) async { final String apiPath = '/databases/{databaseId}/collections/{collectionId}/indexes'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); final Map<String, dynamic> apiParams = { @@ -1025,6 +1040,7 @@ class Databases extends Service { /// Get index /// + /// Get index by ID. Future<models.Index> getIndex({required String databaseId, required String collectionId, required String key}) async { final String apiPath = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); @@ -1046,6 +1062,7 @@ class Databases extends Service { /// Delete index /// + /// Delete an index. Future deleteIndex({required String databaseId, required String collectionId, required String key}) async { final String apiPath = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); diff --git a/lib/services/functions.dart b/lib/services/functions.dart index 93356cf..78dccbd 100644 --- a/lib/services/functions.dart +++ b/lib/services/functions.dart @@ -36,7 +36,7 @@ class Functions extends Service { /// [permissions](https://appwrite.io/docs/permissions) to allow different /// project users or team with access to execute the function using the client /// API. - Future<models.Func> create({required String functionId, required String name, required String runtime, List<String>? execute, List<String>? events, String? schedule, int? timeout, bool? enabled, bool? logging, String? entrypoint, String? commands, String? installationId, String? providerRepositoryId, String? providerBranch, bool? providerSilentMode, String? providerRootDirectory, String? templateRepository, String? templateOwner, String? templateRootDirectory, String? templateBranch}) async { + Future<models.Func> create({required String functionId, required String name, required enums.Runtime runtime, List<String>? execute, List<String>? events, String? schedule, int? timeout, bool? enabled, bool? logging, String? entrypoint, String? commands, String? installationId, String? providerRepositoryId, String? providerBranch, bool? providerSilentMode, String? providerRootDirectory, String? templateRepository, String? templateOwner, String? templateRootDirectory, String? templateBranch}) async { final String apiPath = '/functions'; final Map<String, dynamic> apiParams = { @@ -122,7 +122,7 @@ class Functions extends Service { /// Update function /// /// Update function by its unique ID. - Future<models.Func> update({required String functionId, required String name, String? runtime, List<String>? execute, List<String>? events, String? schedule, int? timeout, bool? enabled, bool? logging, String? entrypoint, String? commands, String? installationId, String? providerRepositoryId, String? providerBranch, bool? providerSilentMode, String? providerRootDirectory}) async { + Future<models.Func> update({required String functionId, required String name, enums.Runtime? runtime, List<String>? execute, List<String>? events, String? schedule, int? timeout, bool? enabled, bool? logging, String? entrypoint, String? commands, String? installationId, String? providerRepositoryId, String? providerBranch, bool? providerSilentMode, String? providerRootDirectory}) async { final String apiPath = '/functions/{functionId}'.replaceAll('{functionId}', functionId); final Map<String, dynamic> apiParams = { @@ -387,7 +387,7 @@ class Functions extends Service { /// current execution status. You can ping the `Get Execution` endpoint to get /// updates on the current execution status. Once this endpoint is called, your /// function execution process will start asynchronously. - Future<models.Execution> createExecution({required String functionId, String? body, bool? xasync, String? path, String? method, Map? headers}) async { + Future<models.Execution> createExecution({required String functionId, String? body, bool? xasync, String? path, enums.ExecutionMethod? method, Map? headers}) async { final String apiPath = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); final Map<String, dynamic> apiParams = { diff --git a/lib/services/health.dart b/lib/services/health.dart index 6681b50..35bdc68 100644 --- a/lib/services/health.dart +++ b/lib/services/health.dart @@ -72,6 +72,29 @@ class Health extends Service { } + /// Get the SSL certificate for a domain + /// + /// Get the SSL certificate for a domain + Future<models.HealthCertificate> getCertificate({String? domain}) async { + final String apiPath = '/health/certificate'; + + final Map<String, dynamic> apiParams = { + 'domain': domain, + + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.HealthCertificate.fromMap(res.data); + + } + /// Get DB /// /// Check the Appwrite database servers are up and connection is successful. @@ -237,8 +260,34 @@ class Health extends Service { } + /// Get number of failed queue jobs + /// + /// Returns the amount of failed jobs in a given queue. + /// + Future<models.HealthQueue> getFailedJobs({required enums.Name name, int? threshold}) async { + final String apiPath = '/health/queue/failed/{name}'.replaceAll('{name}', name.value); + + final Map<String, dynamic> apiParams = { + 'threshold': threshold, + + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.HealthQueue.fromMap(res.data); + + } + /// Get functions queue /// + /// Get the number of function executions that are waiting to be processed in + /// the Appwrite internal queue server. Future<models.HealthQueue> getQueueFunctions({int? threshold}) async { final String apiPath = '/health/queue/functions'; @@ -355,6 +404,54 @@ class Health extends Service { } + /// Get usage queue + /// + /// Get the number of metrics that are waiting to be processed in the Appwrite + /// internal queue server. + Future<models.HealthQueue> getQueueUsage({int? threshold}) async { + final String apiPath = '/health/queue/usage'; + + final Map<String, dynamic> apiParams = { + 'threshold': threshold, + + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.HealthQueue.fromMap(res.data); + + } + + /// Get usage dump queue + /// + /// Get the number of projects containing metrics that are waiting to be + /// processed in the Appwrite internal queue server. + Future<models.HealthQueue> getQueueUsageDump({int? threshold}) async { + final String apiPath = '/health/queue/usage-dump'; + + final Map<String, dynamic> apiParams = { + 'threshold': threshold, + + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.HealthQueue.fromMap(res.data); + + } + /// Get webhooks queue /// /// Get the number of webhooks that are waiting to be processed in the Appwrite @@ -379,6 +476,28 @@ class Health extends Service { } + /// Get storage + /// + /// Check the Appwrite storage device is up and connection is successful. + Future<models.HealthStatus> getStorage() async { + final String apiPath = '/health/storage'; + + final Map<String, dynamic> apiParams = { + + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.HealthStatus.fromMap(res.data); + + } + /// Get local storage /// /// Check the Appwrite local storage device is up and connection is successful. diff --git a/lib/services/messaging.dart b/lib/services/messaging.dart new file mode 100644 index 0000000..7067ded --- /dev/null +++ b/lib/services/messaging.dart @@ -0,0 +1,1252 @@ +part of dart_appwrite; + +/// The Messaging service allows you to send messages to any provider type +/// (SMTP, push notification, SMS, etc.). +class Messaging extends Service { + Messaging(super.client); + + /// List messages + /// + /// Get a list of all messages from the current Appwrite project. + Future<models.MessageList> listMessages({List<String>? queries, String? search}) async { + final String apiPath = '/messaging/messages'; + + final Map<String, dynamic> apiParams = { + 'queries': queries, +'search': search, + + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MessageList.fromMap(res.data); + + } + + /// Create email + /// + /// Create a new email message. + Future<models.Message> createEmail({required String messageId, required String subject, required String content, List<String>? topics, List<String>? users, List<String>? targets, List<String>? cc, List<String>? bcc, List<String>? attachments, bool? draft, bool? html, String? scheduledAt}) async { + final String apiPath = '/messaging/messages/email'; + + final Map<String, dynamic> apiParams = { + + 'messageId': messageId, +'subject': subject, +'content': content, +'topics': topics, +'users': users, +'targets': targets, +'cc': cc, +'bcc': bcc, +'attachments': attachments, +'draft': draft, +'html': html, +'scheduledAt': scheduledAt, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Message.fromMap(res.data); + + } + + /// Update email + /// + /// Update an email message by its unique ID. + /// + Future<models.Message> updateEmail({required String messageId, List<String>? topics, List<String>? users, List<String>? targets, String? subject, String? content, bool? draft, bool? html, List<String>? cc, List<String>? bcc, String? scheduledAt}) async { + final String apiPath = '/messaging/messages/email/{messageId}'.replaceAll('{messageId}', messageId); + + final Map<String, dynamic> apiParams = { + + 'topics': topics, +'users': users, +'targets': targets, +'subject': subject, +'content': content, +'draft': draft, +'html': html, +'cc': cc, +'bcc': bcc, +'scheduledAt': scheduledAt, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Message.fromMap(res.data); + + } + + /// Create push notification + /// + /// Create a new push notification. + Future<models.Message> createPush({required String messageId, required String title, required String body, List<String>? topics, List<String>? users, List<String>? targets, Map? data, String? action, String? image, String? icon, String? sound, String? color, String? tag, String? badge, bool? draft, String? scheduledAt}) async { + final String apiPath = '/messaging/messages/push'; + + final Map<String, dynamic> apiParams = { + + 'messageId': messageId, +'title': title, +'body': body, +'topics': topics, +'users': users, +'targets': targets, +'data': data, +'action': action, +'image': image, +'icon': icon, +'sound': sound, +'color': color, +'tag': tag, +'badge': badge, +'draft': draft, +'scheduledAt': scheduledAt, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Message.fromMap(res.data); + + } + + /// Update push notification + /// + /// Update a push notification by its unique ID. + /// + Future<models.Message> updatePush({required String messageId, List<String>? topics, List<String>? users, List<String>? targets, String? title, String? body, Map? data, String? action, String? image, String? icon, String? sound, String? color, String? tag, int? badge, bool? draft, String? scheduledAt}) async { + final String apiPath = '/messaging/messages/push/{messageId}'.replaceAll('{messageId}', messageId); + + final Map<String, dynamic> apiParams = { + + 'topics': topics, +'users': users, +'targets': targets, +'title': title, +'body': body, +'data': data, +'action': action, +'image': image, +'icon': icon, +'sound': sound, +'color': color, +'tag': tag, +'badge': badge, +'draft': draft, +'scheduledAt': scheduledAt, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Message.fromMap(res.data); + + } + + /// Create SMS + /// + /// Create a new SMS message. + Future<models.Message> createSms({required String messageId, required String content, List<String>? topics, List<String>? users, List<String>? targets, bool? draft, String? scheduledAt}) async { + final String apiPath = '/messaging/messages/sms'; + + final Map<String, dynamic> apiParams = { + + 'messageId': messageId, +'content': content, +'topics': topics, +'users': users, +'targets': targets, +'draft': draft, +'scheduledAt': scheduledAt, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Message.fromMap(res.data); + + } + + /// Update SMS + /// + /// Update an email message by its unique ID. + /// + Future<models.Message> updateSms({required String messageId, List<String>? topics, List<String>? users, List<String>? targets, String? content, bool? draft, String? scheduledAt}) async { + final String apiPath = '/messaging/messages/sms/{messageId}'.replaceAll('{messageId}', messageId); + + final Map<String, dynamic> apiParams = { + + 'topics': topics, +'users': users, +'targets': targets, +'content': content, +'draft': draft, +'scheduledAt': scheduledAt, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Message.fromMap(res.data); + + } + + /// Get message + /// + /// Get a message by its unique ID. + /// + Future<models.Message> getMessage({required String messageId}) async { + final String apiPath = '/messaging/messages/{messageId}'.replaceAll('{messageId}', messageId); + + final Map<String, dynamic> apiParams = { + + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Message.fromMap(res.data); + + } + + /// Delete message + /// + /// Delete a message. If the message is not a draft or scheduled, but has been + /// sent, this will not recall the message. + Future delete({required String messageId}) async { + final String apiPath = '/messaging/messages/{messageId}'.replaceAll('{messageId}', messageId); + + final Map<String, dynamic> apiParams = { + + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; + + } + + /// List message logs + /// + /// Get the message activity logs listed by its unique ID. + Future<models.LogList> listMessageLogs({required String messageId, List<String>? queries}) async { + final String apiPath = '/messaging/messages/{messageId}/logs'.replaceAll('{messageId}', messageId); + + final Map<String, dynamic> apiParams = { + 'queries': queries, + + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.LogList.fromMap(res.data); + + } + + /// List message targets + /// + /// Get a list of the targets associated with a message. + Future<models.TargetList> listTargets({required String messageId, List<String>? queries}) async { + final String apiPath = '/messaging/messages/{messageId}/targets'.replaceAll('{messageId}', messageId); + + final Map<String, dynamic> apiParams = { + 'queries': queries, + + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.TargetList.fromMap(res.data); + + } + + /// List providers + /// + /// Get a list of all providers from the current Appwrite project. + Future<models.ProviderList> listProviders({List<String>? queries, String? search}) async { + final String apiPath = '/messaging/providers'; + + final Map<String, dynamic> apiParams = { + 'queries': queries, +'search': search, + + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.ProviderList.fromMap(res.data); + + } + + /// Create APNS provider + /// + /// Create a new Apple Push Notification service provider. + Future<models.Provider> createApnsProvider({required String providerId, required String name, String? authKey, String? authKeyId, String? teamId, String? bundleId, bool? sandbox, bool? enabled}) async { + final String apiPath = '/messaging/providers/apns'; + + final Map<String, dynamic> apiParams = { + + 'providerId': providerId, +'name': name, +'authKey': authKey, +'authKeyId': authKeyId, +'teamId': teamId, +'bundleId': bundleId, +'sandbox': sandbox, +'enabled': enabled, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Provider.fromMap(res.data); + + } + + /// Update APNS provider + /// + /// Update a Apple Push Notification service provider by its unique ID. + Future<models.Provider> updateApnsProvider({required String providerId, String? name, bool? enabled, String? authKey, String? authKeyId, String? teamId, String? bundleId, bool? sandbox}) async { + final String apiPath = '/messaging/providers/apns/{providerId}'.replaceAll('{providerId}', providerId); + + final Map<String, dynamic> apiParams = { + + 'name': name, +'enabled': enabled, +'authKey': authKey, +'authKeyId': authKeyId, +'teamId': teamId, +'bundleId': bundleId, +'sandbox': sandbox, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Provider.fromMap(res.data); + + } + + /// Create FCM provider + /// + /// Create a new Firebase Cloud Messaging provider. + Future<models.Provider> createFcmProvider({required String providerId, required String name, Map? serviceAccountJSON, bool? enabled}) async { + final String apiPath = '/messaging/providers/fcm'; + + final Map<String, dynamic> apiParams = { + + 'providerId': providerId, +'name': name, +'serviceAccountJSON': serviceAccountJSON, +'enabled': enabled, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Provider.fromMap(res.data); + + } + + /// Update FCM provider + /// + /// Update a Firebase Cloud Messaging provider by its unique ID. + Future<models.Provider> updateFcmProvider({required String providerId, String? name, bool? enabled, Map? serviceAccountJSON}) async { + final String apiPath = '/messaging/providers/fcm/{providerId}'.replaceAll('{providerId}', providerId); + + final Map<String, dynamic> apiParams = { + + 'name': name, +'enabled': enabled, +'serviceAccountJSON': serviceAccountJSON, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Provider.fromMap(res.data); + + } + + /// Create Mailgun provider + /// + /// Create a new Mailgun provider. + Future<models.Provider> createMailgunProvider({required String providerId, required String name, String? apiKey, String? domain, bool? isEuRegion, String? fromName, String? fromEmail, String? replyToName, String? replyToEmail, bool? enabled}) async { + final String apiPath = '/messaging/providers/mailgun'; + + final Map<String, dynamic> apiParams = { + + 'providerId': providerId, +'name': name, +'apiKey': apiKey, +'domain': domain, +'isEuRegion': isEuRegion, +'fromName': fromName, +'fromEmail': fromEmail, +'replyToName': replyToName, +'replyToEmail': replyToEmail, +'enabled': enabled, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Provider.fromMap(res.data); + + } + + /// Update Mailgun provider + /// + /// Update a Mailgun provider by its unique ID. + Future<models.Provider> updateMailgunProvider({required String providerId, String? name, String? apiKey, String? domain, bool? isEuRegion, bool? enabled, String? fromName, String? fromEmail, String? replyToName, String? replyToEmail}) async { + final String apiPath = '/messaging/providers/mailgun/{providerId}'.replaceAll('{providerId}', providerId); + + final Map<String, dynamic> apiParams = { + + 'name': name, +'apiKey': apiKey, +'domain': domain, +'isEuRegion': isEuRegion, +'enabled': enabled, +'fromName': fromName, +'fromEmail': fromEmail, +'replyToName': replyToName, +'replyToEmail': replyToEmail, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Provider.fromMap(res.data); + + } + + /// Create Msg91 provider + /// + /// Create a new MSG91 provider. + Future<models.Provider> createMsg91Provider({required String providerId, required String name, String? from, String? senderId, String? authKey, bool? enabled}) async { + final String apiPath = '/messaging/providers/msg91'; + + final Map<String, dynamic> apiParams = { + + 'providerId': providerId, +'name': name, +'from': from, +'senderId': senderId, +'authKey': authKey, +'enabled': enabled, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Provider.fromMap(res.data); + + } + + /// Update Msg91 provider + /// + /// Update a MSG91 provider by its unique ID. + Future<models.Provider> updateMsg91Provider({required String providerId, String? name, bool? enabled, String? senderId, String? authKey, String? from}) async { + final String apiPath = '/messaging/providers/msg91/{providerId}'.replaceAll('{providerId}', providerId); + + final Map<String, dynamic> apiParams = { + + 'name': name, +'enabled': enabled, +'senderId': senderId, +'authKey': authKey, +'from': from, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Provider.fromMap(res.data); + + } + + /// Create Sendgrid provider + /// + /// Create a new Sendgrid provider. + Future<models.Provider> createSendgridProvider({required String providerId, required String name, String? apiKey, String? fromName, String? fromEmail, String? replyToName, String? replyToEmail, bool? enabled}) async { + final String apiPath = '/messaging/providers/sendgrid'; + + final Map<String, dynamic> apiParams = { + + 'providerId': providerId, +'name': name, +'apiKey': apiKey, +'fromName': fromName, +'fromEmail': fromEmail, +'replyToName': replyToName, +'replyToEmail': replyToEmail, +'enabled': enabled, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Provider.fromMap(res.data); + + } + + /// Update Sendgrid provider + /// + /// Update a Sendgrid provider by its unique ID. + Future<models.Provider> updateSendgridProvider({required String providerId, String? name, bool? enabled, String? apiKey, String? fromName, String? fromEmail, String? replyToName, String? replyToEmail}) async { + final String apiPath = '/messaging/providers/sendgrid/{providerId}'.replaceAll('{providerId}', providerId); + + final Map<String, dynamic> apiParams = { + + 'name': name, +'enabled': enabled, +'apiKey': apiKey, +'fromName': fromName, +'fromEmail': fromEmail, +'replyToName': replyToName, +'replyToEmail': replyToEmail, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Provider.fromMap(res.data); + + } + + /// Create SMTP provider + /// + /// Create a new SMTP provider. + Future<models.Provider> createSmtpProvider({required String providerId, required String name, required String host, int? port, String? username, String? password, enums.SmtpEncryption? encryption, bool? autoTLS, String? mailer, String? fromName, String? fromEmail, String? replyToName, String? replyToEmail, bool? enabled}) async { + final String apiPath = '/messaging/providers/smtp'; + + final Map<String, dynamic> apiParams = { + + 'providerId': providerId, +'name': name, +'host': host, +'port': port, +'username': username, +'password': password, +'encryption': encryption, +'autoTLS': autoTLS, +'mailer': mailer, +'fromName': fromName, +'fromEmail': fromEmail, +'replyToName': replyToName, +'replyToEmail': replyToEmail, +'enabled': enabled, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Provider.fromMap(res.data); + + } + + /// Update SMTP provider + /// + /// Update a SMTP provider by its unique ID. + Future<models.Provider> updateSmtpProvider({required String providerId, String? name, String? host, int? port, String? username, String? password, enums.SmtpEncryption? encryption, bool? autoTLS, String? mailer, String? fromName, String? fromEmail, String? replyToName, String? replyToEmail, bool? enabled}) async { + final String apiPath = '/messaging/providers/smtp/{providerId}'.replaceAll('{providerId}', providerId); + + final Map<String, dynamic> apiParams = { + + 'name': name, +'host': host, +'port': port, +'username': username, +'password': password, +'encryption': encryption, +'autoTLS': autoTLS, +'mailer': mailer, +'fromName': fromName, +'fromEmail': fromEmail, +'replyToName': replyToName, +'replyToEmail': replyToEmail, +'enabled': enabled, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Provider.fromMap(res.data); + + } + + /// Create Telesign provider + /// + /// Create a new Telesign provider. + Future<models.Provider> createTelesignProvider({required String providerId, required String name, String? from, String? customerId, String? apiKey, bool? enabled}) async { + final String apiPath = '/messaging/providers/telesign'; + + final Map<String, dynamic> apiParams = { + + 'providerId': providerId, +'name': name, +'from': from, +'customerId': customerId, +'apiKey': apiKey, +'enabled': enabled, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Provider.fromMap(res.data); + + } + + /// Update Telesign provider + /// + /// Update a Telesign provider by its unique ID. + Future<models.Provider> updateTelesignProvider({required String providerId, String? name, bool? enabled, String? customerId, String? apiKey, String? from}) async { + final String apiPath = '/messaging/providers/telesign/{providerId}'.replaceAll('{providerId}', providerId); + + final Map<String, dynamic> apiParams = { + + 'name': name, +'enabled': enabled, +'customerId': customerId, +'apiKey': apiKey, +'from': from, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Provider.fromMap(res.data); + + } + + /// Create Textmagic provider + /// + /// Create a new Textmagic provider. + Future<models.Provider> createTextmagicProvider({required String providerId, required String name, String? from, String? username, String? apiKey, bool? enabled}) async { + final String apiPath = '/messaging/providers/textmagic'; + + final Map<String, dynamic> apiParams = { + + 'providerId': providerId, +'name': name, +'from': from, +'username': username, +'apiKey': apiKey, +'enabled': enabled, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Provider.fromMap(res.data); + + } + + /// Update Textmagic provider + /// + /// Update a Textmagic provider by its unique ID. + Future<models.Provider> updateTextmagicProvider({required String providerId, String? name, bool? enabled, String? username, String? apiKey, String? from}) async { + final String apiPath = '/messaging/providers/textmagic/{providerId}'.replaceAll('{providerId}', providerId); + + final Map<String, dynamic> apiParams = { + + 'name': name, +'enabled': enabled, +'username': username, +'apiKey': apiKey, +'from': from, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Provider.fromMap(res.data); + + } + + /// Create Twilio provider + /// + /// Create a new Twilio provider. + Future<models.Provider> createTwilioProvider({required String providerId, required String name, String? from, String? accountSid, String? authToken, bool? enabled}) async { + final String apiPath = '/messaging/providers/twilio'; + + final Map<String, dynamic> apiParams = { + + 'providerId': providerId, +'name': name, +'from': from, +'accountSid': accountSid, +'authToken': authToken, +'enabled': enabled, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Provider.fromMap(res.data); + + } + + /// Update Twilio provider + /// + /// Update a Twilio provider by its unique ID. + Future<models.Provider> updateTwilioProvider({required String providerId, String? name, bool? enabled, String? accountSid, String? authToken, String? from}) async { + final String apiPath = '/messaging/providers/twilio/{providerId}'.replaceAll('{providerId}', providerId); + + final Map<String, dynamic> apiParams = { + + 'name': name, +'enabled': enabled, +'accountSid': accountSid, +'authToken': authToken, +'from': from, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Provider.fromMap(res.data); + + } + + /// Create Vonage provider + /// + /// Create a new Vonage provider. + Future<models.Provider> createVonageProvider({required String providerId, required String name, String? from, String? apiKey, String? apiSecret, bool? enabled}) async { + final String apiPath = '/messaging/providers/vonage'; + + final Map<String, dynamic> apiParams = { + + 'providerId': providerId, +'name': name, +'from': from, +'apiKey': apiKey, +'apiSecret': apiSecret, +'enabled': enabled, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Provider.fromMap(res.data); + + } + + /// Update Vonage provider + /// + /// Update a Vonage provider by its unique ID. + Future<models.Provider> updateVonageProvider({required String providerId, String? name, bool? enabled, String? apiKey, String? apiSecret, String? from}) async { + final String apiPath = '/messaging/providers/vonage/{providerId}'.replaceAll('{providerId}', providerId); + + final Map<String, dynamic> apiParams = { + + 'name': name, +'enabled': enabled, +'apiKey': apiKey, +'apiSecret': apiSecret, +'from': from, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Provider.fromMap(res.data); + + } + + /// Get provider + /// + /// Get a provider by its unique ID. + /// + Future<models.Provider> getProvider({required String providerId}) async { + final String apiPath = '/messaging/providers/{providerId}'.replaceAll('{providerId}', providerId); + + final Map<String, dynamic> apiParams = { + + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Provider.fromMap(res.data); + + } + + /// Delete provider + /// + /// Delete a provider by its unique ID. + Future deleteProvider({required String providerId}) async { + final String apiPath = '/messaging/providers/{providerId}'.replaceAll('{providerId}', providerId); + + final Map<String, dynamic> apiParams = { + + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; + + } + + /// List provider logs + /// + /// Get the provider activity logs listed by its unique ID. + Future<models.LogList> listProviderLogs({required String providerId, List<String>? queries}) async { + final String apiPath = '/messaging/providers/{providerId}/logs'.replaceAll('{providerId}', providerId); + + final Map<String, dynamic> apiParams = { + 'queries': queries, + + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.LogList.fromMap(res.data); + + } + + /// List subscriber logs + /// + /// Get the subscriber activity logs listed by its unique ID. + Future<models.LogList> listSubscriberLogs({required String subscriberId, List<String>? queries}) async { + final String apiPath = '/messaging/subscribers/{subscriberId}/logs'.replaceAll('{subscriberId}', subscriberId); + + final Map<String, dynamic> apiParams = { + 'queries': queries, + + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.LogList.fromMap(res.data); + + } + + /// List topics + /// + /// Get a list of all topics from the current Appwrite project. + Future<models.TopicList> listTopics({List<String>? queries, String? search}) async { + final String apiPath = '/messaging/topics'; + + final Map<String, dynamic> apiParams = { + 'queries': queries, +'search': search, + + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.TopicList.fromMap(res.data); + + } + + /// Create topic + /// + /// Create a new topic. + Future<models.Topic> createTopic({required String topicId, required String name, List<String>? subscribe}) async { + final String apiPath = '/messaging/topics'; + + final Map<String, dynamic> apiParams = { + + 'topicId': topicId, +'name': name, +'subscribe': subscribe, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Topic.fromMap(res.data); + + } + + /// Get topic + /// + /// Get a topic by its unique ID. + /// + Future<models.Topic> getTopic({required String topicId}) async { + final String apiPath = '/messaging/topics/{topicId}'.replaceAll('{topicId}', topicId); + + final Map<String, dynamic> apiParams = { + + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Topic.fromMap(res.data); + + } + + /// Update topic + /// + /// Update a topic by its unique ID. + /// + Future<models.Topic> updateTopic({required String topicId, String? name, List<String>? subscribe}) async { + final String apiPath = '/messaging/topics/{topicId}'.replaceAll('{topicId}', topicId); + + final Map<String, dynamic> apiParams = { + + 'name': name, +'subscribe': subscribe, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Topic.fromMap(res.data); + + } + + /// Delete topic + /// + /// Delete a topic by its unique ID. + Future deleteTopic({required String topicId}) async { + final String apiPath = '/messaging/topics/{topicId}'.replaceAll('{topicId}', topicId); + + final Map<String, dynamic> apiParams = { + + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; + + } + + /// List topic logs + /// + /// Get the topic activity logs listed by its unique ID. + Future<models.LogList> listTopicLogs({required String topicId, List<String>? queries}) async { + final String apiPath = '/messaging/topics/{topicId}/logs'.replaceAll('{topicId}', topicId); + + final Map<String, dynamic> apiParams = { + 'queries': queries, + + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.LogList.fromMap(res.data); + + } + + /// List subscribers + /// + /// Get a list of all subscribers from the current Appwrite project. + Future<models.SubscriberList> listSubscribers({required String topicId, List<String>? queries, String? search}) async { + final String apiPath = '/messaging/topics/{topicId}/subscribers'.replaceAll('{topicId}', topicId); + + final Map<String, dynamic> apiParams = { + 'queries': queries, +'search': search, + + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.SubscriberList.fromMap(res.data); + + } + + /// Create subscriber + /// + /// Create a new subscriber. + Future<models.Subscriber> createSubscriber({required String topicId, required String subscriberId, required String targetId}) async { + final String apiPath = '/messaging/topics/{topicId}/subscribers'.replaceAll('{topicId}', topicId); + + final Map<String, dynamic> apiParams = { + + 'subscriberId': subscriberId, +'targetId': targetId, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Subscriber.fromMap(res.data); + + } + + /// Get subscriber + /// + /// Get a subscriber by its unique ID. + /// + Future<models.Subscriber> getSubscriber({required String topicId, required String subscriberId}) async { + final String apiPath = '/messaging/topics/{topicId}/subscribers/{subscriberId}'.replaceAll('{topicId}', topicId).replaceAll('{subscriberId}', subscriberId); + + final Map<String, dynamic> apiParams = { + + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Subscriber.fromMap(res.data); + + } + + /// Delete subscriber + /// + /// Delete a subscriber by its unique ID. + Future deleteSubscriber({required String topicId, required String subscriberId}) async { + final String apiPath = '/messaging/topics/{topicId}/subscribers/{subscriberId}'.replaceAll('{topicId}', topicId).replaceAll('{subscriberId}', subscriberId); + + final Map<String, dynamic> apiParams = { + + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; + + } +} \ No newline at end of file diff --git a/lib/services/storage.dart b/lib/services/storage.dart index c7ffda5..018d559 100644 --- a/lib/services/storage.dart +++ b/lib/services/storage.dart @@ -32,7 +32,7 @@ class Storage extends Service { /// Create bucket /// /// Create a new storage bucket. - Future<models.Bucket> createBucket({required String bucketId, required String name, List<String>? permissions, bool? fileSecurity, bool? enabled, int? maximumFileSize, List<String>? allowedFileExtensions, String? compression, bool? encryption, bool? antivirus}) async { + Future<models.Bucket> createBucket({required String bucketId, required String name, List<String>? permissions, bool? fileSecurity, bool? enabled, int? maximumFileSize, List<String>? allowedFileExtensions, enums.Compression? compression, bool? encryption, bool? antivirus}) async { final String apiPath = '/storage/buckets'; final Map<String, dynamic> apiParams = { @@ -87,7 +87,7 @@ class Storage extends Service { /// Update bucket /// /// Update a storage bucket by its unique ID. - Future<models.Bucket> updateBucket({required String bucketId, required String name, List<String>? permissions, bool? fileSecurity, bool? enabled, int? maximumFileSize, List<String>? allowedFileExtensions, String? compression, bool? encryption, bool? antivirus}) async { + Future<models.Bucket> updateBucket({required String bucketId, required String name, List<String>? permissions, bool? fileSecurity, bool? enabled, int? maximumFileSize, List<String>? allowedFileExtensions, enums.Compression? compression, bool? encryption, bool? antivirus}) async { final String apiPath = '/storage/buckets/{bucketId}'.replaceAll('{bucketId}', bucketId); final Map<String, dynamic> apiParams = { @@ -297,7 +297,7 @@ class Storage extends Service { 'project': client.config['project'], - 'key': client.config['key'], + 'session': client.config['session'], }; final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); @@ -311,7 +311,7 @@ class Storage extends Service { /// and spreadsheets, will return the file icon image. You can also pass query /// string arguments for cutting and resizing your preview image. Preview is /// supported only for image files smaller than 10MB. - Future<Uint8List> getFilePreview({required String bucketId, 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}) async { + Future<Uint8List> getFilePreview({required String bucketId, required String fileId, int? width, int? height, enums.ImageGravity? gravity, int? quality, int? borderWidth, String? borderColor, int? borderRadius, double? opacity, int? rotation, String? background, enums.ImageFormat? output}) async { final String apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); final Map<String, dynamic> params = { @@ -329,7 +329,7 @@ class Storage extends Service { 'project': client.config['project'], - 'key': client.config['key'], + 'session': client.config['session'], }; final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); @@ -348,7 +348,7 @@ class Storage extends Service { 'project': client.config['project'], - 'key': client.config['key'], + 'session': client.config['session'], }; final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes); diff --git a/lib/services/users.dart b/lib/services/users.dart index 397b167..566fd45 100644 --- a/lib/services/users.dart +++ b/lib/services/users.dart @@ -117,7 +117,7 @@ class Users extends Service { /// List Identities /// /// Get identities for all users. - Future<models.IdentityList> listIdentities({String? queries, String? search}) async { + Future<models.IdentityList> listIdentities({List<String>? queries, String? search}) async { final String apiPath = '/users/identities'; final Map<String, dynamic> apiParams = { @@ -138,7 +138,7 @@ class Users extends Service { } - /// Delete Identity + /// Delete identity /// /// Delete an identity by its unique ID. Future deleteIdentity({required String identityId}) async { @@ -291,7 +291,7 @@ class Users extends Service { /// [SHA](https://en.wikipedia.org/wiki/Secure_Hash_Algorithm) algorithm. Use /// the [POST /users](https://appwrite.io/docs/server/users#usersCreate) /// endpoint to create users with a plain text password. - Future<models.User> createSHAUser({required String userId, required String email, required String password, String? passwordVersion, String? name}) async { + Future<models.User> createSHAUser({required String userId, required String email, required String password, enums.PasswordHash? passwordVersion, String? name}) async { final String apiPath = '/users/sha'; final Map<String, dynamic> apiParams = { @@ -460,6 +460,148 @@ class Users extends Service { } + /// Update MFA + /// + /// Enable or disable MFA on a user account. + Future<models.User> updateMfa({required String userId, required bool mfa}) async { + final String apiPath = '/users/{userId}/mfa'.replaceAll('{userId}', userId); + + final Map<String, dynamic> apiParams = { + + 'mfa': mfa, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.User.fromMap(res.data); + + } + + /// Delete Authenticator + /// + /// Delete an authenticator app. + Future<models.User> deleteMfaAuthenticator({required String userId, required enums.AuthenticatorType type}) async { + final String apiPath = '/users/{userId}/mfa/authenticators/{type}'.replaceAll('{userId}', userId).replaceAll('{type}', type.value); + + final Map<String, dynamic> apiParams = { + + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.User.fromMap(res.data); + + } + + /// List Factors + /// + /// List the factors available on the account to be used as a MFA challange. + Future<models.MfaFactors> listMfaFactors({required String userId}) async { + final String apiPath = '/users/{userId}/mfa/factors'.replaceAll('{userId}', userId); + + final Map<String, dynamic> apiParams = { + + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaFactors.fromMap(res.data); + + } + + /// Get MFA Recovery Codes + /// + /// Get recovery codes that can be used as backup for MFA flow by User ID. + /// Before getting codes, they must be generated using + /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) + /// method. + Future<models.MfaRecoveryCodes> getMfaRecoveryCodes({required String userId}) async { + final String apiPath = '/users/{userId}/mfa/recovery-codes'.replaceAll('{userId}', userId); + + final Map<String, dynamic> apiParams = { + + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaRecoveryCodes.fromMap(res.data); + + } + + /// Regenerate MFA Recovery Codes + /// + /// Regenerate recovery codes that can be used as backup for MFA flow by User + /// ID. Before regenerating codes, they must be first generated using + /// [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) + /// method. + Future<models.MfaRecoveryCodes> updateMfaRecoveryCodes({required String userId}) async { + final String apiPath = '/users/{userId}/mfa/recovery-codes'.replaceAll('{userId}', userId); + + final Map<String, dynamic> apiParams = { + + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.put, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaRecoveryCodes.fromMap(res.data); + + } + + /// Create MFA Recovery Codes + /// + /// Generate recovery codes used as backup for MFA flow for User ID. Recovery + /// codes can be used as a MFA verification type in + /// [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) + /// method by client SDK. + Future<models.MfaRecoveryCodes> createMfaRecoveryCodes({required String userId}) async { + final String apiPath = '/users/{userId}/mfa/recovery-codes'.replaceAll('{userId}', userId); + + final Map<String, dynamic> apiParams = { + + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.MfaRecoveryCodes.fromMap(res.data); + + } + /// Update name /// /// Update the user name by its unique ID. @@ -598,6 +740,33 @@ class Users extends Service { } + /// Create session + /// + /// Creates a session for a user. Returns an immediately usable session object. + /// + /// If you want to generate a token for a custom authentication flow, use the + /// [POST + /// /users/{userId}/tokens](https://appwrite.io/docs/server/users#createToken) + /// endpoint. + Future<models.Session> createSession({required String userId}) async { + final String apiPath = '/users/{userId}/sessions'.replaceAll('{userId}', userId); + + final Map<String, dynamic> apiParams = { + + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Session.fromMap(res.data); + + } + /// Delete user sessions /// /// Delete all user's sessions by using the user's unique ID. @@ -666,6 +835,153 @@ class Users extends Service { } + /// List User Targets + /// + /// List the messaging targets that are associated with a user. + Future<models.TargetList> listTargets({required String userId, List<String>? queries}) async { + final String apiPath = '/users/{userId}/targets'.replaceAll('{userId}', userId); + + final Map<String, dynamic> apiParams = { + 'queries': queries, + + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.TargetList.fromMap(res.data); + + } + + /// Create User Target + /// + /// Create a messaging target. + Future<models.Target> createTarget({required String userId, required String targetId, required enums.MessagingProviderType providerType, required String identifier, String? providerId, String? name}) async { + final String apiPath = '/users/{userId}/targets'.replaceAll('{userId}', userId); + + final Map<String, dynamic> apiParams = { + + 'targetId': targetId, +'providerType': providerType, +'identifier': identifier, +'providerId': providerId, +'name': name, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Target.fromMap(res.data); + + } + + /// Get User Target + /// + /// Get a user's push notification target by ID. + Future<models.Target> getTarget({required String userId, required String targetId}) async { + final String apiPath = '/users/{userId}/targets/{targetId}'.replaceAll('{userId}', userId).replaceAll('{targetId}', targetId); + + final Map<String, dynamic> apiParams = { + + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Target.fromMap(res.data); + + } + + /// Update User target + /// + /// Update a messaging target. + Future<models.Target> updateTarget({required String userId, required String targetId, String? identifier, String? providerId, String? name}) async { + final String apiPath = '/users/{userId}/targets/{targetId}'.replaceAll('{userId}', userId).replaceAll('{targetId}', targetId); + + final Map<String, dynamic> apiParams = { + + 'identifier': identifier, +'providerId': providerId, +'name': name, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.patch, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Target.fromMap(res.data); + + } + + /// Delete user target + /// + /// Delete a messaging target. + Future deleteTarget({required String userId, required String targetId}) async { + final String apiPath = '/users/{userId}/targets/{targetId}'.replaceAll('{userId}', userId).replaceAll('{targetId}', targetId); + + final Map<String, dynamic> apiParams = { + + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.delete, path: apiPath, params: apiParams, headers: apiHeaders); + + return res.data; + + } + + /// Create token + /// + /// Returns a token with a secret key for creating a session. If the provided + /// user ID has not be registered, a new user will be created. Use the returned + /// user ID and secret and submit a request to the [PUT + /// /account/sessions/custom](https://appwrite.io/docs/references/cloud/client-web/account#updateCustomSession) + /// endpoint to complete the login process. + Future<models.Token> createToken({required String userId, int? length, int? expire}) async { + final String apiPath = '/users/{userId}/tokens'.replaceAll('{userId}', userId); + + final Map<String, dynamic> apiParams = { + + 'length': length, +'expire': expire, + + }; + + final Map<String, String> apiHeaders = { + 'content-type': 'application/json', + + }; + + final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders); + + return models.Token.fromMap(res.data); + + } + /// Update email verification /// /// Update the user email verification status by its unique ID. diff --git a/lib/src/client.dart b/lib/src/client.dart index 474654d..8dee242 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -19,10 +19,13 @@ abstract class Client { /// Initializes a [Client]. factory Client( - {String endPoint = 'https://HOSTNAME/v1', + {String endPoint = 'https://cloud.appwrite.io/v1', bool selfSigned = false}) => createClient(endPoint: endPoint, selfSigned: selfSigned); + /// Handle OAuth2 session creation. + Future<String?> webAuth(Uri url); + /// Set self signed to [status]. /// /// If self signed is true, [Client] will ignore invalid certificates. @@ -51,6 +54,16 @@ abstract class Client { /// Set Locale Client setLocale(value); + /// Set Session + /// + /// The user session to authenticate with + Client setSession(value); + + /// Set ForwardedUserAgent + /// + /// The user agent string of the client that made the request + Client setForwardedUserAgent(value); + /// Add headers that should be sent with all API calls. Client addHeader(String key, String value); diff --git a/lib/src/client_base.dart b/lib/src/client_base.dart index 8cfb3d8..21992eb 100644 --- a/lib/src/client_base.dart +++ b/lib/src/client_base.dart @@ -14,6 +14,12 @@ abstract class ClientBase implements Client { ClientBase setJWT(value); @override ClientBase setLocale(value); + /// The user session to authenticate with + @override + ClientBase setSession(value); + /// The user agent string of the client that made the request + @override + ClientBase setForwardedUserAgent(value); @override ClientBase setSelfSigned({bool status = true}); diff --git a/lib/src/client_browser.dart b/lib/src/client_browser.dart index 0bd487c..01c7384 100644 --- a/lib/src/client_browser.dart +++ b/lib/src/client_browser.dart @@ -24,7 +24,7 @@ class ClientBrowser extends ClientBase with ClientMixin { late BrowserClient _httpClient; ClientBrowser({ - String endPoint = 'https://HOSTNAME/v1', + String endPoint = 'https://cloud.appwrite.io/v1', bool selfSigned = false, }) : _endPoint = endPoint { _httpClient = BrowserClient(); @@ -33,8 +33,8 @@ class ClientBrowser extends ClientBase with ClientMixin { 'x-sdk-name': 'Dart', 'x-sdk-platform': 'server', 'x-sdk-language': 'dart', - 'x-sdk-version': '10.1.1', - 'X-Appwrite-Response-Format' : '1.4.0', + 'x-sdk-version': '11.0.0', + 'X-Appwrite-Response-Format' : '1.5.0', }; config = {}; @@ -73,6 +73,20 @@ class ClientBrowser extends ClientBase with ClientMixin { addHeader('X-Appwrite-Locale', value); return this; } + /// The user session to authenticate with + @override + ClientBrowser setSession(value) { + config['session'] = value; + addHeader('X-Appwrite-Session', value); + return this; + } + /// The user agent string of the client that made the request + @override + ClientBrowser setForwardedUserAgent(value) { + config['forwardedUserAgent'] = value; + addHeader('X-Forwarded-User-Agent', value); + return this; + } @override ClientBrowser setSelfSigned({bool status = true}) { @@ -91,6 +105,14 @@ class ClientBrowser extends ClientBase with ClientMixin { return this; } + @override + Future<String?> webAuth(Uri url) async { + final request = http.Request('GET', url); + request.followRedirects = false; + final response = await _httpClient.send(request); + return response.headers['location']; + } + @override Future<Response> chunkedUpload({ required String path, diff --git a/lib/src/client_io.dart b/lib/src/client_io.dart index 05583fb..5d37ce3 100644 --- a/lib/src/client_io.dart +++ b/lib/src/client_io.dart @@ -29,7 +29,7 @@ class ClientIO extends ClientBase with ClientMixin { late HttpClient _nativeClient; ClientIO({ - String endPoint = 'https://HOSTNAME/v1', + String endPoint = 'https://cloud.appwrite.io/v1', bool selfSigned = false, }) : _endPoint = endPoint { _nativeClient = HttpClient() @@ -42,9 +42,9 @@ class ClientIO extends ClientBase with ClientMixin { 'x-sdk-name': 'Dart', 'x-sdk-platform': 'server', 'x-sdk-language': 'dart', - 'x-sdk-version': '10.1.1', - 'user-agent' : 'AppwriteDartSDK/10.1.1 (${Platform.operatingSystem}; ${Platform.operatingSystemVersion})', - 'X-Appwrite-Response-Format' : '1.4.0', + 'x-sdk-version': '11.0.0', + 'user-agent' : 'AppwriteDartSDK/11.0.0 (${Platform.operatingSystem}; ${Platform.operatingSystemVersion})', + 'X-Appwrite-Response-Format' : '1.5.0', }; config = {}; @@ -83,6 +83,20 @@ class ClientIO extends ClientBase with ClientMixin { addHeader('X-Appwrite-Locale', value); return this; } + /// The user session to authenticate with + @override + ClientIO setSession(value) { + config['session'] = value; + addHeader('X-Appwrite-Session', value); + return this; + } + /// The user agent string of the client that made the request + @override + ClientIO setForwardedUserAgent(value) { + config['forwardedUserAgent'] = value; + addHeader('X-Forwarded-User-Agent', value); + return this; + } @override ClientIO setSelfSigned({bool status = true}) { @@ -199,6 +213,14 @@ class ClientIO extends ClientBase with ClientMixin { return res; } + @override + Future<String?> webAuth(Uri url) async { + final request = http.Request('GET', url); + request.followRedirects = false; + final response = await _httpClient.send(request); + return response.headers['location']; + } + @override Future<Response> call( HttpMethod method, { diff --git a/lib/src/enums/authentication_factor.dart b/lib/src/enums/authentication_factor.dart new file mode 100644 index 0000000..53a69d0 --- /dev/null +++ b/lib/src/enums/authentication_factor.dart @@ -0,0 +1,16 @@ +part of dart_appwrite.enums; + +enum AuthenticationFactor { + email(value: 'email'), + phone(value: 'phone'), + totp(value: 'totp'), + recoverycode(value: 'recoverycode'); + + const AuthenticationFactor({ + required this.value + }); + + final String value; + + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/authenticator_type.dart b/lib/src/enums/authenticator_type.dart new file mode 100644 index 0000000..034ee05 --- /dev/null +++ b/lib/src/enums/authenticator_type.dart @@ -0,0 +1,13 @@ +part of dart_appwrite.enums; + +enum AuthenticatorType { + totp(value: 'totp'); + + const AuthenticatorType({ + required this.value + }); + + final String value; + + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/browser.dart b/lib/src/enums/browser.dart new file mode 100644 index 0000000..92d8c5a --- /dev/null +++ b/lib/src/enums/browser.dart @@ -0,0 +1,26 @@ +part of dart_appwrite.enums; + +enum Browser { + avantBrowser(value: 'aa'), + androidWebViewBeta(value: 'an'), + googleChrome(value: 'ch'), + googleChromeIOS(value: 'ci'), + googleChromeMobile(value: 'cm'), + chromium(value: 'cr'), + mozillaFirefox(value: 'ff'), + safari(value: 'sf'), + mobileSafari(value: 'mf'), + microsoftEdge(value: 'ps'), + microsoftEdgeIOS(value: 'oi'), + operaMini(value: 'om'), + opera(value: 'op'), + operaNext(value: 'on'); + + const Browser({ + required this.value + }); + + final String value; + + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/compression.dart b/lib/src/enums/compression.dart new file mode 100644 index 0000000..2f51015 --- /dev/null +++ b/lib/src/enums/compression.dart @@ -0,0 +1,15 @@ +part of dart_appwrite.enums; + +enum Compression { + none(value: 'none'), + gzip(value: 'gzip'), + zstd(value: 'zstd'); + + const Compression({ + required this.value + }); + + final String value; + + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/credit_card.dart b/lib/src/enums/credit_card.dart new file mode 100644 index 0000000..9f3523d --- /dev/null +++ b/lib/src/enums/credit_card.dart @@ -0,0 +1,28 @@ +part of dart_appwrite.enums; + +enum CreditCard { + americanExpress(value: 'amex'), + argencard(value: 'argencard'), + cabal(value: 'cabal'), + consosud(value: 'censosud'), + dinersClub(value: 'diners'), + discover(value: 'discover'), + elo(value: 'elo'), + hipercard(value: 'hipercard'), + jCB(value: 'jcb'), + mastercard(value: 'mastercard'), + naranja(value: 'naranja'), + tarjetaShopping(value: 'targeta-shopping'), + unionChinaPay(value: 'union-china-pay'), + visa(value: 'visa'), + mIR(value: 'mir'), + maestro(value: 'maestro'); + + const CreditCard({ + required this.value + }); + + final String value; + + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/execution_method.dart b/lib/src/enums/execution_method.dart new file mode 100644 index 0000000..2a67eea --- /dev/null +++ b/lib/src/enums/execution_method.dart @@ -0,0 +1,18 @@ +part of dart_appwrite.enums; + +enum ExecutionMethod { + gET(value: 'GET'), + pOST(value: 'POST'), + pUT(value: 'PUT'), + pATCH(value: 'PATCH'), + dELETE(value: 'DELETE'), + oPTIONS(value: 'OPTIONS'); + + const ExecutionMethod({ + required this.value + }); + + final String value; + + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/flag.dart b/lib/src/enums/flag.dart new file mode 100644 index 0000000..a121f44 --- /dev/null +++ b/lib/src/enums/flag.dart @@ -0,0 +1,206 @@ +part of dart_appwrite.enums; + +enum Flag { + afghanistan(value: 'af'), + angola(value: 'ao'), + albania(value: 'al'), + andorra(value: 'ad'), + unitedArabEmirates(value: 'ae'), + argentina(value: 'ar'), + armenia(value: 'am'), + antiguaAndBarbuda(value: 'ag'), + australia(value: 'au'), + austria(value: 'at'), + azerbaijan(value: 'az'), + burundi(value: 'bi'), + belgium(value: 'be'), + benin(value: 'bj'), + burkinaFaso(value: 'bf'), + bangladesh(value: 'bd'), + bulgaria(value: 'bg'), + bahrain(value: 'bh'), + bahamas(value: 'bs'), + bosniaAndHerzegovina(value: 'ba'), + belarus(value: 'by'), + belize(value: 'bz'), + bolivia(value: 'bo'), + brazil(value: 'br'), + barbados(value: 'bb'), + bruneiDarussalam(value: 'bn'), + bhutan(value: 'bt'), + botswana(value: 'bw'), + centralAfricanRepublic(value: 'cf'), + canada(value: 'ca'), + switzerland(value: 'ch'), + chile(value: 'cl'), + china(value: 'cn'), + coteDIvoire(value: 'ci'), + cameroon(value: 'cm'), + democraticRepublicOfTheCongo(value: 'cd'), + republicOfTheCongo(value: 'cg'), + colombia(value: 'co'), + comoros(value: 'km'), + capeVerde(value: 'cv'), + costaRica(value: 'cr'), + cuba(value: 'cu'), + cyprus(value: 'cy'), + czechRepublic(value: 'cz'), + germany(value: 'de'), + djibouti(value: 'dj'), + dominica(value: 'dm'), + denmark(value: 'dk'), + dominicanRepublic(value: 'do'), + algeria(value: 'dz'), + ecuador(value: 'ec'), + egypt(value: 'eg'), + eritrea(value: 'er'), + spain(value: 'es'), + estonia(value: 'ee'), + ethiopia(value: 'et'), + finland(value: 'fi'), + fiji(value: 'fj'), + france(value: 'fr'), + micronesiaFederatedStatesOf(value: 'fm'), + gabon(value: 'ga'), + unitedKingdom(value: 'gb'), + georgia(value: 'ge'), + ghana(value: 'gh'), + guinea(value: 'gn'), + gambia(value: 'gm'), + guineaBissau(value: 'gw'), + equatorialGuinea(value: 'gq'), + greece(value: 'gr'), + grenada(value: 'gd'), + guatemala(value: 'gt'), + guyana(value: 'gy'), + honduras(value: 'hn'), + croatia(value: 'hr'), + haiti(value: 'ht'), + hungary(value: 'hu'), + indonesia(value: 'id'), + india(value: 'in'), + ireland(value: 'ie'), + iranIslamicRepublicOf(value: 'ir'), + iraq(value: 'iq'), + iceland(value: 'is'), + israel(value: 'il'), + italy(value: 'it'), + jamaica(value: 'jm'), + jordan(value: 'jo'), + japan(value: 'jp'), + kazakhstan(value: 'kz'), + kenya(value: 'ke'), + kyrgyzstan(value: 'kg'), + cambodia(value: 'kh'), + kiribati(value: 'ki'), + saintKittsAndNevis(value: 'kn'), + southKorea(value: 'kr'), + kuwait(value: 'kw'), + laoPeopleSDemocraticRepublic(value: 'la'), + lebanon(value: 'lb'), + liberia(value: 'lr'), + libya(value: 'ly'), + saintLucia(value: 'lc'), + liechtenstein(value: 'li'), + sriLanka(value: 'lk'), + lesotho(value: 'ls'), + lithuania(value: 'lt'), + luxembourg(value: 'lu'), + latvia(value: 'lv'), + morocco(value: 'ma'), + monaco(value: 'mc'), + moldova(value: 'md'), + madagascar(value: 'mg'), + maldives(value: 'mv'), + mexico(value: 'mx'), + marshallIslands(value: 'mh'), + northMacedonia(value: 'mk'), + mali(value: 'ml'), + malta(value: 'mt'), + myanmar(value: 'mm'), + montenegro(value: 'me'), + mongolia(value: 'mn'), + mozambique(value: 'mz'), + mauritania(value: 'mr'), + mauritius(value: 'mu'), + malawi(value: 'mw'), + malaysia(value: 'my'), + namibia(value: 'na'), + niger(value: 'ne'), + nigeria(value: 'ng'), + nicaragua(value: 'ni'), + netherlands(value: 'nl'), + norway(value: 'no'), + nepal(value: 'np'), + nauru(value: 'nr'), + newZealand(value: 'nz'), + oman(value: 'om'), + pakistan(value: 'pk'), + panama(value: 'pa'), + peru(value: 'pe'), + philippines(value: 'ph'), + palau(value: 'pw'), + papuaNewGuinea(value: 'pg'), + poland(value: 'pl'), + northKorea(value: 'kp'), + portugal(value: 'pt'), + paraguay(value: 'py'), + qatar(value: 'qa'), + romania(value: 'ro'), + russia(value: 'ru'), + rwanda(value: 'rw'), + saudiArabia(value: 'sa'), + sudan(value: 'sd'), + senegal(value: 'sn'), + singapore(value: 'sg'), + solomonIslands(value: 'sb'), + sierraLeone(value: 'sl'), + elSalvador(value: 'sv'), + sanMarino(value: 'sm'), + somalia(value: 'so'), + serbia(value: 'rs'), + southSudan(value: 'ss'), + saoTomeAndPrincipe(value: 'st'), + suriname(value: 'sr'), + slovakia(value: 'sk'), + slovenia(value: 'si'), + sweden(value: 'se'), + eswatini(value: 'sz'), + seychelles(value: 'sc'), + syria(value: 'sy'), + chad(value: 'td'), + togo(value: 'tg'), + thailand(value: 'th'), + tajikistan(value: 'tj'), + turkmenistan(value: 'tm'), + timorLeste(value: 'tl'), + tonga(value: 'to'), + trinidadAndTobago(value: 'tt'), + tunisia(value: 'tn'), + turkey(value: 'tr'), + tuvalu(value: 'tv'), + tanzania(value: 'tz'), + uganda(value: 'ug'), + ukraine(value: 'ua'), + uruguay(value: 'uy'), + unitedStates(value: 'us'), + uzbekistan(value: 'uz'), + vaticanCity(value: 'va'), + saintVincentAndTheGrenadines(value: 'vc'), + venezuela(value: 've'), + vietnam(value: 'vn'), + vanuatu(value: 'vu'), + samoa(value: 'ws'), + yemen(value: 'ye'), + southAfrica(value: 'za'), + zambia(value: 'zm'), + zimbabwe(value: 'zw'); + + const Flag({ + required this.value + }); + + final String value; + + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/image_format.dart b/lib/src/enums/image_format.dart new file mode 100644 index 0000000..3110d9e --- /dev/null +++ b/lib/src/enums/image_format.dart @@ -0,0 +1,17 @@ +part of dart_appwrite.enums; + +enum ImageFormat { + jpg(value: 'jpg'), + jpeg(value: 'jpeg'), + gif(value: 'gif'), + png(value: 'png'), + webp(value: 'webp'); + + const ImageFormat({ + required this.value + }); + + final String value; + + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/image_gravity.dart b/lib/src/enums/image_gravity.dart new file mode 100644 index 0000000..2913f70 --- /dev/null +++ b/lib/src/enums/image_gravity.dart @@ -0,0 +1,21 @@ +part of dart_appwrite.enums; + +enum ImageGravity { + center(value: 'center'), + topLeft(value: 'top-left'), + top(value: 'top'), + topRight(value: 'top-right'), + left(value: 'left'), + right(value: 'right'), + bottomLeft(value: 'bottom-left'), + bottom(value: 'bottom'), + bottomRight(value: 'bottom-right'); + + const ImageGravity({ + required this.value + }); + + final String value; + + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/index_type.dart b/lib/src/enums/index_type.dart new file mode 100644 index 0000000..57449bc --- /dev/null +++ b/lib/src/enums/index_type.dart @@ -0,0 +1,15 @@ +part of dart_appwrite.enums; + +enum IndexType { + key(value: 'key'), + fulltext(value: 'fulltext'), + unique(value: 'unique'); + + const IndexType({ + required this.value + }); + + final String value; + + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/messaging_provider_type.dart b/lib/src/enums/messaging_provider_type.dart new file mode 100644 index 0000000..a50c21b --- /dev/null +++ b/lib/src/enums/messaging_provider_type.dart @@ -0,0 +1,15 @@ +part of dart_appwrite.enums; + +enum MessagingProviderType { + email(value: 'email'), + sms(value: 'sms'), + push(value: 'push'); + + const MessagingProviderType({ + required this.value + }); + + final String value; + + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/name.dart b/lib/src/enums/name.dart new file mode 100644 index 0000000..6b990e4 --- /dev/null +++ b/lib/src/enums/name.dart @@ -0,0 +1,25 @@ +part of dart_appwrite.enums; + +enum Name { + v1Database(value: 'v1-database'), + v1Deletes(value: 'v1-deletes'), + v1Audits(value: 'v1-audits'), + v1Mails(value: 'v1-mails'), + v1Functions(value: 'v1-functions'), + v1Usage(value: 'v1-usage'), + v1UsageDump(value: 'v1-usage-dump'), + webhooksv1(value: 'webhooksv1'), + v1Certificates(value: 'v1-certificates'), + v1Builds(value: 'v1-builds'), + v1Messaging(value: 'v1-messaging'), + v1Migrations(value: 'v1-migrations'), + hamsterv1(value: 'hamsterv1'); + + const Name({ + required this.value + }); + + final String value; + + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/o_auth_provider.dart b/lib/src/enums/o_auth_provider.dart new file mode 100644 index 0000000..cf4aa54 --- /dev/null +++ b/lib/src/enums/o_auth_provider.dart @@ -0,0 +1,51 @@ +part of dart_appwrite.enums; + +enum OAuthProvider { + amazon(value: 'amazon'), + apple(value: 'apple'), + auth0(value: 'auth0'), + authentik(value: 'authentik'), + autodesk(value: 'autodesk'), + bitbucket(value: 'bitbucket'), + bitly(value: 'bitly'), + box(value: 'box'), + dailymotion(value: 'dailymotion'), + discord(value: 'discord'), + disqus(value: 'disqus'), + dropbox(value: 'dropbox'), + etsy(value: 'etsy'), + facebook(value: 'facebook'), + github(value: 'github'), + gitlab(value: 'gitlab'), + google(value: 'google'), + linkedin(value: 'linkedin'), + microsoft(value: 'microsoft'), + notion(value: 'notion'), + oidc(value: 'oidc'), + okta(value: 'okta'), + paypal(value: 'paypal'), + paypalSandbox(value: 'paypalSandbox'), + podio(value: 'podio'), + salesforce(value: 'salesforce'), + slack(value: 'slack'), + spotify(value: 'spotify'), + stripe(value: 'stripe'), + tradeshift(value: 'tradeshift'), + tradeshiftBox(value: 'tradeshiftBox'), + twitch(value: 'twitch'), + wordpress(value: 'wordpress'), + yahoo(value: 'yahoo'), + yammer(value: 'yammer'), + yandex(value: 'yandex'), + zoho(value: 'zoho'), + zoom(value: 'zoom'), + mock(value: 'mock'); + + const OAuthProvider({ + required this.value + }); + + final String value; + + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/password_hash.dart b/lib/src/enums/password_hash.dart new file mode 100644 index 0000000..ed2f0f5 --- /dev/null +++ b/lib/src/enums/password_hash.dart @@ -0,0 +1,23 @@ +part of dart_appwrite.enums; + +enum PasswordHash { + sha1(value: 'sha1'), + sha224(value: 'sha224'), + sha256(value: 'sha256'), + sha384(value: 'sha384'), + sha512224(value: 'sha512/224'), + sha512256(value: 'sha512/256'), + sha512(value: 'sha512'), + sha3224(value: 'sha3-224'), + sha3256(value: 'sha3-256'), + sha3384(value: 'sha3-384'), + sha3512(value: 'sha3-512'); + + const PasswordHash({ + required this.value + }); + + final String value; + + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/relation_mutate.dart b/lib/src/enums/relation_mutate.dart new file mode 100644 index 0000000..c3a4fb9 --- /dev/null +++ b/lib/src/enums/relation_mutate.dart @@ -0,0 +1,15 @@ +part of dart_appwrite.enums; + +enum RelationMutate { + cascade(value: 'cascade'), + restrict(value: 'restrict'), + setNull(value: 'setNull'); + + const RelationMutate({ + required this.value + }); + + final String value; + + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/relationship_type.dart b/lib/src/enums/relationship_type.dart new file mode 100644 index 0000000..9b281ed --- /dev/null +++ b/lib/src/enums/relationship_type.dart @@ -0,0 +1,16 @@ +part of dart_appwrite.enums; + +enum RelationshipType { + oneToOne(value: 'oneToOne'), + manyToOne(value: 'manyToOne'), + manyToMany(value: 'manyToMany'), + oneToMany(value: 'oneToMany'); + + const RelationshipType({ + required this.value + }); + + final String value; + + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/runtime.dart b/lib/src/enums/runtime.dart new file mode 100644 index 0000000..d1388fb --- /dev/null +++ b/lib/src/enums/runtime.dart @@ -0,0 +1,56 @@ +part of dart_appwrite.enums; + +enum Runtime { + node145(value: 'node-14.5'), + node160(value: 'node-16.0'), + node180(value: 'node-18.0'), + node190(value: 'node-19.0'), + node200(value: 'node-20.0'), + node210(value: 'node-21.0'), + php80(value: 'php-8.0'), + php81(value: 'php-8.1'), + php82(value: 'php-8.2'), + php83(value: 'php-8.3'), + ruby30(value: 'ruby-3.0'), + ruby31(value: 'ruby-3.1'), + ruby32(value: 'ruby-3.2'), + ruby33(value: 'ruby-3.3'), + python38(value: 'python-3.8'), + python39(value: 'python-3.9'), + python310(value: 'python-3.10'), + python311(value: 'python-3.11'), + python312(value: 'python-3.12'), + deno140(value: 'deno-1.40'), + dart215(value: 'dart-2.15'), + dart216(value: 'dart-2.16'), + dart217(value: 'dart-2.17'), + dart218(value: 'dart-2.18'), + dart30(value: 'dart-3.0'), + dart31(value: 'dart-3.1'), + dart33(value: 'dart-3.3'), + dotnet31(value: 'dotnet-3.1'), + dotnet60(value: 'dotnet-6.0'), + dotnet70(value: 'dotnet-7.0'), + java80(value: 'java-8.0'), + java110(value: 'java-11.0'), + java170(value: 'java-17.0'), + java180(value: 'java-18.0'), + java210(value: 'java-21.0'), + swift55(value: 'swift-5.5'), + swift58(value: 'swift-5.8'), + swift59(value: 'swift-5.9'), + kotlin16(value: 'kotlin-1.6'), + kotlin18(value: 'kotlin-1.8'), + kotlin19(value: 'kotlin-1.9'), + cpp17(value: 'cpp-17'), + cpp20(value: 'cpp-20'), + bun10(value: 'bun-1.0'); + + const Runtime({ + required this.value + }); + + final String value; + + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/enums/smtp_encryption.dart b/lib/src/enums/smtp_encryption.dart new file mode 100644 index 0000000..c416f6b --- /dev/null +++ b/lib/src/enums/smtp_encryption.dart @@ -0,0 +1,15 @@ +part of dart_appwrite.enums; + +enum SmtpEncryption { + none(value: 'none'), + ssl(value: 'ssl'), + tls(value: 'tls'); + + const SmtpEncryption({ + required this.value + }); + + final String value; + + String toJson() => value; +} \ No newline at end of file diff --git a/lib/src/models/health_certificate.dart b/lib/src/models/health_certificate.dart new file mode 100644 index 0000000..b578102 --- /dev/null +++ b/lib/src/models/health_certificate.dart @@ -0,0 +1,48 @@ +part of dart_appwrite.models; + +/// Health Certificate +class HealthCertificate implements Model { + /// Certificate name + final String name; + /// Subject SN + final String subjectSN; + /// Issuer organisation + final String issuerOrganisation; + /// Valid from + final String validFrom; + /// Valid to + final String validTo; + /// Signature type SN + final String signatureTypeSN; + + HealthCertificate({ + required this.name, + required this.subjectSN, + required this.issuerOrganisation, + required this.validFrom, + required this.validTo, + required this.signatureTypeSN, + }); + + factory HealthCertificate.fromMap(Map<String, dynamic> map) { + return HealthCertificate( + name: map['name'].toString(), + subjectSN: map['subjectSN'].toString(), + issuerOrganisation: map['issuerOrganisation'].toString(), + validFrom: map['validFrom'].toString(), + validTo: map['validTo'].toString(), + signatureTypeSN: map['signatureTypeSN'].toString(), + ); + } + + Map<String, dynamic> toMap() { + return { + "name": name, + "subjectSN": subjectSN, + "issuerOrganisation": issuerOrganisation, + "validFrom": validFrom, + "validTo": validTo, + "signatureTypeSN": signatureTypeSN, + }; + } +} diff --git a/lib/src/models/jwt.dart b/lib/src/models/jwt.dart new file mode 100644 index 0000000..f187a74 --- /dev/null +++ b/lib/src/models/jwt.dart @@ -0,0 +1,23 @@ +part of dart_appwrite.models; + +/// JWT +class Jwt implements Model { + /// JWT encoded string. + final String jwt; + + Jwt({ + required this.jwt, + }); + + factory Jwt.fromMap(Map<String, dynamic> map) { + return Jwt( + jwt: map['jwt'].toString(), + ); + } + + Map<String, dynamic> toMap() { + return { + "jwt": jwt, + }; + } +} diff --git a/lib/src/models/membership.dart b/lib/src/models/membership.dart index d83bd12..1388e2e 100644 --- a/lib/src/models/membership.dart +++ b/lib/src/models/membership.dart @@ -24,6 +24,8 @@ class Membership implements Model { final String joined; /// User confirmation status, true if the user has joined the team or false otherwise. final bool confirm; + /// Multi factor authentication status, true if the user has MFA enabled or false otherwise. + final bool mfa; /// User list of roles final List roles; @@ -39,6 +41,7 @@ class Membership implements Model { required this.invited, required this.joined, required this.confirm, + required this.mfa, required this.roles, }); @@ -55,6 +58,7 @@ class Membership implements Model { invited: map['invited'].toString(), joined: map['joined'].toString(), confirm: map['confirm'], + mfa: map['mfa'], roles: map['roles'] ?? [], ); } @@ -72,6 +76,7 @@ class Membership implements Model { "invited": invited, "joined": joined, "confirm": confirm, + "mfa": mfa, "roles": roles, }; } diff --git a/lib/src/models/message.dart b/lib/src/models/message.dart new file mode 100644 index 0000000..9b63cfd --- /dev/null +++ b/lib/src/models/message.dart @@ -0,0 +1,83 @@ +part of dart_appwrite.models; + +/// Message +class Message implements Model { + /// Message ID. + final String $id; + /// Message creation time in ISO 8601 format. + final String $createdAt; + /// Message update date in ISO 8601 format. + final String $updatedAt; + /// Message provider type. + final String providerType; + /// Topic IDs set as recipients. + final List topics; + /// User IDs set as recipients. + final List users; + /// Target IDs set as recipients. + final List targets; + /// The scheduled time for message. + final String? scheduledAt; + /// The time when the message was delivered. + final String? deliveredAt; + /// Delivery errors if any. + final List? deliveryErrors; + /// Number of recipients the message was delivered to. + final int deliveredTotal; + /// Data of the message. + final Map<String, dynamic> data; + /// Status of delivery. + final String status; + + Message({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.providerType, + required this.topics, + required this.users, + required this.targets, + this.scheduledAt, + this.deliveredAt, + this.deliveryErrors, + required this.deliveredTotal, + required this.data, + required this.status, + }); + + factory Message.fromMap(Map<String, dynamic> map) { + return Message( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + providerType: map['providerType'].toString(), + topics: map['topics'] ?? [], + users: map['users'] ?? [], + targets: map['targets'] ?? [], + scheduledAt: map['scheduledAt']?.toString(), + deliveredAt: map['deliveredAt']?.toString(), + deliveryErrors: map['deliveryErrors'], + deliveredTotal: map['deliveredTotal'], + data: map['data'], + status: map['status'].toString(), + ); + } + + Map<String, dynamic> toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "providerType": providerType, + "topics": topics, + "users": users, + "targets": targets, + "scheduledAt": scheduledAt, + "deliveredAt": deliveredAt, + "deliveryErrors": deliveryErrors, + "deliveredTotal": deliveredTotal, + "data": data, + "status": status, + }; + } +} diff --git a/lib/src/models/message_list.dart b/lib/src/models/message_list.dart new file mode 100644 index 0000000..b4c503c --- /dev/null +++ b/lib/src/models/message_list.dart @@ -0,0 +1,28 @@ +part of dart_appwrite.models; + +/// Message list +class MessageList implements Model { + /// Total number of messages documents that matched your query. + final int total; + /// List of messages. + final List<Message> messages; + + MessageList({ + required this.total, + required this.messages, + }); + + factory MessageList.fromMap(Map<String, dynamic> map) { + return MessageList( + total: map['total'], + messages: List<Message>.from(map['messages'].map((p) => Message.fromMap(p))), + ); + } + + Map<String, dynamic> toMap() { + return { + "total": total, + "messages": messages.map((p) => p.toMap()).toList(), + }; + } +} diff --git a/lib/src/models/mfa_challenge.dart b/lib/src/models/mfa_challenge.dart new file mode 100644 index 0000000..621dcda --- /dev/null +++ b/lib/src/models/mfa_challenge.dart @@ -0,0 +1,38 @@ +part of dart_appwrite.models; + +/// MFA Challenge +class MfaChallenge implements Model { + /// Token ID. + final String $id; + /// Token creation date in ISO 8601 format. + final String $createdAt; + /// User ID. + final String userId; + /// Token expiration date in ISO 8601 format. + final String expire; + + MfaChallenge({ + required this.$id, + required this.$createdAt, + required this.userId, + required this.expire, + }); + + factory MfaChallenge.fromMap(Map<String, dynamic> map) { + return MfaChallenge( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + userId: map['userId'].toString(), + expire: map['expire'].toString(), + ); + } + + Map<String, dynamic> toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "userId": userId, + "expire": expire, + }; + } +} diff --git a/lib/src/models/mfa_factors.dart b/lib/src/models/mfa_factors.dart new file mode 100644 index 0000000..485b767 --- /dev/null +++ b/lib/src/models/mfa_factors.dart @@ -0,0 +1,33 @@ +part of dart_appwrite.models; + +/// MFAFactors +class MfaFactors implements Model { + /// TOTP + final bool totp; + /// Phone + final bool phone; + /// Email + final bool email; + + MfaFactors({ + required this.totp, + required this.phone, + required this.email, + }); + + factory MfaFactors.fromMap(Map<String, dynamic> map) { + return MfaFactors( + totp: map['totp'], + phone: map['phone'], + email: map['email'], + ); + } + + Map<String, dynamic> toMap() { + return { + "totp": totp, + "phone": phone, + "email": email, + }; + } +} diff --git a/lib/src/models/mfa_recovery_codes.dart b/lib/src/models/mfa_recovery_codes.dart new file mode 100644 index 0000000..d4364ea --- /dev/null +++ b/lib/src/models/mfa_recovery_codes.dart @@ -0,0 +1,23 @@ +part of dart_appwrite.models; + +/// MFA Recovery Codes +class MfaRecoveryCodes implements Model { + /// Recovery codes. + final List recoveryCodes; + + MfaRecoveryCodes({ + required this.recoveryCodes, + }); + + factory MfaRecoveryCodes.fromMap(Map<String, dynamic> map) { + return MfaRecoveryCodes( + recoveryCodes: map['recoveryCodes'] ?? [], + ); + } + + Map<String, dynamic> toMap() { + return { + "recoveryCodes": recoveryCodes, + }; + } +} diff --git a/lib/src/models/mfa_type.dart b/lib/src/models/mfa_type.dart new file mode 100644 index 0000000..887ae0e --- /dev/null +++ b/lib/src/models/mfa_type.dart @@ -0,0 +1,28 @@ +part of dart_appwrite.models; + +/// MFAType +class MfaType implements Model { + /// Secret token used for TOTP factor. + final String secret; + /// URI for authenticator apps. + final String uri; + + MfaType({ + required this.secret, + required this.uri, + }); + + factory MfaType.fromMap(Map<String, dynamic> map) { + return MfaType( + secret: map['secret'].toString(), + uri: map['uri'].toString(), + ); + } + + Map<String, dynamic> toMap() { + return { + "secret": secret, + "uri": uri, + }; + } +} diff --git a/lib/src/models/provider.dart b/lib/src/models/provider.dart new file mode 100644 index 0000000..57c76c2 --- /dev/null +++ b/lib/src/models/provider.dart @@ -0,0 +1,63 @@ +part of dart_appwrite.models; + +/// Provider +class Provider implements Model { + /// Provider ID. + final String $id; + /// Provider creation time in ISO 8601 format. + final String $createdAt; + /// Provider update date in ISO 8601 format. + final String $updatedAt; + /// The name for the provider instance. + final String name; + /// The name of the provider service. + final String provider; + /// Is provider enabled? + final bool enabled; + /// Type of provider. + final String type; + /// Provider credentials. + final Map<String, dynamic> credentials; + /// Provider options. + final Map<String, dynamic>? options; + + Provider({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + required this.provider, + required this.enabled, + required this.type, + required this.credentials, + this.options, + }); + + factory Provider.fromMap(Map<String, dynamic> map) { + return Provider( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + provider: map['provider'].toString(), + enabled: map['enabled'], + type: map['type'].toString(), + credentials: map['credentials'], + options: map['options'], + ); + } + + Map<String, dynamic> toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "provider": provider, + "enabled": enabled, + "type": type, + "credentials": credentials, + "options": options, + }; + } +} diff --git a/lib/src/models/provider_list.dart b/lib/src/models/provider_list.dart new file mode 100644 index 0000000..9384dd3 --- /dev/null +++ b/lib/src/models/provider_list.dart @@ -0,0 +1,28 @@ +part of dart_appwrite.models; + +/// Provider list +class ProviderList implements Model { + /// Total number of providers documents that matched your query. + final int total; + /// List of providers. + final List<Provider> providers; + + ProviderList({ + required this.total, + required this.providers, + }); + + factory ProviderList.fromMap(Map<String, dynamic> map) { + return ProviderList( + total: map['total'], + providers: List<Provider>.from(map['providers'].map((p) => Provider.fromMap(p))), + ); + } + + Map<String, dynamic> toMap() { + return { + "total": total, + "providers": providers.map((p) => p.toMap()).toList(), + }; + } +} diff --git a/lib/src/models/session.dart b/lib/src/models/session.dart index e264530..1349c44 100644 --- a/lib/src/models/session.dart +++ b/lib/src/models/session.dart @@ -52,6 +52,12 @@ class Session implements Model { final String countryName; /// Returns true if this the current user session. final bool current; + /// Returns a list of active session factors. + final List factors; + /// Secret used to authenticate the user. Only included if the request was made with an API key + final String secret; + /// Most recent date in ISO 8601 format when the session successfully passed MFA challenge. + final String mfaUpdatedAt; Session({ required this.$id, @@ -79,6 +85,9 @@ class Session implements Model { required this.countryCode, required this.countryName, required this.current, + required this.factors, + required this.secret, + required this.mfaUpdatedAt, }); factory Session.fromMap(Map<String, dynamic> map) { @@ -108,6 +117,9 @@ class Session implements Model { countryCode: map['countryCode'].toString(), countryName: map['countryName'].toString(), current: map['current'], + factors: map['factors'] ?? [], + secret: map['secret'].toString(), + mfaUpdatedAt: map['mfaUpdatedAt'].toString(), ); } @@ -138,6 +150,9 @@ class Session implements Model { "countryCode": countryCode, "countryName": countryName, "current": current, + "factors": factors, + "secret": secret, + "mfaUpdatedAt": mfaUpdatedAt, }; } } diff --git a/lib/src/models/subscriber.dart b/lib/src/models/subscriber.dart new file mode 100644 index 0000000..e4e8cde --- /dev/null +++ b/lib/src/models/subscriber.dart @@ -0,0 +1,63 @@ +part of dart_appwrite.models; + +/// Subscriber +class Subscriber implements Model { + /// Subscriber ID. + final String $id; + /// Subscriber creation time in ISO 8601 format. + final String $createdAt; + /// Subscriber update date in ISO 8601 format. + final String $updatedAt; + /// Target ID. + final String targetId; + /// Target. + final Target target; + /// Topic ID. + final String userId; + /// User Name. + final String userName; + /// Topic ID. + final String topicId; + /// The target provider type. Can be one of the following: `email`, `sms` or `push`. + final String providerType; + + Subscriber({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.targetId, + required this.target, + required this.userId, + required this.userName, + required this.topicId, + required this.providerType, + }); + + factory Subscriber.fromMap(Map<String, dynamic> map) { + return Subscriber( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + targetId: map['targetId'].toString(), + target: Target.fromMap(map['target']), + userId: map['userId'].toString(), + userName: map['userName'].toString(), + topicId: map['topicId'].toString(), + providerType: map['providerType'].toString(), + ); + } + + Map<String, dynamic> toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "targetId": targetId, + "target": target.toMap(), + "userId": userId, + "userName": userName, + "topicId": topicId, + "providerType": providerType, + }; + } +} diff --git a/lib/src/models/subscriber_list.dart b/lib/src/models/subscriber_list.dart new file mode 100644 index 0000000..8441475 --- /dev/null +++ b/lib/src/models/subscriber_list.dart @@ -0,0 +1,28 @@ +part of dart_appwrite.models; + +/// Subscriber list +class SubscriberList implements Model { + /// Total number of subscribers documents that matched your query. + final int total; + /// List of subscribers. + final List<Subscriber> subscribers; + + SubscriberList({ + required this.total, + required this.subscribers, + }); + + factory SubscriberList.fromMap(Map<String, dynamic> map) { + return SubscriberList( + total: map['total'], + subscribers: List<Subscriber>.from(map['subscribers'].map((p) => Subscriber.fromMap(p))), + ); + } + + Map<String, dynamic> toMap() { + return { + "total": total, + "subscribers": subscribers.map((p) => p.toMap()).toList(), + }; + } +} diff --git a/lib/src/models/target.dart b/lib/src/models/target.dart new file mode 100644 index 0000000..67a1f45 --- /dev/null +++ b/lib/src/models/target.dart @@ -0,0 +1,58 @@ +part of dart_appwrite.models; + +/// Target +class Target implements Model { + /// Target ID. + final String $id; + /// Target creation time in ISO 8601 format. + final String $createdAt; + /// Target update date in ISO 8601 format. + final String $updatedAt; + /// Target Name. + final String name; + /// User ID. + final String userId; + /// Provider ID. + final String? providerId; + /// The target provider type. Can be one of the following: `email`, `sms` or `push`. + final String providerType; + /// The target identifier. + final String identifier; + + Target({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + required this.userId, + this.providerId, + required this.providerType, + required this.identifier, + }); + + factory Target.fromMap(Map<String, dynamic> map) { + return Target( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + userId: map['userId'].toString(), + providerId: map['providerId']?.toString(), + providerType: map['providerType'].toString(), + identifier: map['identifier'].toString(), + ); + } + + Map<String, dynamic> toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "userId": userId, + "providerId": providerId, + "providerType": providerType, + "identifier": identifier, + }; + } +} diff --git a/lib/src/models/target_list.dart b/lib/src/models/target_list.dart new file mode 100644 index 0000000..4c2e953 --- /dev/null +++ b/lib/src/models/target_list.dart @@ -0,0 +1,28 @@ +part of dart_appwrite.models; + +/// Target list +class TargetList implements Model { + /// Total number of targets documents that matched your query. + final int total; + /// List of targets. + final List<Target> targets; + + TargetList({ + required this.total, + required this.targets, + }); + + factory TargetList.fromMap(Map<String, dynamic> map) { + return TargetList( + total: map['total'], + targets: List<Target>.from(map['targets'].map((p) => Target.fromMap(p))), + ); + } + + Map<String, dynamic> toMap() { + return { + "total": total, + "targets": targets.map((p) => p.toMap()).toList(), + }; + } +} diff --git a/lib/src/models/token.dart b/lib/src/models/token.dart index cb5c59a..83ef0fb 100644 --- a/lib/src/models/token.dart +++ b/lib/src/models/token.dart @@ -12,6 +12,8 @@ class Token implements Model { final String secret; /// Token expiration date in ISO 8601 format. final String expire; + /// Security phrase of a token. Empty if security phrase was not requested when creating a token. It includes randomly generated phrase which is also sent in the external resource such as email. + final String phrase; Token({ required this.$id, @@ -19,6 +21,7 @@ class Token implements Model { required this.userId, required this.secret, required this.expire, + required this.phrase, }); factory Token.fromMap(Map<String, dynamic> map) { @@ -28,6 +31,7 @@ class Token implements Model { userId: map['userId'].toString(), secret: map['secret'].toString(), expire: map['expire'].toString(), + phrase: map['phrase'].toString(), ); } @@ -38,6 +42,7 @@ class Token implements Model { "userId": userId, "secret": secret, "expire": expire, + "phrase": phrase, }; } } diff --git a/lib/src/models/topic.dart b/lib/src/models/topic.dart new file mode 100644 index 0000000..28e8154 --- /dev/null +++ b/lib/src/models/topic.dart @@ -0,0 +1,58 @@ +part of dart_appwrite.models; + +/// Topic +class Topic implements Model { + /// Topic ID. + final String $id; + /// Topic creation time in ISO 8601 format. + final String $createdAt; + /// Topic update date in ISO 8601 format. + final String $updatedAt; + /// The name of the topic. + final String name; + /// Total count of email subscribers subscribed to the topic. + final int emailTotal; + /// Total count of SMS subscribers subscribed to the topic. + final int smsTotal; + /// Total count of push subscribers subscribed to the topic. + final int pushTotal; + /// Subscribe permissions. + final List subscribe; + + Topic({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + required this.emailTotal, + required this.smsTotal, + required this.pushTotal, + required this.subscribe, + }); + + factory Topic.fromMap(Map<String, dynamic> map) { + return Topic( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + emailTotal: map['emailTotal'], + smsTotal: map['smsTotal'], + pushTotal: map['pushTotal'], + subscribe: map['subscribe'] ?? [], + ); + } + + Map<String, dynamic> toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "emailTotal": emailTotal, + "smsTotal": smsTotal, + "pushTotal": pushTotal, + "subscribe": subscribe, + }; + } +} diff --git a/lib/src/models/topic_list.dart b/lib/src/models/topic_list.dart new file mode 100644 index 0000000..9368946 --- /dev/null +++ b/lib/src/models/topic_list.dart @@ -0,0 +1,28 @@ +part of dart_appwrite.models; + +/// Topic list +class TopicList implements Model { + /// Total number of topics documents that matched your query. + final int total; + /// List of topics. + final List<Topic> topics; + + TopicList({ + required this.total, + required this.topics, + }); + + factory TopicList.fromMap(Map<String, dynamic> map) { + return TopicList( + total: map['total'], + topics: List<Topic>.from(map['topics'].map((p) => Topic.fromMap(p))), + ); + } + + Map<String, dynamic> toMap() { + return { + "total": total, + "topics": topics.map((p) => p.toMap()).toList(), + }; + } +} diff --git a/lib/src/models/user.dart b/lib/src/models/user.dart index 32aa59a..6ad01e4 100644 --- a/lib/src/models/user.dart +++ b/lib/src/models/user.dart @@ -32,8 +32,12 @@ class User implements Model { final bool emailVerification; /// Phone verification status. final bool phoneVerification; + /// Multi factor authentication status. + final bool mfa; /// User preferences as a key-value object final Preferences prefs; + /// A user-owned message receiver. A single user may have multiple e.g. emails, phones, and a browser. Each target is registered with a single provider. + final List<Target> targets; /// Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. final String accessedAt; @@ -53,7 +57,9 @@ class User implements Model { required this.phone, required this.emailVerification, required this.phoneVerification, + required this.mfa, required this.prefs, + required this.targets, required this.accessedAt, }); @@ -74,7 +80,9 @@ class User implements Model { phone: map['phone'].toString(), emailVerification: map['emailVerification'], phoneVerification: map['phoneVerification'], + mfa: map['mfa'], prefs: Preferences.fromMap(map['prefs']), + targets: List<Target>.from(map['targets'].map((p) => Target.fromMap(p))), accessedAt: map['accessedAt'].toString(), ); } @@ -96,7 +104,9 @@ class User implements Model { "phone": phone, "emailVerification": emailVerification, "phoneVerification": phoneVerification, + "mfa": mfa, "prefs": prefs.toMap(), + "targets": targets.map((p) => p.toMap()).toList(), "accessedAt": accessedAt, }; } diff --git a/pubspec.yaml b/pubspec.yaml index b5842f8..24a7ef3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: dart_appwrite -version: 10.1.1 +version: 11.0.0 description: Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API homepage: https://appwrite.io repository: https://github.com/appwrite/sdk-for-dart diff --git a/test/query_test.dart b/test/query_test.dart index 1939b4f..71d1cf2 100644 --- a/test/query_test.dart +++ b/test/query_test.dart @@ -19,42 +19,42 @@ void main() { BasicFilterQueryTest( description: 'with a string', value: 's', - expectedValues: '["s"]', + expectedValues: ["s"], ), BasicFilterQueryTest( description: 'with an integer', value: 1, - expectedValues: '[1]', + expectedValues: [1], ), BasicFilterQueryTest( description: 'with a double', value: 1.2, - expectedValues: '[1.2]', + expectedValues: [1.2], ), BasicFilterQueryTest( description: 'with a whole number double', value: 1.0, - expectedValues: '[1.0]', + expectedValues: [1.0], ), BasicFilterQueryTest( description: 'with a bool', value: false, - expectedValues: '[false]', + expectedValues: [false], ), BasicFilterQueryTest( description: 'with a list', value: ['a', 'b', 'c'], - expectedValues: '["a","b","c"]', + expectedValues: ["a","b","c"], ), ]; group('equal()', () { for (var t in tests) { test(t.description, () { - expect( - Query.equal('attr', t.value), - 'equal("attr", ${t.expectedValues})', - ); + final query = Query.equal('attr', t.value).toJson(); + expect(query['attribute'], 'attr'); + expect(query['values'], t.expectedValues); + expect(query['method'], 'equal'); }); } }); @@ -62,10 +62,10 @@ void main() { group('notEqual()', () { for (var t in tests) { test(t.description, () { - expect( - Query.notEqual('attr', t.value), - 'notEqual("attr", ${t.expectedValues})', - ); + final query = Query.notEqual('attr', t.value).toJson(); + expect(query['attribute'], 'attr'); + expect(query['values'], t.expectedValues); + expect(query['method'], 'notEqual'); }); } }); @@ -73,10 +73,10 @@ void main() { group('lessThan()', () { for (var t in tests) { test(t.description, () { - expect( - Query.lessThan('attr', t.value), - 'lessThan("attr", ${t.expectedValues})', - ); + final query = Query.lessThan('attr', t.value).toJson(); + expect(query['attribute'], 'attr'); + expect(query['values'], t.expectedValues); + expect(query['method'], 'lessThan'); }); } }); @@ -84,10 +84,10 @@ void main() { group('lessThanEqual()', () { for (var t in tests) { test(t.description, () { - expect( - Query.lessThanEqual('attr', t.value), - 'lessThanEqual("attr", ${t.expectedValues})', - ); + final query = Query.lessThanEqual('attr', t.value).toJson(); + expect(query['attribute'], 'attr'); + expect(query['values'], t.expectedValues); + expect(query['method'], 'lessThanEqual'); }); } }); @@ -95,10 +95,10 @@ void main() { group('greaterThan()', () { for (var t in tests) { test(t.description, () { - expect( - Query.greaterThan('attr', t.value), - 'greaterThan("attr", ${t.expectedValues})', - ); + final query = Query.greaterThan('attr', t.value).toJson(); + expect(query['attribute'], 'attr'); + expect(query['values'], t.expectedValues); + expect(query['method'], 'greaterThan'); }); } }); @@ -106,87 +106,106 @@ void main() { group('greaterThanEqual()', () { for (var t in tests) { test(t.description, () { - expect( - Query.greaterThanEqual('attr', t.value), - 'greaterThanEqual("attr", ${t.expectedValues})', - ); + final query = Query.greaterThanEqual('attr', t.value).toJson(); + expect(query['attribute'], 'attr'); + expect(query['values'], t.expectedValues); + expect(query['method'], 'greaterThanEqual'); }); } }); }); - group('search()', () { - test('returns search', () { - expect(Query.search('attr', 'keyword1 keyword2'), 'search("attr", ["keyword1 keyword2"])'); - }); + test('returns search', () { + final query = Query.search('attr', 'keyword1 keyword2').toJson(); + expect(query['attribute'], 'attr'); + expect(query['values'], ['keyword1 keyword2']); + expect(query['method'], 'search'); }); - group('isNull()', () { - test('returns isNull', () { - expect(Query.isNull('attr'), 'isNull("attr")'); - }); + test('returns isNull', () { + final query = Query.isNull('attr').toJson(); + expect(query['attribute'], 'attr'); + expect(query['values'], null); + expect(query['method'], 'isNull'); }); - group('isNotNull()', () { - test('returns isNotNull', () { - expect(Query.isNotNull('attr'), 'isNotNull("attr")'); - }); + test('returns isNotNull', () { + final query = Query.isNotNull('attr', 'keyword1 keyword2').toJson(); + expect(query['attribute'], 'attr'); + expect(query['values'], null); + expect(query['method'], 'isNotNull'); }); group('between()', () { test('with integers', () { - expect(Query.between('attr', 1, 2), 'between("attr", [1,2])'); + final query = Query.between('attr', 1, 2).toJson(); + expect(query['attribute'], 'attr'); + expect(query['values'], [1, 2]); + expect(query['method'], 'between'); }); test('with doubles', () { - expect(Query.between('attr', 1.0, 2.0), 'between("attr", [1.0,2.0])'); + final query = Query.between('attr', 1.0, 2.0).toJson(); + expect(query['attribute'], 'attr'); + expect(query['values'], [1.0, 2.0]); + expect(query['method'], 'between'); }); test('with strings', () { - expect(Query.between('attr', "a", "z"), 'between("attr", ["a","z"])'); + final query = Query.between('attr', 'a', 'z').toJson(); + expect(query['attribute'], 'attr'); + expect(query['values'], ['a', 'z']); + expect(query['method'], 'between'); }); }); - group('select()', () { - test('returns select', () { - expect(Query.select(['attr1', 'attr2']), 'select(["attr1","attr2"])'); - }); + test('returns select', () { + final query = Query.select(['attr1', 'attr2']).toJson(); + expect(query['attribute'], null); + expect(query['values'], ['attr1', 'attr2']); + expect(query['method'], 'select'); }); - group('orderAsc()', () { - test('returns orderAsc', () { - expect(Query.orderAsc('attr'), 'orderAsc("attr")'); - }); + test('returns orderAsc', () { + final query = Query.orderAsc('attr').toJson(); + expect(query['attribute'], 'attr'); + expect(query['values'], null); + expect(query['method'], 'orderAsc'); }); - group('orderDesc()', () { - test('returns orderDesc', () { - expect(Query.orderDesc('attr'), 'orderDesc("attr")'); - }); + test('returns orderDesc', () { + final query = Query.orderDesc('attr').toJson(); + expect(query['attribute'], 'attr'); + expect(query['values'], null); + expect(query['method'], 'orderDesc'); }); - group('cursorBefore()', () { - test('returns cursorBefore', () { - expect(Query.cursorBefore(ID.custom('custom')), 'cursorBefore("custom")'); - }); + test('returns cursorBefore', () { + final query = Query.cursorBefore('custom').toJson(); + expect(query['attribute'], null); + expect(query['values'], 'custom'); + expect(query['method'], 'cursorBefore'); }); - group('cursorAfter()', () { - test('returns cursorAfter', () { - expect(Query.cursorAfter(ID.custom('custom')), 'cursorAfter("custom")'); - }); + test('returns cursorAfter', () { + final query = Query.cursorAfter('custom').toJson(); + expect(query['attribute'], null); + expect(query['values'], 'custom'); + expect(query['method'], 'cursorAfter'); }); - group('limit()', () { - test('returns limit', () { - expect(Query.limit(1), 'limit(1)'); - }); + test('returns limit', () { + final query = Query.limit(1).toJson(); + expect(query['attribute'], null); + expect(query['values'], 1); + expect(query['method'], 'limit'); }); - group('offset()', () { - test('returns offset', () { - expect(Query.offset(1), 'offset(1)'); - }); + test('returns offset', () { + final query = Query.offset(1).toJson(); + expect(query['attribute'], null); + expect(query['values'], 1); + expect(query['method'], 'offset'); }); } diff --git a/test/services/account_test.dart b/test/services/account_test.dart index de0434c..a999398 100644 --- a/test/services/account_test.dart +++ b/test/services/account_test.dart @@ -68,7 +68,9 @@ void main() { 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, + 'mfa': true, 'prefs': <String, dynamic>{}, + 'targets': [], 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; @@ -83,6 +85,40 @@ void main() { }); + test('test method create()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': <String, dynamic>{}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.create( + userId: '<USER_ID>', + email: 'email@example.com', + password: '', + ); + expect(response, isA<models.User>()); + + }); + test('test method updateEmail()', () async { final Map<String, dynamic> data = { '\$id': '5e5ea5c16897e', @@ -97,7 +133,9 @@ void main() { 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, + 'mfa': true, 'prefs': <String, dynamic>{}, + 'targets': [], 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; @@ -140,10 +178,26 @@ void main() { final response = await account.deleteIdentity( - identityId: '[IDENTITY_ID]', + identityId: '<IDENTITY_ID>', ); }); + test('test method createJWT()', () async { + final Map<String, dynamic> data = { + 'jwt': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createJWT( + ); + expect(response, isA<models.Jwt>()); + + }); + test('test method listLogs()', () async { final Map<String, dynamic> data = { 'total': 5, @@ -161,6 +215,222 @@ void main() { }); + test('test method updateMFA()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': <String, dynamic>{}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateMFA( + mfa: true, + ); + expect(response, isA<models.User>()); + + }); + + test('test method createMfaAuthenticator()', () async { + final Map<String, dynamic> data = { + 'secret': '1', + 'uri': '1',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createMfaAuthenticator( + type: 'totp', + ); + expect(response, isA<models.MfaType>()); + + }); + + test('test method updateMfaAuthenticator()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': <String, dynamic>{}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateMfaAuthenticator( + type: 'totp', + otp: '<OTP>', + ); + expect(response, isA<models.User>()); + + }); + + test('test method deleteMfaAuthenticator()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': <String, dynamic>{}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.deleteMfaAuthenticator( + type: 'totp', + otp: '<OTP>', + ); + expect(response, isA<models.User>()); + + }); + + test('test method createMfaChallenge()', () async { + final Map<String, dynamic> data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'expire': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createMfaChallenge( + factor: 'email', + ); + expect(response, isA<models.MfaChallenge>()); + + }); + + test('test method updateMfaChallenge()', () async { + final data = ''; + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateMfaChallenge( + challengeId: '<CHALLENGE_ID>', + otp: '<OTP>', + ); + }); + + test('test method listMfaFactors()', () async { + final Map<String, dynamic> data = { + 'totp': true, + 'phone': true, + 'email': true,}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.listMfaFactors( + ); + expect(response, isA<models.MfaFactors>()); + + }); + + test('test method getMfaRecoveryCodes()', () async { + final Map<String, dynamic> data = { + 'recoveryCodes': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.getMfaRecoveryCodes( + ); + expect(response, isA<models.MfaRecoveryCodes>()); + + }); + + test('test method createMfaRecoveryCodes()', () async { + final Map<String, dynamic> data = { + 'recoveryCodes': [],}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createMfaRecoveryCodes( + ); + expect(response, isA<models.MfaRecoveryCodes>()); + + }); + + test('test method updateMfaRecoveryCodes()', () async { + final Map<String, dynamic> data = { + 'recoveryCodes': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateMfaRecoveryCodes( + ); + expect(response, isA<models.MfaRecoveryCodes>()); + + }); + test('test method updateName()', () async { final Map<String, dynamic> data = { '\$id': '5e5ea5c16897e', @@ -175,7 +445,9 @@ void main() { 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, + 'mfa': true, 'prefs': <String, dynamic>{}, + 'targets': [], 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; @@ -185,7 +457,7 @@ void main() { final response = await account.updateName( - name: '[NAME]', + name: '<NAME>', ); expect(response, isA<models.User>()); @@ -205,7 +477,9 @@ void main() { 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, + 'mfa': true, 'prefs': <String, dynamic>{}, + 'targets': [], 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; @@ -235,7 +509,9 @@ void main() { 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, + 'mfa': true, 'prefs': <String, dynamic>{}, + 'targets': [], 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; @@ -281,7 +557,9 @@ void main() { 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, + 'mfa': true, 'prefs': <String, dynamic>{}, + 'targets': [], 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; @@ -303,7 +581,8 @@ void main() { '\$createdAt': '2020-10-15T06:38:00.000+00:00', 'userId': '5e5ea5c168bb8', 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00',}; + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; when(client.call( @@ -325,7 +604,8 @@ void main() { '\$createdAt': '2020-10-15T06:38:00.000+00:00', 'userId': '5e5ea5c168bb8', 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00',}; + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; when(client.call( @@ -334,10 +614,9 @@ void main() { final response = await account.updateRecovery( - userId: '[USER_ID]', - secret: '[SECRET]', - password: 'password', - passwordAgain: 'password', + userId: '<USER_ID>', + secret: '<SECRET>', + password: '', ); expect(response, isA<models.Token>()); @@ -372,6 +651,229 @@ void main() { ); }); + test('test method createAnonymousSession()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createAnonymousSession( + ); + expect(response, isA<models.Session>()); + + }); + + test('test method createEmailPasswordSession()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createEmailPasswordSession( + email: 'email@example.com', + password: 'password', + ); + expect(response, isA<models.Session>()); + + }); + + test('test method updateMagicURLSession()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateMagicURLSession( + userId: '<USER_ID>', + secret: '<SECRET>', + ); + expect(response, isA<models.Session>()); + + }); + + test('test method updatePhoneSession()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updatePhoneSession( + userId: '<USER_ID>', + secret: '<SECRET>', + ); + expect(response, isA<models.Session>()); + + }); + + test('test method createSession()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createSession( + userId: '<USER_ID>', + secret: '<SECRET>', + ); + expect(response, isA<models.Session>()); + + }); + test('test method getSession()', () async { final Map<String, dynamic> data = { '\$id': '5e5ea5c16897e', @@ -398,7 +900,10 @@ void main() { 'deviceModel': 'Nexus 5', 'countryCode': 'US', 'countryName': 'United States', - 'current': true,}; + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; when(client.call( @@ -407,7 +912,7 @@ void main() { final response = await account.getSession( - sessionId: '[SESSION_ID]', + sessionId: '<SESSION_ID>', ); expect(response, isA<models.Session>()); @@ -439,7 +944,10 @@ void main() { 'deviceModel': 'Nexus 5', 'countryCode': 'US', 'countryName': 'United States', - 'current': true,}; + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; when(client.call( @@ -448,7 +956,7 @@ void main() { final response = await account.updateSession( - sessionId: '[SESSION_ID]', + sessionId: '<SESSION_ID>', ); expect(response, isA<models.Session>()); @@ -463,7 +971,7 @@ void main() { final response = await account.deleteSession( - sessionId: '[SESSION_ID]', + sessionId: '<SESSION_ID>', ); }); @@ -481,7 +989,9 @@ void main() { 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, + 'mfa': true, 'prefs': <String, dynamic>{}, + 'targets': [], 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; @@ -496,13 +1006,95 @@ void main() { }); + test('test method createEmailToken()', () async { + final Map<String, dynamic> data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createEmailToken( + userId: '<USER_ID>', + email: 'email@example.com', + ); + expect(response, isA<models.Token>()); + + }); + + test('test method createMagicURLToken()', () async { + final Map<String, dynamic> data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createMagicURLToken( + userId: '<USER_ID>', + email: 'email@example.com', + ); + expect(response, isA<models.Token>()); + + }); + + test('test method createOAuth2Token()', () async { + + when(client.webAuth( + Uri(), + )).thenAnswer((_) async => 'done'); + + + final response = await account.createOAuth2Token( + provider: 'amazon', + ); + }); + + test('test method createPhoneToken()', () async { + final Map<String, dynamic> data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createPhoneToken( + userId: '<USER_ID>', + phone: '+12065550100', + ); + expect(response, isA<models.Token>()); + + }); + test('test method createVerification()', () async { final Map<String, dynamic> data = { '\$id': 'bb8ea5c16897e', '\$createdAt': '2020-10-15T06:38:00.000+00:00', 'userId': '5e5ea5c168bb8', 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00',}; + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; when(client.call( @@ -523,7 +1115,8 @@ void main() { '\$createdAt': '2020-10-15T06:38:00.000+00:00', 'userId': '5e5ea5c168bb8', 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00',}; + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; when(client.call( @@ -532,8 +1125,8 @@ void main() { final response = await account.updateVerification( - userId: '[USER_ID]', - secret: '[SECRET]', + userId: '<USER_ID>', + secret: '<SECRET>', ); expect(response, isA<models.Token>()); @@ -545,7 +1138,8 @@ void main() { '\$createdAt': '2020-10-15T06:38:00.000+00:00', 'userId': '5e5ea5c168bb8', 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00',}; + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; when(client.call( @@ -565,7 +1159,8 @@ void main() { '\$createdAt': '2020-10-15T06:38:00.000+00:00', 'userId': '5e5ea5c168bb8', 'secret': '', - 'expire': '2020-10-15T06:38:00.000+00:00',}; + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; when(client.call( @@ -574,8 +1169,8 @@ void main() { final response = await account.updatePhoneVerification( - userId: '[USER_ID]', - secret: '[SECRET]', + userId: '<USER_ID>', + secret: '<SECRET>', ); expect(response, isA<models.Token>()); diff --git a/test/services/avatars_test.dart b/test/services/avatars_test.dart index db6ea9c..aaf8431 100644 --- a/test/services/avatars_test.dart +++ b/test/services/avatars_test.dart @@ -145,7 +145,7 @@ void main() { final response = await avatars.getQR( - text: '[TEXT]', + text: '<TEXT>', ); expect(response, isA<Uint8List>()); diff --git a/test/services/databases_test.dart b/test/services/databases_test.dart index 400d800..94369bc 100644 --- a/test/services/databases_test.dart +++ b/test/services/databases_test.dart @@ -86,8 +86,8 @@ void main() { final response = await databases.create( - databaseId: '[DATABASE_ID]', - name: '[NAME]', + databaseId: '<DATABASE_ID>', + name: '<NAME>', ); expect(response, isA<models.Database>()); @@ -108,7 +108,7 @@ void main() { final response = await databases.get( - databaseId: '[DATABASE_ID]', + databaseId: '<DATABASE_ID>', ); expect(response, isA<models.Database>()); @@ -129,8 +129,8 @@ void main() { final response = await databases.update( - databaseId: '[DATABASE_ID]', - name: '[NAME]', + databaseId: '<DATABASE_ID>', + name: '<NAME>', ); expect(response, isA<models.Database>()); @@ -145,7 +145,7 @@ void main() { final response = await databases.delete( - databaseId: '[DATABASE_ID]', + databaseId: '<DATABASE_ID>', ); }); @@ -161,7 +161,7 @@ void main() { final response = await databases.listCollections( - databaseId: '[DATABASE_ID]', + databaseId: '<DATABASE_ID>', ); expect(response, isA<models.CollectionList>()); @@ -187,9 +187,9 @@ void main() { final response = await databases.createCollection( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', - name: '[NAME]', + databaseId: '<DATABASE_ID>', + collectionId: '<COLLECTION_ID>', + name: '<NAME>', ); expect(response, isA<models.Collection>()); @@ -215,8 +215,8 @@ void main() { final response = await databases.getCollection( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', + databaseId: '<DATABASE_ID>', + collectionId: '<COLLECTION_ID>', ); expect(response, isA<models.Collection>()); @@ -242,9 +242,9 @@ void main() { final response = await databases.updateCollection( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', - name: '[NAME]', + databaseId: '<DATABASE_ID>', + collectionId: '<COLLECTION_ID>', + name: '<NAME>', ); expect(response, isA<models.Collection>()); @@ -259,8 +259,8 @@ void main() { final response = await databases.deleteCollection( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', + databaseId: '<DATABASE_ID>', + collectionId: '<COLLECTION_ID>', ); }); @@ -276,8 +276,8 @@ void main() { final response = await databases.listAttributes( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', + databaseId: '<DATABASE_ID>', + collectionId: '<COLLECTION_ID>', ); expect(response, isA<models.AttributeList>()); @@ -298,8 +298,8 @@ void main() { final response = await databases.createBooleanAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', + databaseId: '<DATABASE_ID>', + collectionId: '<COLLECTION_ID>', key: '', xrequired: true, ); @@ -322,8 +322,8 @@ void main() { final response = await databases.updateBooleanAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', + databaseId: '<DATABASE_ID>', + collectionId: '<COLLECTION_ID>', key: '', xrequired: true, xdefault: true, @@ -348,8 +348,8 @@ void main() { final response = await databases.createDatetimeAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', + databaseId: '<DATABASE_ID>', + collectionId: '<COLLECTION_ID>', key: '', xrequired: true, ); @@ -373,8 +373,8 @@ void main() { final response = await databases.updateDatetimeAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', + databaseId: '<DATABASE_ID>', + collectionId: '<COLLECTION_ID>', key: '', xrequired: true, xdefault: '', @@ -399,8 +399,8 @@ void main() { final response = await databases.createEmailAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', + databaseId: '<DATABASE_ID>', + collectionId: '<COLLECTION_ID>', key: '', xrequired: true, ); @@ -424,8 +424,8 @@ void main() { final response = await databases.updateEmailAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', + databaseId: '<DATABASE_ID>', + collectionId: '<COLLECTION_ID>', key: '', xrequired: true, xdefault: 'email@example.com', @@ -451,8 +451,8 @@ void main() { final response = await databases.createEnumAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', + databaseId: '<DATABASE_ID>', + collectionId: '<COLLECTION_ID>', key: '', elements: [], xrequired: true, @@ -478,12 +478,12 @@ void main() { final response = await databases.updateEnumAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', + databaseId: '<DATABASE_ID>', + collectionId: '<COLLECTION_ID>', key: '', elements: [], xrequired: true, - xdefault: '[DEFAULT]', + xdefault: '<DEFAULT>', ); expect(response, isA<models.AttributeEnum>()); @@ -504,8 +504,8 @@ void main() { final response = await databases.createFloatAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', + databaseId: '<DATABASE_ID>', + collectionId: '<COLLECTION_ID>', key: '', xrequired: true, ); @@ -528,8 +528,8 @@ void main() { final response = await databases.updateFloatAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', + databaseId: '<DATABASE_ID>', + collectionId: '<COLLECTION_ID>', key: '', xrequired: true, min: 1.0, @@ -555,8 +555,8 @@ void main() { final response = await databases.createIntegerAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', + databaseId: '<DATABASE_ID>', + collectionId: '<COLLECTION_ID>', key: '', xrequired: true, ); @@ -579,8 +579,8 @@ void main() { final response = await databases.updateIntegerAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', + databaseId: '<DATABASE_ID>', + collectionId: '<COLLECTION_ID>', key: '', xrequired: true, min: 1, @@ -607,8 +607,8 @@ void main() { final response = await databases.createIpAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', + databaseId: '<DATABASE_ID>', + collectionId: '<COLLECTION_ID>', key: '', xrequired: true, ); @@ -632,8 +632,8 @@ void main() { final response = await databases.updateIpAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', + databaseId: '<DATABASE_ID>', + collectionId: '<COLLECTION_ID>', key: '', xrequired: true, xdefault: '', @@ -663,9 +663,9 @@ void main() { final response = await databases.createRelationshipAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', - relatedCollectionId: '[RELATED_COLLECTION_ID]', + databaseId: '<DATABASE_ID>', + collectionId: '<COLLECTION_ID>', + relatedCollectionId: '<RELATED_COLLECTION_ID>', type: 'oneToOne', ); expect(response, isA<models.AttributeRelationship>()); @@ -688,8 +688,8 @@ void main() { final response = await databases.createStringAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', + databaseId: '<DATABASE_ID>', + collectionId: '<COLLECTION_ID>', key: '', size: 1, xrequired: true, @@ -714,11 +714,11 @@ void main() { final response = await databases.updateStringAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', + databaseId: '<DATABASE_ID>', + collectionId: '<COLLECTION_ID>', key: '', xrequired: true, - xdefault: '[DEFAULT]', + xdefault: '<DEFAULT>', ); expect(response, isA<models.AttributeString>()); @@ -740,8 +740,8 @@ void main() { final response = await databases.createUrlAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', + databaseId: '<DATABASE_ID>', + collectionId: '<COLLECTION_ID>', key: '', xrequired: true, ); @@ -765,8 +765,8 @@ void main() { final response = await databases.updateUrlAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', + databaseId: '<DATABASE_ID>', + collectionId: '<COLLECTION_ID>', key: '', xrequired: true, xdefault: 'https://example.com', @@ -784,8 +784,8 @@ void main() { final response = await databases.getAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', + databaseId: '<DATABASE_ID>', + collectionId: '<COLLECTION_ID>', key: '', ); }); @@ -799,8 +799,8 @@ void main() { final response = await databases.deleteAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', + databaseId: '<DATABASE_ID>', + collectionId: '<COLLECTION_ID>', key: '', ); }); @@ -826,8 +826,8 @@ void main() { final response = await databases.updateRelationshipAttribute( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', + databaseId: '<DATABASE_ID>', + collectionId: '<COLLECTION_ID>', key: '', ); expect(response, isA<models.AttributeRelationship>()); @@ -846,8 +846,8 @@ void main() { final response = await databases.listDocuments( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', + databaseId: '<DATABASE_ID>', + collectionId: '<COLLECTION_ID>', ); expect(response, isA<models.DocumentList>()); @@ -869,9 +869,9 @@ void main() { final response = await databases.createDocument( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', - documentId: '[DOCUMENT_ID]', + databaseId: '<DATABASE_ID>', + collectionId: '<COLLECTION_ID>', + documentId: '<DOCUMENT_ID>', data: {}, ); expect(response, isA<models.Document>()); @@ -894,9 +894,9 @@ void main() { final response = await databases.getDocument( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', - documentId: '[DOCUMENT_ID]', + databaseId: '<DATABASE_ID>', + collectionId: '<COLLECTION_ID>', + documentId: '<DOCUMENT_ID>', ); expect(response, isA<models.Document>()); @@ -918,9 +918,9 @@ void main() { final response = await databases.updateDocument( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', - documentId: '[DOCUMENT_ID]', + databaseId: '<DATABASE_ID>', + collectionId: '<COLLECTION_ID>', + documentId: '<DOCUMENT_ID>', ); expect(response, isA<models.Document>()); @@ -935,9 +935,9 @@ void main() { final response = await databases.deleteDocument( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', - documentId: '[DOCUMENT_ID]', + databaseId: '<DATABASE_ID>', + collectionId: '<COLLECTION_ID>', + documentId: '<DOCUMENT_ID>', ); }); @@ -953,8 +953,8 @@ void main() { final response = await databases.listIndexes( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', + databaseId: '<DATABASE_ID>', + collectionId: '<COLLECTION_ID>', ); expect(response, isA<models.IndexList>()); @@ -975,8 +975,8 @@ void main() { final response = await databases.createIndex( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', + databaseId: '<DATABASE_ID>', + collectionId: '<COLLECTION_ID>', key: '', type: 'key', attributes: [], @@ -1000,8 +1000,8 @@ void main() { final response = await databases.getIndex( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', + databaseId: '<DATABASE_ID>', + collectionId: '<COLLECTION_ID>', key: '', ); expect(response, isA<models.Index>()); @@ -1017,8 +1017,8 @@ void main() { final response = await databases.deleteIndex( - databaseId: '[DATABASE_ID]', - collectionId: '[COLLECTION_ID]', + databaseId: '<DATABASE_ID>', + collectionId: '<COLLECTION_ID>', key: '', ); }); diff --git a/test/services/functions_test.dart b/test/services/functions_test.dart index c38d068..267db16 100644 --- a/test/services/functions_test.dart +++ b/test/services/functions_test.dart @@ -103,9 +103,9 @@ void main() { final response = await functions.create( - functionId: '[FUNCTION_ID]', - name: '[NAME]', - runtime: 'node-18.0', + functionId: '<FUNCTION_ID>', + name: '<NAME>', + runtime: 'node-14.5', ); expect(response, isA<models.Func>()); @@ -160,7 +160,7 @@ void main() { final response = await functions.get( - functionId: '[FUNCTION_ID]', + functionId: '<FUNCTION_ID>', ); expect(response, isA<models.Func>()); @@ -198,8 +198,8 @@ void main() { final response = await functions.update( - functionId: '[FUNCTION_ID]', - name: '[NAME]', + functionId: '<FUNCTION_ID>', + name: '<NAME>', ); expect(response, isA<models.Func>()); @@ -214,7 +214,7 @@ void main() { final response = await functions.delete( - functionId: '[FUNCTION_ID]', + functionId: '<FUNCTION_ID>', ); }); @@ -230,7 +230,7 @@ void main() { final response = await functions.listDeployments( - functionId: '[FUNCTION_ID]', + functionId: '<FUNCTION_ID>', ); expect(response, isA<models.DeploymentList>()); @@ -273,7 +273,7 @@ void main() { final response = await functions.createDeployment( - functionId: '[FUNCTION_ID]', + functionId: '<FUNCTION_ID>', code: InputFile.fromPath(path: './image.png'), activate: true, ); @@ -314,8 +314,8 @@ void main() { final response = await functions.getDeployment( - functionId: '[FUNCTION_ID]', - deploymentId: '[DEPLOYMENT_ID]', + functionId: '<FUNCTION_ID>', + deploymentId: '<DEPLOYMENT_ID>', ); expect(response, isA<models.Deployment>()); @@ -353,8 +353,8 @@ void main() { final response = await functions.updateDeployment( - functionId: '[FUNCTION_ID]', - deploymentId: '[DEPLOYMENT_ID]', + functionId: '<FUNCTION_ID>', + deploymentId: '<DEPLOYMENT_ID>', ); expect(response, isA<models.Func>()); @@ -369,8 +369,8 @@ void main() { final response = await functions.deleteDeployment( - functionId: '[FUNCTION_ID]', - deploymentId: '[DEPLOYMENT_ID]', + functionId: '<FUNCTION_ID>', + deploymentId: '<DEPLOYMENT_ID>', ); }); @@ -383,9 +383,9 @@ void main() { final response = await functions.createBuild( - functionId: '[FUNCTION_ID]', - deploymentId: '[DEPLOYMENT_ID]', - buildId: '[BUILD_ID]', + functionId: '<FUNCTION_ID>', + deploymentId: '<DEPLOYMENT_ID>', + buildId: '<BUILD_ID>', ); }); @@ -397,8 +397,8 @@ void main() { final response = await functions.downloadDeployment( - functionId: '[FUNCTION_ID]', - deploymentId: '[DEPLOYMENT_ID]', + functionId: '<FUNCTION_ID>', + deploymentId: '<DEPLOYMENT_ID>', ); expect(response, isA<Uint8List>()); @@ -416,7 +416,7 @@ void main() { final response = await functions.listExecutions( - functionId: '[FUNCTION_ID]', + functionId: '<FUNCTION_ID>', ); expect(response, isA<models.ExecutionList>()); @@ -448,7 +448,7 @@ void main() { final response = await functions.createExecution( - functionId: '[FUNCTION_ID]', + functionId: '<FUNCTION_ID>', ); expect(response, isA<models.Execution>()); @@ -480,8 +480,8 @@ void main() { final response = await functions.getExecution( - functionId: '[FUNCTION_ID]', - executionId: '[EXECUTION_ID]', + functionId: '<FUNCTION_ID>', + executionId: '<EXECUTION_ID>', ); expect(response, isA<models.Execution>()); @@ -499,7 +499,7 @@ void main() { final response = await functions.listVariables( - functionId: '[FUNCTION_ID]', + functionId: '<FUNCTION_ID>', ); expect(response, isA<models.VariableList>()); @@ -522,9 +522,9 @@ void main() { final response = await functions.createVariable( - functionId: '[FUNCTION_ID]', - key: '[KEY]', - value: '[VALUE]', + functionId: '<FUNCTION_ID>', + key: '<KEY>', + value: '<VALUE>', ); expect(response, isA<models.Variable>()); @@ -547,8 +547,8 @@ void main() { final response = await functions.getVariable( - functionId: '[FUNCTION_ID]', - variableId: '[VARIABLE_ID]', + functionId: '<FUNCTION_ID>', + variableId: '<VARIABLE_ID>', ); expect(response, isA<models.Variable>()); @@ -571,9 +571,9 @@ void main() { final response = await functions.updateVariable( - functionId: '[FUNCTION_ID]', - variableId: '[VARIABLE_ID]', - key: '[KEY]', + functionId: '<FUNCTION_ID>', + variableId: '<VARIABLE_ID>', + key: '<KEY>', ); expect(response, isA<models.Variable>()); @@ -588,8 +588,8 @@ void main() { final response = await functions.deleteVariable( - functionId: '[FUNCTION_ID]', - variableId: '[VARIABLE_ID]', + functionId: '<FUNCTION_ID>', + variableId: '<VARIABLE_ID>', ); }); diff --git a/test/services/health_test.dart b/test/services/health_test.dart index f73e536..ecbc178 100644 --- a/test/services/health_test.dart +++ b/test/services/health_test.dart @@ -107,6 +107,27 @@ void main() { }); + test('test method getCertificate()', () async { + final Map<String, dynamic> data = { + 'name': '/CN=www.google.com', + 'subjectSN': '', + 'issuerOrganisation': '', + 'validFrom': '1704200998', + 'validTo': '1711458597', + 'signatureTypeSN': 'RSA-SHA256',}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await health.getCertificate( + ); + expect(response, isA<models.HealthCertificate>()); + + }); + test('test method getDB()', () async { final Map<String, dynamic> data = { 'name': 'database', @@ -225,6 +246,23 @@ void main() { }); + test('test method getFailedJobs()', () async { + final Map<String, dynamic> data = { + 'size': 8,}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await health.getFailedJobs( + name: 'v1-database', + ); + expect(response, isA<models.HealthQueue>()); + + }); + test('test method getQueueFunctions()', () async { final Map<String, dynamic> data = { 'size': 8,}; @@ -305,6 +343,38 @@ void main() { }); + test('test method getQueueUsage()', () async { + final Map<String, dynamic> data = { + 'size': 8,}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await health.getQueueUsage( + ); + expect(response, isA<models.HealthQueue>()); + + }); + + test('test method getQueueUsageDump()', () async { + final Map<String, dynamic> data = { + 'size': 8,}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await health.getQueueUsageDump( + ); + expect(response, isA<models.HealthQueue>()); + + }); + test('test method getQueueWebhooks()', () async { final Map<String, dynamic> data = { 'size': 8,}; @@ -321,6 +391,24 @@ void main() { }); + test('test method getStorage()', () async { + final Map<String, dynamic> data = { + 'name': 'database', + 'ping': 128, + 'status': 'pass',}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await health.getStorage( + ); + expect(response, isA<models.HealthStatus>()); + + }); + test('test method getStorageLocal()', () async { final Map<String, dynamic> data = { 'name': 'database', diff --git a/test/services/messaging_test.dart b/test/services/messaging_test.dart new file mode 100644 index 0000000..31db4ac --- /dev/null +++ b/test/services/messaging_test.dart @@ -0,0 +1,1098 @@ +import 'package:test/test.dart'; +import 'package:mockito/mockito.dart'; +import 'package:dart_appwrite/models.dart' as models; +import 'package:dart_appwrite/src/enums.dart'; +import 'package:dart_appwrite/src/response.dart'; +import 'dart:typed_data'; +import 'package:dart_appwrite/dart_appwrite.dart'; + +class MockClient extends Mock implements Client { + Map<String, String> config = {'project': 'testproject'}; + String endPoint = 'https://localhost/v1'; + @override + Future<Response> call( + HttpMethod? method, { + String path = '', + Map<String, String> headers = const {}, + Map<String, dynamic> params = const {}, + ResponseType? responseType, + }) async { + return super.noSuchMethod(Invocation.method(#call, [method]), + returnValue: Response()); + } + + @override + Future webAuth( + Uri? url, + { + String? callbackUrlScheme, + } + ) async { + return super.noSuchMethod(Invocation.method(#webAuth, [url]), returnValue: 'done'); + } + + @override + Future<Response> chunkedUpload({ + String? path, + Map<String, dynamic>? params, + String? paramName, + String? idParamName, + Map<String, String>? headers, + Function(UploadProgress)? onProgress, + }) async { + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + } +} + +void main() { + group('Messaging test', () { + late MockClient client; + late Messaging messaging; + + setUp(() { + client = MockClient(); + messaging = Messaging(client); + }); + + test('test method listMessages()', () async { + final Map<String, dynamic> data = { + 'total': 5, + 'messages': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.listMessages( + ); + expect(response, isA<models.MessageList>()); + + }); + + test('test method createEmail()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'providerType': 'email', + 'topics': [], + 'users': [], + 'targets': [], + 'deliveredTotal': 1, + 'data': <String, dynamic>{}, + 'status': 'Message status can be one of the following: draft, processing, scheduled, sent, or failed.',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.createEmail( + messageId: '<MESSAGE_ID>', + subject: '<SUBJECT>', + content: '<CONTENT>', + ); + expect(response, isA<models.Message>()); + + }); + + test('test method updateEmail()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'providerType': 'email', + 'topics': [], + 'users': [], + 'targets': [], + 'deliveredTotal': 1, + 'data': <String, dynamic>{}, + 'status': 'Message status can be one of the following: draft, processing, scheduled, sent, or failed.',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.updateEmail( + messageId: '<MESSAGE_ID>', + ); + expect(response, isA<models.Message>()); + + }); + + test('test method createPush()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'providerType': 'email', + 'topics': [], + 'users': [], + 'targets': [], + 'deliveredTotal': 1, + 'data': <String, dynamic>{}, + 'status': 'Message status can be one of the following: draft, processing, scheduled, sent, or failed.',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.createPush( + messageId: '<MESSAGE_ID>', + title: '<TITLE>', + body: '<BODY>', + ); + expect(response, isA<models.Message>()); + + }); + + test('test method updatePush()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'providerType': 'email', + 'topics': [], + 'users': [], + 'targets': [], + 'deliveredTotal': 1, + 'data': <String, dynamic>{}, + 'status': 'Message status can be one of the following: draft, processing, scheduled, sent, or failed.',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.updatePush( + messageId: '<MESSAGE_ID>', + ); + expect(response, isA<models.Message>()); + + }); + + test('test method createSms()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'providerType': 'email', + 'topics': [], + 'users': [], + 'targets': [], + 'deliveredTotal': 1, + 'data': <String, dynamic>{}, + 'status': 'Message status can be one of the following: draft, processing, scheduled, sent, or failed.',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.createSms( + messageId: '<MESSAGE_ID>', + content: '<CONTENT>', + ); + expect(response, isA<models.Message>()); + + }); + + test('test method updateSms()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'providerType': 'email', + 'topics': [], + 'users': [], + 'targets': [], + 'deliveredTotal': 1, + 'data': <String, dynamic>{}, + 'status': 'Message status can be one of the following: draft, processing, scheduled, sent, or failed.',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.updateSms( + messageId: '<MESSAGE_ID>', + ); + expect(response, isA<models.Message>()); + + }); + + test('test method getMessage()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'providerType': 'email', + 'topics': [], + 'users': [], + 'targets': [], + 'deliveredTotal': 1, + 'data': <String, dynamic>{}, + 'status': 'Message status can be one of the following: draft, processing, scheduled, sent, or failed.',}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.getMessage( + messageId: '<MESSAGE_ID>', + ); + expect(response, isA<models.Message>()); + + }); + + test('test method delete()', () async { + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.delete( + messageId: '<MESSAGE_ID>', + ); + }); + + test('test method listMessageLogs()', () async { + final Map<String, dynamic> data = { + 'total': 5, + 'logs': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.listMessageLogs( + messageId: '<MESSAGE_ID>', + ); + expect(response, isA<models.LogList>()); + + }); + + test('test method listTargets()', () async { + final Map<String, dynamic> data = { + 'total': 5, + 'targets': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.listTargets( + messageId: '<MESSAGE_ID>', + ); + expect(response, isA<models.TargetList>()); + + }); + + test('test method listProviders()', () async { + final Map<String, dynamic> data = { + 'total': 5, + 'providers': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.listProviders( + ); + expect(response, isA<models.ProviderList>()); + + }); + + test('test method createApnsProvider()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': <String, dynamic>{},}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.createApnsProvider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', + ); + expect(response, isA<models.Provider>()); + + }); + + test('test method updateApnsProvider()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': <String, dynamic>{},}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.updateApnsProvider( + providerId: '<PROVIDER_ID>', + ); + expect(response, isA<models.Provider>()); + + }); + + test('test method createFcmProvider()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': <String, dynamic>{},}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.createFcmProvider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', + ); + expect(response, isA<models.Provider>()); + + }); + + test('test method updateFcmProvider()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': <String, dynamic>{},}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.updateFcmProvider( + providerId: '<PROVIDER_ID>', + ); + expect(response, isA<models.Provider>()); + + }); + + test('test method createMailgunProvider()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': <String, dynamic>{},}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.createMailgunProvider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', + ); + expect(response, isA<models.Provider>()); + + }); + + test('test method updateMailgunProvider()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': <String, dynamic>{},}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.updateMailgunProvider( + providerId: '<PROVIDER_ID>', + ); + expect(response, isA<models.Provider>()); + + }); + + test('test method createMsg91Provider()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': <String, dynamic>{},}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.createMsg91Provider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', + ); + expect(response, isA<models.Provider>()); + + }); + + test('test method updateMsg91Provider()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': <String, dynamic>{},}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.updateMsg91Provider( + providerId: '<PROVIDER_ID>', + ); + expect(response, isA<models.Provider>()); + + }); + + test('test method createSendgridProvider()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': <String, dynamic>{},}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.createSendgridProvider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', + ); + expect(response, isA<models.Provider>()); + + }); + + test('test method updateSendgridProvider()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': <String, dynamic>{},}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.updateSendgridProvider( + providerId: '<PROVIDER_ID>', + ); + expect(response, isA<models.Provider>()); + + }); + + test('test method createSmtpProvider()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': <String, dynamic>{},}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.createSmtpProvider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', + host: '<HOST>', + ); + expect(response, isA<models.Provider>()); + + }); + + test('test method updateSmtpProvider()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': <String, dynamic>{},}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.updateSmtpProvider( + providerId: '<PROVIDER_ID>', + ); + expect(response, isA<models.Provider>()); + + }); + + test('test method createTelesignProvider()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': <String, dynamic>{},}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.createTelesignProvider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', + ); + expect(response, isA<models.Provider>()); + + }); + + test('test method updateTelesignProvider()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': <String, dynamic>{},}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.updateTelesignProvider( + providerId: '<PROVIDER_ID>', + ); + expect(response, isA<models.Provider>()); + + }); + + test('test method createTextmagicProvider()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': <String, dynamic>{},}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.createTextmagicProvider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', + ); + expect(response, isA<models.Provider>()); + + }); + + test('test method updateTextmagicProvider()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': <String, dynamic>{},}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.updateTextmagicProvider( + providerId: '<PROVIDER_ID>', + ); + expect(response, isA<models.Provider>()); + + }); + + test('test method createTwilioProvider()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': <String, dynamic>{},}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.createTwilioProvider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', + ); + expect(response, isA<models.Provider>()); + + }); + + test('test method updateTwilioProvider()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': <String, dynamic>{},}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.updateTwilioProvider( + providerId: '<PROVIDER_ID>', + ); + expect(response, isA<models.Provider>()); + + }); + + test('test method createVonageProvider()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': <String, dynamic>{},}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.createVonageProvider( + providerId: '<PROVIDER_ID>', + name: '<NAME>', + ); + expect(response, isA<models.Provider>()); + + }); + + test('test method updateVonageProvider()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': <String, dynamic>{},}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.updateVonageProvider( + providerId: '<PROVIDER_ID>', + ); + expect(response, isA<models.Provider>()); + + }); + + test('test method getProvider()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Mailgun', + 'provider': 'mailgun', + 'enabled': true, + 'type': 'sms', + 'credentials': <String, dynamic>{},}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.getProvider( + providerId: '<PROVIDER_ID>', + ); + expect(response, isA<models.Provider>()); + + }); + + test('test method deleteProvider()', () async { + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.deleteProvider( + providerId: '<PROVIDER_ID>', + ); + }); + + test('test method listProviderLogs()', () async { + final Map<String, dynamic> data = { + 'total': 5, + 'logs': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.listProviderLogs( + providerId: '<PROVIDER_ID>', + ); + expect(response, isA<models.LogList>()); + + }); + + test('test method listSubscriberLogs()', () async { + final Map<String, dynamic> data = { + 'total': 5, + 'logs': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.listSubscriberLogs( + subscriberId: '<SUBSCRIBER_ID>', + ); + expect(response, isA<models.LogList>()); + + }); + + test('test method listTopics()', () async { + final Map<String, dynamic> data = { + 'total': 5, + 'topics': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.listTopics( + ); + expect(response, isA<models.TopicList>()); + + }); + + test('test method createTopic()', () async { + final Map<String, dynamic> data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'events', + 'emailTotal': 100, + 'smsTotal': 100, + 'pushTotal': 100, + 'subscribe': [],}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.createTopic( + topicId: '<TOPIC_ID>', + name: '<NAME>', + ); + expect(response, isA<models.Topic>()); + + }); + + test('test method getTopic()', () async { + final Map<String, dynamic> data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'events', + 'emailTotal': 100, + 'smsTotal': 100, + 'pushTotal': 100, + 'subscribe': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.getTopic( + topicId: '<TOPIC_ID>', + ); + expect(response, isA<models.Topic>()); + + }); + + test('test method updateTopic()', () async { + final Map<String, dynamic> data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'events', + 'emailTotal': 100, + 'smsTotal': 100, + 'pushTotal': 100, + 'subscribe': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.updateTopic( + topicId: '<TOPIC_ID>', + ); + expect(response, isA<models.Topic>()); + + }); + + test('test method deleteTopic()', () async { + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.deleteTopic( + topicId: '<TOPIC_ID>', + ); + }); + + test('test method listTopicLogs()', () async { + final Map<String, dynamic> data = { + 'total': 5, + 'logs': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.listTopicLogs( + topicId: '<TOPIC_ID>', + ); + expect(response, isA<models.LogList>()); + + }); + + test('test method listSubscribers()', () async { + final Map<String, dynamic> data = { + 'total': 5, + 'subscribers': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.listSubscribers( + topicId: '<TOPIC_ID>', + ); + expect(response, isA<models.SubscriberList>()); + + }); + + test('test method createSubscriber()', () async { + final Map<String, dynamic> data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'targetId': '259125845563242502', + 'target': <String, dynamic>{}, + 'userId': '5e5ea5c16897e', + 'userName': 'Aegon Targaryen', + 'topicId': '259125845563242502', + 'providerType': 'email',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.createSubscriber( + topicId: '<TOPIC_ID>', + subscriberId: '<SUBSCRIBER_ID>', + targetId: '<TARGET_ID>', + ); + expect(response, isA<models.Subscriber>()); + + }); + + test('test method getSubscriber()', () async { + final Map<String, dynamic> data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'targetId': '259125845563242502', + 'target': <String, dynamic>{}, + 'userId': '5e5ea5c16897e', + 'userName': 'Aegon Targaryen', + 'topicId': '259125845563242502', + 'providerType': 'email',}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.getSubscriber( + topicId: '<TOPIC_ID>', + subscriberId: '<SUBSCRIBER_ID>', + ); + expect(response, isA<models.Subscriber>()); + + }); + + test('test method deleteSubscriber()', () async { + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await messaging.deleteSubscriber( + topicId: '<TOPIC_ID>', + subscriberId: '<SUBSCRIBER_ID>', + ); + }); + + }); +} \ No newline at end of file diff --git a/test/services/storage_test.dart b/test/services/storage_test.dart index 78ed21c..c2a81fa 100644 --- a/test/services/storage_test.dart +++ b/test/services/storage_test.dart @@ -93,8 +93,8 @@ void main() { final response = await storage.createBucket( - bucketId: '[BUCKET_ID]', - name: '[NAME]', + bucketId: '<BUCKET_ID>', + name: '<NAME>', ); expect(response, isA<models.Bucket>()); @@ -122,7 +122,7 @@ void main() { final response = await storage.getBucket( - bucketId: '[BUCKET_ID]', + bucketId: '<BUCKET_ID>', ); expect(response, isA<models.Bucket>()); @@ -150,8 +150,8 @@ void main() { final response = await storage.updateBucket( - bucketId: '[BUCKET_ID]', - name: '[NAME]', + bucketId: '<BUCKET_ID>', + name: '<NAME>', ); expect(response, isA<models.Bucket>()); @@ -166,7 +166,7 @@ void main() { final response = await storage.deleteBucket( - bucketId: '[BUCKET_ID]', + bucketId: '<BUCKET_ID>', ); }); @@ -182,7 +182,7 @@ void main() { final response = await storage.listFiles( - bucketId: '[BUCKET_ID]', + bucketId: '<BUCKET_ID>', ); expect(response, isA<models.FileList>()); @@ -213,8 +213,8 @@ void main() { final response = await storage.createFile( - bucketId: '[BUCKET_ID]', - fileId: '[FILE_ID]', + bucketId: '<BUCKET_ID>', + fileId: '<FILE_ID>', file: InputFile.fromPath(path: './image.png'), ); expect(response, isA<models.File>()); @@ -242,8 +242,8 @@ void main() { final response = await storage.getFile( - bucketId: '[BUCKET_ID]', - fileId: '[FILE_ID]', + bucketId: '<BUCKET_ID>', + fileId: '<FILE_ID>', ); expect(response, isA<models.File>()); @@ -270,8 +270,8 @@ void main() { final response = await storage.updateFile( - bucketId: '[BUCKET_ID]', - fileId: '[FILE_ID]', + bucketId: '<BUCKET_ID>', + fileId: '<FILE_ID>', ); expect(response, isA<models.File>()); @@ -286,8 +286,8 @@ void main() { final response = await storage.deleteFile( - bucketId: '[BUCKET_ID]', - fileId: '[FILE_ID]', + bucketId: '<BUCKET_ID>', + fileId: '<FILE_ID>', ); }); @@ -299,8 +299,8 @@ void main() { final response = await storage.getFileDownload( - bucketId: '[BUCKET_ID]', - fileId: '[FILE_ID]', + bucketId: '<BUCKET_ID>', + fileId: '<FILE_ID>', ); expect(response, isA<Uint8List>()); @@ -314,8 +314,8 @@ void main() { final response = await storage.getFilePreview( - bucketId: '[BUCKET_ID]', - fileId: '[FILE_ID]', + bucketId: '<BUCKET_ID>', + fileId: '<FILE_ID>', ); expect(response, isA<Uint8List>()); @@ -329,8 +329,8 @@ void main() { final response = await storage.getFileView( - bucketId: '[BUCKET_ID]', - fileId: '[FILE_ID]', + bucketId: '<BUCKET_ID>', + fileId: '<FILE_ID>', ); expect(response, isA<Uint8List>()); diff --git a/test/services/teams_test.dart b/test/services/teams_test.dart index 2ffec71..891610e 100644 --- a/test/services/teams_test.dart +++ b/test/services/teams_test.dart @@ -87,8 +87,8 @@ void main() { final response = await teams.create( - teamId: '[TEAM_ID]', - name: '[NAME]', + teamId: '<TEAM_ID>', + name: '<NAME>', ); expect(response, isA<models.Team>()); @@ -110,7 +110,7 @@ void main() { final response = await teams.get( - teamId: '[TEAM_ID]', + teamId: '<TEAM_ID>', ); expect(response, isA<models.Team>()); @@ -132,8 +132,8 @@ void main() { final response = await teams.updateName( - teamId: '[TEAM_ID]', - name: '[NAME]', + teamId: '<TEAM_ID>', + name: '<NAME>', ); expect(response, isA<models.Team>()); @@ -148,7 +148,7 @@ void main() { final response = await teams.delete( - teamId: '[TEAM_ID]', + teamId: '<TEAM_ID>', ); }); @@ -164,7 +164,7 @@ void main() { final response = await teams.listMemberships( - teamId: '[TEAM_ID]', + teamId: '<TEAM_ID>', ); expect(response, isA<models.MembershipList>()); @@ -183,6 +183,7 @@ void main() { 'invited': '2020-10-15T06:38:00.000+00:00', 'joined': '2020-10-15T06:38:00.000+00:00', 'confirm': true, + 'mfa': true, 'roles': [],}; @@ -192,7 +193,7 @@ void main() { final response = await teams.createMembership( - teamId: '[TEAM_ID]', + teamId: '<TEAM_ID>', roles: [], ); expect(response, isA<models.Membership>()); @@ -212,6 +213,7 @@ void main() { 'invited': '2020-10-15T06:38:00.000+00:00', 'joined': '2020-10-15T06:38:00.000+00:00', 'confirm': true, + 'mfa': true, 'roles': [],}; @@ -221,8 +223,8 @@ void main() { final response = await teams.getMembership( - teamId: '[TEAM_ID]', - membershipId: '[MEMBERSHIP_ID]', + teamId: '<TEAM_ID>', + membershipId: '<MEMBERSHIP_ID>', ); expect(response, isA<models.Membership>()); @@ -241,6 +243,7 @@ void main() { 'invited': '2020-10-15T06:38:00.000+00:00', 'joined': '2020-10-15T06:38:00.000+00:00', 'confirm': true, + 'mfa': true, 'roles': [],}; @@ -250,8 +253,8 @@ void main() { final response = await teams.updateMembership( - teamId: '[TEAM_ID]', - membershipId: '[MEMBERSHIP_ID]', + teamId: '<TEAM_ID>', + membershipId: '<MEMBERSHIP_ID>', roles: [], ); expect(response, isA<models.Membership>()); @@ -267,8 +270,8 @@ void main() { final response = await teams.deleteMembership( - teamId: '[TEAM_ID]', - membershipId: '[MEMBERSHIP_ID]', + teamId: '<TEAM_ID>', + membershipId: '<MEMBERSHIP_ID>', ); }); @@ -285,6 +288,7 @@ void main() { 'invited': '2020-10-15T06:38:00.000+00:00', 'joined': '2020-10-15T06:38:00.000+00:00', 'confirm': true, + 'mfa': true, 'roles': [],}; @@ -294,10 +298,10 @@ void main() { final response = await teams.updateMembershipStatus( - teamId: '[TEAM_ID]', - membershipId: '[MEMBERSHIP_ID]', - userId: '[USER_ID]', - secret: '[SECRET]', + teamId: '<TEAM_ID>', + membershipId: '<MEMBERSHIP_ID>', + userId: '<USER_ID>', + secret: '<SECRET>', ); expect(response, isA<models.Membership>()); @@ -313,7 +317,7 @@ void main() { final response = await teams.getPrefs( - teamId: '[TEAM_ID]', + teamId: '<TEAM_ID>', ); expect(response, isA<models.Preferences>()); @@ -329,7 +333,7 @@ void main() { final response = await teams.updatePrefs( - teamId: '[TEAM_ID]', + teamId: '<TEAM_ID>', prefs: {}, ); expect(response, isA<models.Preferences>()); diff --git a/test/services/users_test.dart b/test/services/users_test.dart index bb923ab..e034d08 100644 --- a/test/services/users_test.dart +++ b/test/services/users_test.dart @@ -85,7 +85,9 @@ void main() { 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, + 'mfa': true, 'prefs': <String, dynamic>{}, + 'targets': [], 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; @@ -95,7 +97,7 @@ void main() { final response = await users.create( - userId: '[USER_ID]', + userId: '<USER_ID>', ); expect(response, isA<models.User>()); @@ -115,7 +117,9 @@ void main() { 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, + 'mfa': true, 'prefs': <String, dynamic>{}, + 'targets': [], 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; @@ -125,7 +129,7 @@ void main() { final response = await users.createArgon2User( - userId: '[USER_ID]', + userId: '<USER_ID>', email: 'email@example.com', password: 'password', ); @@ -147,7 +151,9 @@ void main() { 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, + 'mfa': true, 'prefs': <String, dynamic>{}, + 'targets': [], 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; @@ -157,7 +163,7 @@ void main() { final response = await users.createBcryptUser( - userId: '[USER_ID]', + userId: '<USER_ID>', email: 'email@example.com', password: 'password', ); @@ -191,7 +197,7 @@ void main() { final response = await users.deleteIdentity( - identityId: '[IDENTITY_ID]', + identityId: '<IDENTITY_ID>', ); }); @@ -209,7 +215,9 @@ void main() { 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, + 'mfa': true, 'prefs': <String, dynamic>{}, + 'targets': [], 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; @@ -219,7 +227,7 @@ void main() { final response = await users.createMD5User( - userId: '[USER_ID]', + userId: '<USER_ID>', email: 'email@example.com', password: 'password', ); @@ -241,7 +249,9 @@ void main() { 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, + 'mfa': true, 'prefs': <String, dynamic>{}, + 'targets': [], 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; @@ -251,7 +261,7 @@ void main() { final response = await users.createPHPassUser( - userId: '[USER_ID]', + userId: '<USER_ID>', email: 'email@example.com', password: 'password', ); @@ -273,7 +283,9 @@ void main() { 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, + 'mfa': true, 'prefs': <String, dynamic>{}, + 'targets': [], 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; @@ -283,10 +295,10 @@ void main() { final response = await users.createScryptUser( - userId: '[USER_ID]', + userId: '<USER_ID>', email: 'email@example.com', password: 'password', - passwordSalt: '[PASSWORD_SALT]', + passwordSalt: '<PASSWORD_SALT>', passwordCpu: 1, passwordMemory: 1, passwordParallel: 1, @@ -310,7 +322,9 @@ void main() { 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, + 'mfa': true, 'prefs': <String, dynamic>{}, + 'targets': [], 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; @@ -320,12 +334,12 @@ void main() { final response = await users.createScryptModifiedUser( - userId: '[USER_ID]', + userId: '<USER_ID>', email: 'email@example.com', password: 'password', - passwordSalt: '[PASSWORD_SALT]', - passwordSaltSeparator: '[PASSWORD_SALT_SEPARATOR]', - passwordSignerKey: '[PASSWORD_SIGNER_KEY]', + passwordSalt: '<PASSWORD_SALT>', + passwordSaltSeparator: '<PASSWORD_SALT_SEPARATOR>', + passwordSignerKey: '<PASSWORD_SIGNER_KEY>', ); expect(response, isA<models.User>()); @@ -345,7 +359,9 @@ void main() { 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, + 'mfa': true, 'prefs': <String, dynamic>{}, + 'targets': [], 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; @@ -355,7 +371,7 @@ void main() { final response = await users.createSHAUser( - userId: '[USER_ID]', + userId: '<USER_ID>', email: 'email@example.com', password: 'password', ); @@ -377,7 +393,9 @@ void main() { 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, + 'mfa': true, 'prefs': <String, dynamic>{}, + 'targets': [], 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; @@ -387,7 +405,7 @@ void main() { final response = await users.get( - userId: '[USER_ID]', + userId: '<USER_ID>', ); expect(response, isA<models.User>()); @@ -402,7 +420,7 @@ void main() { final response = await users.delete( - userId: '[USER_ID]', + userId: '<USER_ID>', ); }); @@ -420,7 +438,9 @@ void main() { 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, + 'mfa': true, 'prefs': <String, dynamic>{}, + 'targets': [], 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; @@ -430,7 +450,7 @@ void main() { final response = await users.updateEmail( - userId: '[USER_ID]', + userId: '<USER_ID>', email: 'email@example.com', ); expect(response, isA<models.User>()); @@ -451,7 +471,9 @@ void main() { 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, + 'mfa': true, 'prefs': <String, dynamic>{}, + 'targets': [], 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; @@ -461,7 +483,7 @@ void main() { final response = await users.updateLabels( - userId: '[USER_ID]', + userId: '<USER_ID>', labels: [], ); expect(response, isA<models.User>()); @@ -480,7 +502,7 @@ void main() { final response = await users.listLogs( - userId: '[USER_ID]', + userId: '<USER_ID>', ); expect(response, isA<models.LogList>()); @@ -498,12 +520,148 @@ void main() { final response = await users.listMemberships( - userId: '[USER_ID]', + userId: '<USER_ID>', ); expect(response, isA<models.MembershipList>()); }); + test('test method updateMfa()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': <String, dynamic>{}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.updateMfa( + userId: '<USER_ID>', + mfa: true, + ); + expect(response, isA<models.User>()); + + }); + + test('test method deleteMfaAuthenticator()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'John Doe', + 'registration': '2020-10-15T06:38:00.000+00:00', + 'status': true, + 'labels': [], + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': <String, dynamic>{}, + 'targets': [], + 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.deleteMfaAuthenticator( + userId: '<USER_ID>', + type: 'totp', + ); + expect(response, isA<models.User>()); + + }); + + test('test method listMfaFactors()', () async { + final Map<String, dynamic> data = { + 'totp': true, + 'phone': true, + 'email': true,}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.listMfaFactors( + userId: '<USER_ID>', + ); + expect(response, isA<models.MfaFactors>()); + + }); + + test('test method getMfaRecoveryCodes()', () async { + final Map<String, dynamic> data = { + 'recoveryCodes': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.getMfaRecoveryCodes( + userId: '<USER_ID>', + ); + expect(response, isA<models.MfaRecoveryCodes>()); + + }); + + test('test method updateMfaRecoveryCodes()', () async { + final Map<String, dynamic> data = { + 'recoveryCodes': [],}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.updateMfaRecoveryCodes( + userId: '<USER_ID>', + ); + expect(response, isA<models.MfaRecoveryCodes>()); + + }); + + test('test method createMfaRecoveryCodes()', () async { + final Map<String, dynamic> data = { + 'recoveryCodes': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.createMfaRecoveryCodes( + userId: '<USER_ID>', + ); + expect(response, isA<models.MfaRecoveryCodes>()); + + }); + test('test method updateName()', () async { final Map<String, dynamic> data = { '\$id': '5e5ea5c16897e', @@ -518,7 +676,9 @@ void main() { 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, + 'mfa': true, 'prefs': <String, dynamic>{}, + 'targets': [], 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; @@ -528,8 +688,8 @@ void main() { final response = await users.updateName( - userId: '[USER_ID]', - name: '[NAME]', + userId: '<USER_ID>', + name: '<NAME>', ); expect(response, isA<models.User>()); @@ -549,7 +709,9 @@ void main() { 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, + 'mfa': true, 'prefs': <String, dynamic>{}, + 'targets': [], 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; @@ -559,7 +721,7 @@ void main() { final response = await users.updatePassword( - userId: '[USER_ID]', + userId: '<USER_ID>', password: '', ); expect(response, isA<models.User>()); @@ -580,7 +742,9 @@ void main() { 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, + 'mfa': true, 'prefs': <String, dynamic>{}, + 'targets': [], 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; @@ -590,7 +754,7 @@ void main() { final response = await users.updatePhone( - userId: '[USER_ID]', + userId: '<USER_ID>', number: '+12065550100', ); expect(response, isA<models.User>()); @@ -607,7 +771,7 @@ void main() { final response = await users.getPrefs( - userId: '[USER_ID]', + userId: '<USER_ID>', ); expect(response, isA<models.Preferences>()); @@ -623,7 +787,7 @@ void main() { final response = await users.updatePrefs( - userId: '[USER_ID]', + userId: '<USER_ID>', prefs: {}, ); expect(response, isA<models.Preferences>()); @@ -642,12 +806,56 @@ void main() { final response = await users.listSessions( - userId: '[USER_ID]', + userId: '<USER_ID>', ); expect(response, isA<models.SessionList>()); }); + test('test method createSession()', () async { + final Map<String, dynamic> data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5bb8c16897e', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'provider': 'email', + 'providerUid': 'user@example.com', + 'providerAccessToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'providerAccessTokenExpiry': '2020-10-15T06:38:00.000+00:00', + 'providerRefreshToken': 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3', + 'ip': '127.0.0.1', + 'osCode': 'Mac', + 'osName': 'Mac', + 'osVersion': 'Mac', + 'clientType': 'browser', + 'clientCode': 'CM', + 'clientName': 'Chrome Mobile iOS', + 'clientVersion': '84.0', + 'clientEngine': 'WebKit', + 'clientEngineVersion': '605.1.15', + 'deviceName': 'smartphone', + 'deviceBrand': 'Google', + 'deviceModel': 'Nexus 5', + 'countryCode': 'US', + 'countryName': 'United States', + 'current': true, + 'factors': [], + 'secret': '5e5bb8c16897e', + 'mfaUpdatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.createSession( + userId: '<USER_ID>', + ); + expect(response, isA<models.Session>()); + + }); + test('test method deleteSessions()', () async { final data = ''; @@ -657,7 +865,7 @@ void main() { final response = await users.deleteSessions( - userId: '[USER_ID]', + userId: '<USER_ID>', ); }); @@ -670,8 +878,8 @@ void main() { final response = await users.deleteSession( - userId: '[USER_ID]', - sessionId: '[SESSION_ID]', + userId: '<USER_ID>', + sessionId: '<SESSION_ID>', ); }); @@ -689,7 +897,9 @@ void main() { 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, + 'mfa': true, 'prefs': <String, dynamic>{}, + 'targets': [], 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; @@ -699,13 +909,141 @@ void main() { final response = await users.updateStatus( - userId: '[USER_ID]', + userId: '<USER_ID>', status: true, ); expect(response, isA<models.User>()); }); + test('test method listTargets()', () async { + final Map<String, dynamic> data = { + 'total': 5, + 'targets': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.listTargets( + userId: '<USER_ID>', + ); + expect(response, isA<models.TargetList>()); + + }); + + test('test method createTarget()', () async { + final Map<String, dynamic> data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Aegon apple token', + 'userId': '259125845563242502', + 'providerType': 'email', + 'identifier': 'token',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.createTarget( + userId: '<USER_ID>', + targetId: '<TARGET_ID>', + providerType: 'email', + identifier: '<IDENTIFIER>', + ); + expect(response, isA<models.Target>()); + + }); + + test('test method getTarget()', () async { + final Map<String, dynamic> data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Aegon apple token', + 'userId': '259125845563242502', + 'providerType': 'email', + 'identifier': 'token',}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.getTarget( + userId: '<USER_ID>', + targetId: '<TARGET_ID>', + ); + expect(response, isA<models.Target>()); + + }); + + test('test method updateTarget()', () async { + final Map<String, dynamic> data = { + '\$id': '259125845563242502', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'Aegon apple token', + 'userId': '259125845563242502', + 'providerType': 'email', + 'identifier': 'token',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.updateTarget( + userId: '<USER_ID>', + targetId: '<TARGET_ID>', + ); + expect(response, isA<models.Target>()); + + }); + + test('test method deleteTarget()', () async { + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.deleteTarget( + userId: '<USER_ID>', + targetId: '<TARGET_ID>', + ); + }); + + test('test method createToken()', () async { + final Map<String, dynamic> data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00', + 'phrase': 'Golden Fox',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.createToken( + userId: '<USER_ID>', + ); + expect(response, isA<models.Token>()); + + }); + test('test method updateEmailVerification()', () async { final Map<String, dynamic> data = { '\$id': '5e5ea5c16897e', @@ -720,7 +1058,9 @@ void main() { 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, + 'mfa': true, 'prefs': <String, dynamic>{}, + 'targets': [], 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; @@ -730,7 +1070,7 @@ void main() { final response = await users.updateEmailVerification( - userId: '[USER_ID]', + userId: '<USER_ID>', emailVerification: true, ); expect(response, isA<models.User>()); @@ -751,7 +1091,9 @@ void main() { 'phone': '+4930901820', 'emailVerification': true, 'phoneVerification': true, + 'mfa': true, 'prefs': <String, dynamic>{}, + 'targets': [], 'accessedAt': '2020-10-15T06:38:00.000+00:00',}; @@ -761,7 +1103,7 @@ void main() { final response = await users.updatePhoneVerification( - userId: '[USER_ID]', + userId: '<USER_ID>', phoneVerification: true, ); expect(response, isA<models.User>()); diff --git a/test/src/models/health_certificate_test.dart b/test/src/models/health_certificate_test.dart new file mode 100644 index 0000000..2277d92 --- /dev/null +++ b/test/src/models/health_certificate_test.dart @@ -0,0 +1,28 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('HealthCertificate', () { + + test('model', () { + final model = HealthCertificate( + name: '/CN=www.google.com', + subjectSN: '', + issuerOrganisation: '', + validFrom: '1704200998', + validTo: '1711458597', + signatureTypeSN: 'RSA-SHA256', + ); + + final map = model.toMap(); + final result = HealthCertificate.fromMap(map); + + expect(result.name, '/CN=www.google.com'); + expect(result.subjectSN, ''); + expect(result.issuerOrganisation, ''); + expect(result.validFrom, '1704200998'); + expect(result.validTo, '1711458597'); + expect(result.signatureTypeSN, 'RSA-SHA256'); + }); + }); +} diff --git a/test/src/models/jwt_test.dart b/test/src/models/jwt_test.dart new file mode 100644 index 0000000..db56a03 --- /dev/null +++ b/test/src/models/jwt_test.dart @@ -0,0 +1,18 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('Jwt', () { + + test('model', () { + final model = Jwt( + jwt: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', + ); + + final map = model.toMap(); + final result = Jwt.fromMap(map); + + expect(result.jwt, 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'); + }); + }); +} diff --git a/test/src/models/membership_test.dart b/test/src/models/membership_test.dart index 6a6f820..23cfbd6 100644 --- a/test/src/models/membership_test.dart +++ b/test/src/models/membership_test.dart @@ -17,6 +17,7 @@ void main() { invited: '2020-10-15T06:38:00.000+00:00', joined: '2020-10-15T06:38:00.000+00:00', confirm: true, + mfa: true, roles: [], ); @@ -34,6 +35,7 @@ void main() { expect(result.invited, '2020-10-15T06:38:00.000+00:00'); expect(result.joined, '2020-10-15T06:38:00.000+00:00'); expect(result.confirm, true); + expect(result.mfa, true); expect(result.roles, []); }); }); diff --git a/test/src/models/message_list_test.dart b/test/src/models/message_list_test.dart new file mode 100644 index 0000000..73cbf14 --- /dev/null +++ b/test/src/models/message_list_test.dart @@ -0,0 +1,20 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('MessageList', () { + + test('model', () { + final model = MessageList( + total: 5, + messages: [], + ); + + final map = model.toMap(); + final result = MessageList.fromMap(map); + + expect(result.total, 5); + expect(result.messages, []); + }); + }); +} diff --git a/test/src/models/message_test.dart b/test/src/models/message_test.dart new file mode 100644 index 0000000..4412583 --- /dev/null +++ b/test/src/models/message_test.dart @@ -0,0 +1,36 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('Message', () { + + test('model', () { + final model = Message( + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + providerType: 'email', + topics: [], + users: [], + targets: [], + deliveredTotal: 1, + data: {}, + status: 'Message status can be one of the following: draft, processing, scheduled, sent, or failed.', + ); + + final map = model.toMap(); + final result = Message.fromMap(map); + + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.providerType, 'email'); + expect(result.topics, []); + expect(result.users, []); + expect(result.targets, []); + expect(result.deliveredTotal, 1); + expect(result.data, {}); + expect(result.status, 'Message status can be one of the following: draft, processing, scheduled, sent, or failed.'); + }); + }); +} diff --git a/test/src/models/mfa_challenge_test.dart b/test/src/models/mfa_challenge_test.dart new file mode 100644 index 0000000..fff934e --- /dev/null +++ b/test/src/models/mfa_challenge_test.dart @@ -0,0 +1,24 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('MfaChallenge', () { + + test('model', () { + final model = MfaChallenge( + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + userId: '5e5ea5c168bb8', + expire: '2020-10-15T06:38:00.000+00:00', + ); + + final map = model.toMap(); + final result = MfaChallenge.fromMap(map); + + expect(result.$id, 'bb8ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5ea5c168bb8'); + expect(result.expire, '2020-10-15T06:38:00.000+00:00'); + }); + }); +} diff --git a/test/src/models/mfa_factors_test.dart b/test/src/models/mfa_factors_test.dart new file mode 100644 index 0000000..e27138e --- /dev/null +++ b/test/src/models/mfa_factors_test.dart @@ -0,0 +1,22 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('MfaFactors', () { + + test('model', () { + final model = MfaFactors( + totp: true, + phone: true, + email: true, + ); + + final map = model.toMap(); + final result = MfaFactors.fromMap(map); + + expect(result.totp, true); + expect(result.phone, true); + expect(result.email, true); + }); + }); +} diff --git a/test/src/models/mfa_recovery_codes_test.dart b/test/src/models/mfa_recovery_codes_test.dart new file mode 100644 index 0000000..56555ca --- /dev/null +++ b/test/src/models/mfa_recovery_codes_test.dart @@ -0,0 +1,18 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('MfaRecoveryCodes', () { + + test('model', () { + final model = MfaRecoveryCodes( + recoveryCodes: [], + ); + + final map = model.toMap(); + final result = MfaRecoveryCodes.fromMap(map); + + expect(result.recoveryCodes, []); + }); + }); +} diff --git a/test/src/models/mfa_type_test.dart b/test/src/models/mfa_type_test.dart new file mode 100644 index 0000000..cbb9e4e --- /dev/null +++ b/test/src/models/mfa_type_test.dart @@ -0,0 +1,20 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('MfaType', () { + + test('model', () { + final model = MfaType( + secret: '1', + uri: '1', + ); + + final map = model.toMap(); + final result = MfaType.fromMap(map); + + expect(result.secret, '1'); + expect(result.uri, '1'); + }); + }); +} diff --git a/test/src/models/provider_list_test.dart b/test/src/models/provider_list_test.dart new file mode 100644 index 0000000..954c442 --- /dev/null +++ b/test/src/models/provider_list_test.dart @@ -0,0 +1,20 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('ProviderList', () { + + test('model', () { + final model = ProviderList( + total: 5, + providers: [], + ); + + final map = model.toMap(); + final result = ProviderList.fromMap(map); + + expect(result.total, 5); + expect(result.providers, []); + }); + }); +} diff --git a/test/src/models/provider_test.dart b/test/src/models/provider_test.dart new file mode 100644 index 0000000..a1ecd41 --- /dev/null +++ b/test/src/models/provider_test.dart @@ -0,0 +1,32 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('Provider', () { + + test('model', () { + final model = Provider( + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Mailgun', + provider: 'mailgun', + enabled: true, + type: 'sms', + credentials: {}, + ); + + final map = model.toMap(); + final result = Provider.fromMap(map); + + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.name, 'Mailgun'); + expect(result.provider, 'mailgun'); + expect(result.enabled, true); + expect(result.type, 'sms'); + expect(result.credentials, {}); + }); + }); +} diff --git a/test/src/models/session_test.dart b/test/src/models/session_test.dart index 991fa90..8f4df83 100644 --- a/test/src/models/session_test.dart +++ b/test/src/models/session_test.dart @@ -31,6 +31,9 @@ void main() { countryCode: 'US', countryName: 'United States', current: true, + factors: [], + secret: '5e5bb8c16897e', + mfaUpdatedAt: '2020-10-15T06:38:00.000+00:00', ); final map = model.toMap(); @@ -61,6 +64,9 @@ void main() { expect(result.countryCode, 'US'); expect(result.countryName, 'United States'); expect(result.current, true); + expect(result.factors, []); + expect(result.secret, '5e5bb8c16897e'); + expect(result.mfaUpdatedAt, '2020-10-15T06:38:00.000+00:00'); }); }); } diff --git a/test/src/models/subscriber_list_test.dart b/test/src/models/subscriber_list_test.dart new file mode 100644 index 0000000..d46f055 --- /dev/null +++ b/test/src/models/subscriber_list_test.dart @@ -0,0 +1,20 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('SubscriberList', () { + + test('model', () { + final model = SubscriberList( + total: 5, + subscribers: [], + ); + + final map = model.toMap(); + final result = SubscriberList.fromMap(map); + + expect(result.total, 5); + expect(result.subscribers, []); + }); + }); +} diff --git a/test/src/models/subscriber_test.dart b/test/src/models/subscriber_test.dart new file mode 100644 index 0000000..ed90651 --- /dev/null +++ b/test/src/models/subscriber_test.dart @@ -0,0 +1,34 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('Subscriber', () { + + test('model', () { + final model = Subscriber( + $id: '259125845563242502', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + targetId: '259125845563242502', + target: {}, + userId: '5e5ea5c16897e', + userName: 'Aegon Targaryen', + topicId: '259125845563242502', + providerType: 'email', + ); + + final map = model.toMap(); + final result = Subscriber.fromMap(map); + + expect(result.$id, '259125845563242502'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.targetId, '259125845563242502'); + expect(result.target, {}); + expect(result.userId, '5e5ea5c16897e'); + expect(result.userName, 'Aegon Targaryen'); + expect(result.topicId, '259125845563242502'); + expect(result.providerType, 'email'); + }); + }); +} diff --git a/test/src/models/target_list_test.dart b/test/src/models/target_list_test.dart new file mode 100644 index 0000000..5f96366 --- /dev/null +++ b/test/src/models/target_list_test.dart @@ -0,0 +1,20 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('TargetList', () { + + test('model', () { + final model = TargetList( + total: 5, + targets: [], + ); + + final map = model.toMap(); + final result = TargetList.fromMap(map); + + expect(result.total, 5); + expect(result.targets, []); + }); + }); +} diff --git a/test/src/models/target_test.dart b/test/src/models/target_test.dart new file mode 100644 index 0000000..2d66469 --- /dev/null +++ b/test/src/models/target_test.dart @@ -0,0 +1,30 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('Target', () { + + test('model', () { + final model = Target( + $id: '259125845563242502', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'Aegon apple token', + userId: '259125845563242502', + providerType: 'email', + identifier: 'token', + ); + + final map = model.toMap(); + final result = Target.fromMap(map); + + expect(result.$id, '259125845563242502'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.name, 'Aegon apple token'); + expect(result.userId, '259125845563242502'); + expect(result.providerType, 'email'); + expect(result.identifier, 'token'); + }); + }); +} diff --git a/test/src/models/token_test.dart b/test/src/models/token_test.dart index 1668da7..9e6cdb5 100644 --- a/test/src/models/token_test.dart +++ b/test/src/models/token_test.dart @@ -11,6 +11,7 @@ void main() { userId: '5e5ea5c168bb8', secret: '', expire: '2020-10-15T06:38:00.000+00:00', + phrase: 'Golden Fox', ); final map = model.toMap(); @@ -21,6 +22,7 @@ void main() { expect(result.userId, '5e5ea5c168bb8'); expect(result.secret, ''); expect(result.expire, '2020-10-15T06:38:00.000+00:00'); + expect(result.phrase, 'Golden Fox'); }); }); } diff --git a/test/src/models/topic_list_test.dart b/test/src/models/topic_list_test.dart new file mode 100644 index 0000000..4d4fc12 --- /dev/null +++ b/test/src/models/topic_list_test.dart @@ -0,0 +1,20 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('TopicList', () { + + test('model', () { + final model = TopicList( + total: 5, + topics: [], + ); + + final map = model.toMap(); + final result = TopicList.fromMap(map); + + expect(result.total, 5); + expect(result.topics, []); + }); + }); +} diff --git a/test/src/models/topic_test.dart b/test/src/models/topic_test.dart new file mode 100644 index 0000000..666097f --- /dev/null +++ b/test/src/models/topic_test.dart @@ -0,0 +1,32 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('Topic', () { + + test('model', () { + final model = Topic( + $id: '259125845563242502', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'events', + emailTotal: 100, + smsTotal: 100, + pushTotal: 100, + subscribe: [], + ); + + final map = model.toMap(); + final result = Topic.fromMap(map); + + expect(result.$id, '259125845563242502'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.name, 'events'); + expect(result.emailTotal, 100); + expect(result.smsTotal, 100); + expect(result.pushTotal, 100); + expect(result.subscribe, []); + }); + }); +} diff --git a/test/src/models/user_test.dart b/test/src/models/user_test.dart index 9cd8adf..1f411e3 100644 --- a/test/src/models/user_test.dart +++ b/test/src/models/user_test.dart @@ -18,7 +18,9 @@ void main() { phone: '+4930901820', emailVerification: true, phoneVerification: true, + mfa: true, prefs: Preferences(data: {}), + targets: [], accessedAt: '2020-10-15T06:38:00.000+00:00', ); @@ -37,7 +39,9 @@ void main() { expect(result.phone, '+4930901820'); expect(result.emailVerification, true); expect(result.phoneVerification, true); + expect(result.mfa, true); expect(result.prefs.data, {"data": {}}); + expect(result.targets, []); expect(result.accessedAt, '2020-10-15T06:38:00.000+00:00'); }); });