diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c4660fa..be5f3b4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 8.0.1 + +* Added documentation comments +* Added unit tests +* Upgraded dependencies + ## 8.0.0 * Added relationships support diff --git a/README.md b/README.md index 54203a93..09065833 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![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.3.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.3.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) @@ -23,7 +23,7 @@ Add this to your package's `pubspec.yaml` file: ```yml dependencies: - dart_appwrite: ^8.0.0 + dart_appwrite: ^8.0.1 ``` You can install packages from the command line: diff --git a/docs/examples/account/create-phone-verification.md b/docs/examples/account/create-phone-verification.md index de0389f7..912f8c3b 100644 --- a/docs/examples/account/create-phone-verification.md +++ b/docs/examples/account/create-phone-verification.md @@ -5,7 +5,7 @@ void main() { // Init SDK Account account = Account(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token ; diff --git a/docs/examples/account/create-recovery.md b/docs/examples/account/create-recovery.md index 1d6c7fca..d9f13957 100644 --- a/docs/examples/account/create-recovery.md +++ b/docs/examples/account/create-recovery.md @@ -5,7 +5,7 @@ void main() { // Init SDK Account account = Account(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token ; diff --git a/docs/examples/account/create-verification.md b/docs/examples/account/create-verification.md index a46c1cf5..cca3c7b7 100644 --- a/docs/examples/account/create-verification.md +++ b/docs/examples/account/create-verification.md @@ -5,7 +5,7 @@ void main() { // Init SDK Account account = Account(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token ; diff --git a/docs/examples/account/delete-session.md b/docs/examples/account/delete-session.md index 7e2c59b6..9486ec9b 100644 --- a/docs/examples/account/delete-session.md +++ b/docs/examples/account/delete-session.md @@ -5,7 +5,7 @@ void main() { // Init SDK Account account = Account(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token ; diff --git a/docs/examples/account/delete-sessions.md b/docs/examples/account/delete-sessions.md index 8647d09f..a5732cb6 100644 --- a/docs/examples/account/delete-sessions.md +++ b/docs/examples/account/delete-sessions.md @@ -5,7 +5,7 @@ void main() { // Init SDK Account account = Account(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token ; diff --git a/docs/examples/account/get-prefs.md b/docs/examples/account/get-prefs.md index 911e8681..527a71f3 100644 --- a/docs/examples/account/get-prefs.md +++ b/docs/examples/account/get-prefs.md @@ -5,7 +5,7 @@ void main() { // Init SDK Account account = Account(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token ; diff --git a/docs/examples/account/get-session.md b/docs/examples/account/get-session.md index ef78a529..6eb711ab 100644 --- a/docs/examples/account/get-session.md +++ b/docs/examples/account/get-session.md @@ -5,7 +5,7 @@ void main() { // Init SDK Account account = Account(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token ; diff --git a/docs/examples/account/get.md b/docs/examples/account/get.md index 040dad64..c72fdddb 100644 --- a/docs/examples/account/get.md +++ b/docs/examples/account/get.md @@ -5,7 +5,7 @@ void main() { // Init SDK Account account = Account(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token ; diff --git a/docs/examples/account/list-logs.md b/docs/examples/account/list-logs.md index 83735ecc..68d2c49f 100644 --- a/docs/examples/account/list-logs.md +++ b/docs/examples/account/list-logs.md @@ -5,7 +5,7 @@ void main() { // Init SDK Account account = Account(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token ; diff --git a/docs/examples/account/list-sessions.md b/docs/examples/account/list-sessions.md index 914c3dd7..0d6567b5 100644 --- a/docs/examples/account/list-sessions.md +++ b/docs/examples/account/list-sessions.md @@ -5,7 +5,7 @@ void main() { // Init SDK Account account = Account(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token ; diff --git a/docs/examples/account/update-email.md b/docs/examples/account/update-email.md index 85b5950b..b83f7d86 100644 --- a/docs/examples/account/update-email.md +++ b/docs/examples/account/update-email.md @@ -5,7 +5,7 @@ void main() { // Init SDK Account account = Account(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token ; diff --git a/docs/examples/account/update-name.md b/docs/examples/account/update-name.md index 026206d1..0bd27cf2 100644 --- a/docs/examples/account/update-name.md +++ b/docs/examples/account/update-name.md @@ -5,7 +5,7 @@ void main() { // Init SDK Account account = Account(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token ; diff --git a/docs/examples/account/update-password.md b/docs/examples/account/update-password.md index 4e6994c9..d5e27a75 100644 --- a/docs/examples/account/update-password.md +++ b/docs/examples/account/update-password.md @@ -5,7 +5,7 @@ void main() { // Init SDK Account account = Account(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token ; diff --git a/docs/examples/account/update-phone-verification.md b/docs/examples/account/update-phone-verification.md index 257cc9b4..f2995b9b 100644 --- a/docs/examples/account/update-phone-verification.md +++ b/docs/examples/account/update-phone-verification.md @@ -5,7 +5,7 @@ void main() { // Init SDK Account account = Account(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token ; diff --git a/docs/examples/account/update-phone.md b/docs/examples/account/update-phone.md index 04380338..5848da5d 100644 --- a/docs/examples/account/update-phone.md +++ b/docs/examples/account/update-phone.md @@ -5,7 +5,7 @@ void main() { // Init SDK Account account = Account(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token ; diff --git a/docs/examples/account/update-prefs.md b/docs/examples/account/update-prefs.md index 8bcb83e7..ffbe7002 100644 --- a/docs/examples/account/update-prefs.md +++ b/docs/examples/account/update-prefs.md @@ -5,7 +5,7 @@ void main() { // Init SDK Account account = Account(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token ; diff --git a/docs/examples/account/update-recovery.md b/docs/examples/account/update-recovery.md index 5840fbec..c2cf9d23 100644 --- a/docs/examples/account/update-recovery.md +++ b/docs/examples/account/update-recovery.md @@ -5,7 +5,7 @@ void main() { // Init SDK Account account = Account(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token ; diff --git a/docs/examples/account/update-session.md b/docs/examples/account/update-session.md index c689dda9..61e11e27 100644 --- a/docs/examples/account/update-session.md +++ b/docs/examples/account/update-session.md @@ -5,7 +5,7 @@ void main() { // Init SDK Account account = Account(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token ; diff --git a/docs/examples/account/update-status.md b/docs/examples/account/update-status.md index 025ef777..12f73333 100644 --- a/docs/examples/account/update-status.md +++ b/docs/examples/account/update-status.md @@ -5,7 +5,7 @@ void main() { // Init SDK Account account = Account(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token ; diff --git a/docs/examples/account/update-verification.md b/docs/examples/account/update-verification.md index c9707936..40e36426 100644 --- a/docs/examples/account/update-verification.md +++ b/docs/examples/account/update-verification.md @@ -5,7 +5,7 @@ void main() { // Init SDK Account account = Account(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token ; diff --git a/docs/examples/avatars/get-browser.md b/docs/examples/avatars/get-browser.md index c924ae43..0bac9df4 100644 --- a/docs/examples/avatars/get-browser.md +++ b/docs/examples/avatars/get-browser.md @@ -5,7 +5,7 @@ void main() { // Init SDK Avatars avatars = Avatars(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/avatars/get-credit-card.md b/docs/examples/avatars/get-credit-card.md index 5d01d690..b9a8166e 100644 --- a/docs/examples/avatars/get-credit-card.md +++ b/docs/examples/avatars/get-credit-card.md @@ -5,7 +5,7 @@ void main() { // Init SDK Avatars avatars = Avatars(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/avatars/get-favicon.md b/docs/examples/avatars/get-favicon.md index 3308f5c5..6a728e77 100644 --- a/docs/examples/avatars/get-favicon.md +++ b/docs/examples/avatars/get-favicon.md @@ -5,7 +5,7 @@ void main() { // Init SDK Avatars avatars = Avatars(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/avatars/get-flag.md b/docs/examples/avatars/get-flag.md index 5da4aaf2..02e48809 100644 --- a/docs/examples/avatars/get-flag.md +++ b/docs/examples/avatars/get-flag.md @@ -5,7 +5,7 @@ void main() { // Init SDK Avatars avatars = Avatars(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/avatars/get-image.md b/docs/examples/avatars/get-image.md index 196c6ded..b1d5e338 100644 --- a/docs/examples/avatars/get-image.md +++ b/docs/examples/avatars/get-image.md @@ -5,7 +5,7 @@ void main() { // Init SDK Avatars avatars = Avatars(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/avatars/get-initials.md b/docs/examples/avatars/get-initials.md index c40a54b7..5a68caf1 100644 --- a/docs/examples/avatars/get-initials.md +++ b/docs/examples/avatars/get-initials.md @@ -5,7 +5,7 @@ void main() { // Init SDK Avatars avatars = Avatars(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/avatars/get-q-r.md b/docs/examples/avatars/get-q-r.md index bef31b34..8283b9bd 100644 --- a/docs/examples/avatars/get-q-r.md +++ b/docs/examples/avatars/get-q-r.md @@ -5,7 +5,7 @@ void main() { // Init SDK Avatars avatars = Avatars(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/create-boolean-attribute.md b/docs/examples/databases/create-boolean-attribute.md index fd1223d3..22471968 100644 --- a/docs/examples/databases/create-boolean-attribute.md +++ b/docs/examples/databases/create-boolean-attribute.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/create-collection.md b/docs/examples/databases/create-collection.md index 5783e595..c90183de 100644 --- a/docs/examples/databases/create-collection.md +++ b/docs/examples/databases/create-collection.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/create-datetime-attribute.md b/docs/examples/databases/create-datetime-attribute.md index da3cf104..24c44088 100644 --- a/docs/examples/databases/create-datetime-attribute.md +++ b/docs/examples/databases/create-datetime-attribute.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index 6d88d9c7..00d844da 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/create-email-attribute.md b/docs/examples/databases/create-email-attribute.md index d3443b57..92fd3203 100644 --- a/docs/examples/databases/create-email-attribute.md +++ b/docs/examples/databases/create-email-attribute.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/create-enum-attribute.md b/docs/examples/databases/create-enum-attribute.md index da413a1d..fa8ad920 100644 --- a/docs/examples/databases/create-enum-attribute.md +++ b/docs/examples/databases/create-enum-attribute.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/create-float-attribute.md b/docs/examples/databases/create-float-attribute.md index c2d6ad4a..96047bf2 100644 --- a/docs/examples/databases/create-float-attribute.md +++ b/docs/examples/databases/create-float-attribute.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/create-index.md b/docs/examples/databases/create-index.md index e0d04e77..c16a0271 100644 --- a/docs/examples/databases/create-index.md +++ b/docs/examples/databases/create-index.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/create-integer-attribute.md b/docs/examples/databases/create-integer-attribute.md index 701ed4ee..bc4f12f0 100644 --- a/docs/examples/databases/create-integer-attribute.md +++ b/docs/examples/databases/create-integer-attribute.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/create-ip-attribute.md b/docs/examples/databases/create-ip-attribute.md index 925a5d5d..ef3e985a 100644 --- a/docs/examples/databases/create-ip-attribute.md +++ b/docs/examples/databases/create-ip-attribute.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/create-relationship-attribute.md b/docs/examples/databases/create-relationship-attribute.md index 674a0005..01f2b42f 100644 --- a/docs/examples/databases/create-relationship-attribute.md +++ b/docs/examples/databases/create-relationship-attribute.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/create-string-attribute.md b/docs/examples/databases/create-string-attribute.md index 8178ece3..14f2769d 100644 --- a/docs/examples/databases/create-string-attribute.md +++ b/docs/examples/databases/create-string-attribute.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/create-url-attribute.md b/docs/examples/databases/create-url-attribute.md index 8c117cbf..4cf3e99a 100644 --- a/docs/examples/databases/create-url-attribute.md +++ b/docs/examples/databases/create-url-attribute.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/create.md b/docs/examples/databases/create.md index 7c9cc537..cbaf3b74 100644 --- a/docs/examples/databases/create.md +++ b/docs/examples/databases/create.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/delete-attribute.md b/docs/examples/databases/delete-attribute.md index 113f80da..e9865bfe 100644 --- a/docs/examples/databases/delete-attribute.md +++ b/docs/examples/databases/delete-attribute.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/delete-collection.md b/docs/examples/databases/delete-collection.md index 05425529..58869201 100644 --- a/docs/examples/databases/delete-collection.md +++ b/docs/examples/databases/delete-collection.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/delete-document.md b/docs/examples/databases/delete-document.md index 5985c933..0d298f3b 100644 --- a/docs/examples/databases/delete-document.md +++ b/docs/examples/databases/delete-document.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/delete-index.md b/docs/examples/databases/delete-index.md index 8efc981d..be5b2a5c 100644 --- a/docs/examples/databases/delete-index.md +++ b/docs/examples/databases/delete-index.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/delete.md b/docs/examples/databases/delete.md index 78f70bbc..ff19beea 100644 --- a/docs/examples/databases/delete.md +++ b/docs/examples/databases/delete.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/get-attribute.md b/docs/examples/databases/get-attribute.md index 32bb0955..c27ddb64 100644 --- a/docs/examples/databases/get-attribute.md +++ b/docs/examples/databases/get-attribute.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/get-collection.md b/docs/examples/databases/get-collection.md index 33b7913e..359f0df8 100644 --- a/docs/examples/databases/get-collection.md +++ b/docs/examples/databases/get-collection.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/get-document.md b/docs/examples/databases/get-document.md index 58fde417..2141abf4 100644 --- a/docs/examples/databases/get-document.md +++ b/docs/examples/databases/get-document.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/get-index.md b/docs/examples/databases/get-index.md index 64b03c48..2b8a9031 100644 --- a/docs/examples/databases/get-index.md +++ b/docs/examples/databases/get-index.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/get.md b/docs/examples/databases/get.md index c85a5c70..f0cc118b 100644 --- a/docs/examples/databases/get.md +++ b/docs/examples/databases/get.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/list-attributes.md b/docs/examples/databases/list-attributes.md index c13a9d70..60ca58f3 100644 --- a/docs/examples/databases/list-attributes.md +++ b/docs/examples/databases/list-attributes.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/list-collections.md b/docs/examples/databases/list-collections.md index 098a3272..a10038db 100644 --- a/docs/examples/databases/list-collections.md +++ b/docs/examples/databases/list-collections.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/list-documents.md b/docs/examples/databases/list-documents.md index ba10a984..70299774 100644 --- a/docs/examples/databases/list-documents.md +++ b/docs/examples/databases/list-documents.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/list-indexes.md b/docs/examples/databases/list-indexes.md index bc957cad..6703ebf3 100644 --- a/docs/examples/databases/list-indexes.md +++ b/docs/examples/databases/list-indexes.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/list.md b/docs/examples/databases/list.md index 6b103349..d9bd06ad 100644 --- a/docs/examples/databases/list.md +++ b/docs/examples/databases/list.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/update-boolean-attribute.md b/docs/examples/databases/update-boolean-attribute.md index 1a296aaf..94853d28 100644 --- a/docs/examples/databases/update-boolean-attribute.md +++ b/docs/examples/databases/update-boolean-attribute.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/update-collection.md b/docs/examples/databases/update-collection.md index 515c4fe7..a5f32dea 100644 --- a/docs/examples/databases/update-collection.md +++ b/docs/examples/databases/update-collection.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/update-datetime-attribute.md b/docs/examples/databases/update-datetime-attribute.md index 1c33ae7d..f93aa815 100644 --- a/docs/examples/databases/update-datetime-attribute.md +++ b/docs/examples/databases/update-datetime-attribute.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/update-document.md b/docs/examples/databases/update-document.md index 41e1bff1..fb08413f 100644 --- a/docs/examples/databases/update-document.md +++ b/docs/examples/databases/update-document.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/update-email-attribute.md b/docs/examples/databases/update-email-attribute.md index ff255508..8fd104db 100644 --- a/docs/examples/databases/update-email-attribute.md +++ b/docs/examples/databases/update-email-attribute.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/update-enum-attribute.md b/docs/examples/databases/update-enum-attribute.md index fc6e9dc8..20c44817 100644 --- a/docs/examples/databases/update-enum-attribute.md +++ b/docs/examples/databases/update-enum-attribute.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/update-float-attribute.md b/docs/examples/databases/update-float-attribute.md index 8822f2bb..50432542 100644 --- a/docs/examples/databases/update-float-attribute.md +++ b/docs/examples/databases/update-float-attribute.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/update-integer-attribute.md b/docs/examples/databases/update-integer-attribute.md index c1125a7b..2d3da6ce 100644 --- a/docs/examples/databases/update-integer-attribute.md +++ b/docs/examples/databases/update-integer-attribute.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/update-ip-attribute.md b/docs/examples/databases/update-ip-attribute.md index ec0cc2bd..8c4cf4f3 100644 --- a/docs/examples/databases/update-ip-attribute.md +++ b/docs/examples/databases/update-ip-attribute.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/update-relationship-attribute.md b/docs/examples/databases/update-relationship-attribute.md index 7da90061..239e23da 100644 --- a/docs/examples/databases/update-relationship-attribute.md +++ b/docs/examples/databases/update-relationship-attribute.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/update-string-attribute.md b/docs/examples/databases/update-string-attribute.md index 96e68836..7f24507a 100644 --- a/docs/examples/databases/update-string-attribute.md +++ b/docs/examples/databases/update-string-attribute.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/update-url-attribute.md b/docs/examples/databases/update-url-attribute.md index a9635595..d7dd6758 100644 --- a/docs/examples/databases/update-url-attribute.md +++ b/docs/examples/databases/update-url-attribute.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/databases/update.md b/docs/examples/databases/update.md index 080d88a1..59070cef 100644 --- a/docs/examples/databases/update.md +++ b/docs/examples/databases/update.md @@ -5,7 +5,7 @@ void main() { // Init SDK Databases databases = Databases(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/functions/create-build.md b/docs/examples/functions/create-build.md index 82f71e2d..530ba6de 100644 --- a/docs/examples/functions/create-build.md +++ b/docs/examples/functions/create-build.md @@ -5,7 +5,7 @@ void main() { // Init SDK Functions functions = Functions(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/functions/create-deployment.md b/docs/examples/functions/create-deployment.md index a407622f..d646680d 100644 --- a/docs/examples/functions/create-deployment.md +++ b/docs/examples/functions/create-deployment.md @@ -5,7 +5,7 @@ void main() { // Init SDK Functions functions = Functions(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/functions/create-execution.md b/docs/examples/functions/create-execution.md index 572b54ff..f5de49f7 100644 --- a/docs/examples/functions/create-execution.md +++ b/docs/examples/functions/create-execution.md @@ -5,7 +5,7 @@ void main() { // Init SDK Functions functions = Functions(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/functions/create-variable.md b/docs/examples/functions/create-variable.md index c4d300f4..50cd063c 100644 --- a/docs/examples/functions/create-variable.md +++ b/docs/examples/functions/create-variable.md @@ -5,7 +5,7 @@ void main() { // Init SDK Functions functions = Functions(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index 2e8e8faf..839c6f6e 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -5,7 +5,7 @@ void main() { // Init SDK Functions functions = Functions(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/functions/delete-deployment.md b/docs/examples/functions/delete-deployment.md index 495b5b6c..e65380c5 100644 --- a/docs/examples/functions/delete-deployment.md +++ b/docs/examples/functions/delete-deployment.md @@ -5,7 +5,7 @@ void main() { // Init SDK Functions functions = Functions(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/functions/delete-variable.md b/docs/examples/functions/delete-variable.md index 23546874..87c7f407 100644 --- a/docs/examples/functions/delete-variable.md +++ b/docs/examples/functions/delete-variable.md @@ -5,7 +5,7 @@ void main() { // Init SDK Functions functions = Functions(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/functions/delete.md b/docs/examples/functions/delete.md index 36694658..51633669 100644 --- a/docs/examples/functions/delete.md +++ b/docs/examples/functions/delete.md @@ -5,7 +5,7 @@ void main() { // Init SDK Functions functions = Functions(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/functions/get-deployment.md b/docs/examples/functions/get-deployment.md index 7e529df7..9cab571e 100644 --- a/docs/examples/functions/get-deployment.md +++ b/docs/examples/functions/get-deployment.md @@ -5,7 +5,7 @@ void main() { // Init SDK Functions functions = Functions(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/functions/get-execution.md b/docs/examples/functions/get-execution.md index 7854e7f7..6cadde64 100644 --- a/docs/examples/functions/get-execution.md +++ b/docs/examples/functions/get-execution.md @@ -5,7 +5,7 @@ void main() { // Init SDK Functions functions = Functions(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/functions/get-variable.md b/docs/examples/functions/get-variable.md index 29c90745..924bee2b 100644 --- a/docs/examples/functions/get-variable.md +++ b/docs/examples/functions/get-variable.md @@ -5,7 +5,7 @@ void main() { // Init SDK Functions functions = Functions(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/functions/get.md b/docs/examples/functions/get.md index 261ffef3..503ab207 100644 --- a/docs/examples/functions/get.md +++ b/docs/examples/functions/get.md @@ -5,7 +5,7 @@ void main() { // Init SDK Functions functions = Functions(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/functions/list-deployments.md b/docs/examples/functions/list-deployments.md index 071c1a7f..b12f9eba 100644 --- a/docs/examples/functions/list-deployments.md +++ b/docs/examples/functions/list-deployments.md @@ -5,7 +5,7 @@ void main() { // Init SDK Functions functions = Functions(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/functions/list-executions.md b/docs/examples/functions/list-executions.md index a0af0d16..3d66a449 100644 --- a/docs/examples/functions/list-executions.md +++ b/docs/examples/functions/list-executions.md @@ -5,7 +5,7 @@ void main() { // Init SDK Functions functions = Functions(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/functions/list-runtimes.md b/docs/examples/functions/list-runtimes.md index da474ff7..091a1116 100644 --- a/docs/examples/functions/list-runtimes.md +++ b/docs/examples/functions/list-runtimes.md @@ -5,7 +5,7 @@ void main() { // Init SDK Functions functions = Functions(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/functions/list-variables.md b/docs/examples/functions/list-variables.md index dc14c932..f3c6655b 100644 --- a/docs/examples/functions/list-variables.md +++ b/docs/examples/functions/list-variables.md @@ -5,7 +5,7 @@ void main() { // Init SDK Functions functions = Functions(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/functions/list.md b/docs/examples/functions/list.md index a530d00f..4f2b1140 100644 --- a/docs/examples/functions/list.md +++ b/docs/examples/functions/list.md @@ -5,7 +5,7 @@ void main() { // Init SDK Functions functions = Functions(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/functions/update-deployment.md b/docs/examples/functions/update-deployment.md index 633b6265..d503aecb 100644 --- a/docs/examples/functions/update-deployment.md +++ b/docs/examples/functions/update-deployment.md @@ -5,7 +5,7 @@ void main() { // Init SDK Functions functions = Functions(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/functions/update-variable.md b/docs/examples/functions/update-variable.md index eeeeaf12..126d2644 100644 --- a/docs/examples/functions/update-variable.md +++ b/docs/examples/functions/update-variable.md @@ -5,7 +5,7 @@ void main() { // Init SDK Functions functions = Functions(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index f91ad606..2b92f553 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -5,7 +5,7 @@ void main() { // Init SDK Functions functions = Functions(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/graphql/mutation.md b/docs/examples/graphql/mutation.md index 0c14c9ca..780ee09f 100644 --- a/docs/examples/graphql/mutation.md +++ b/docs/examples/graphql/mutation.md @@ -5,7 +5,7 @@ void main() { // Init SDK Graphql graphql = Graphql(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/graphql/query.md b/docs/examples/graphql/query.md index 8b093367..7f22f536 100644 --- a/docs/examples/graphql/query.md +++ b/docs/examples/graphql/query.md @@ -5,7 +5,7 @@ void main() { // Init SDK Graphql graphql = Graphql(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/health/get-antivirus.md b/docs/examples/health/get-antivirus.md index 974a29bd..922dcfa1 100644 --- a/docs/examples/health/get-antivirus.md +++ b/docs/examples/health/get-antivirus.md @@ -5,7 +5,7 @@ void main() { // Init SDK Health health = Health(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/health/get-cache.md b/docs/examples/health/get-cache.md index 322939d7..4b63edee 100644 --- a/docs/examples/health/get-cache.md +++ b/docs/examples/health/get-cache.md @@ -5,7 +5,7 @@ void main() { // Init SDK Health health = Health(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/health/get-d-b.md b/docs/examples/health/get-d-b.md index e3447550..65188c09 100644 --- a/docs/examples/health/get-d-b.md +++ b/docs/examples/health/get-d-b.md @@ -5,7 +5,7 @@ void main() { // Init SDK Health health = Health(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/health/get-queue-certificates.md b/docs/examples/health/get-queue-certificates.md index 7c605154..4063ab35 100644 --- a/docs/examples/health/get-queue-certificates.md +++ b/docs/examples/health/get-queue-certificates.md @@ -5,7 +5,7 @@ void main() { // Init SDK Health health = Health(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/health/get-queue-functions.md b/docs/examples/health/get-queue-functions.md index c06cda91..5ebaad64 100644 --- a/docs/examples/health/get-queue-functions.md +++ b/docs/examples/health/get-queue-functions.md @@ -5,7 +5,7 @@ void main() { // Init SDK Health health = Health(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/health/get-queue-logs.md b/docs/examples/health/get-queue-logs.md index 807a04fb..11a52854 100644 --- a/docs/examples/health/get-queue-logs.md +++ b/docs/examples/health/get-queue-logs.md @@ -5,7 +5,7 @@ void main() { // Init SDK Health health = Health(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/health/get-queue-webhooks.md b/docs/examples/health/get-queue-webhooks.md index 7c159ac8..a43f5f84 100644 --- a/docs/examples/health/get-queue-webhooks.md +++ b/docs/examples/health/get-queue-webhooks.md @@ -5,7 +5,7 @@ void main() { // Init SDK Health health = Health(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/health/get-storage-local.md b/docs/examples/health/get-storage-local.md index 7f172bf8..4a586690 100644 --- a/docs/examples/health/get-storage-local.md +++ b/docs/examples/health/get-storage-local.md @@ -5,7 +5,7 @@ void main() { // Init SDK Health health = Health(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/health/get-time.md b/docs/examples/health/get-time.md index 65861d3c..d8166dd3 100644 --- a/docs/examples/health/get-time.md +++ b/docs/examples/health/get-time.md @@ -5,7 +5,7 @@ void main() { // Init SDK Health health = Health(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/health/get.md b/docs/examples/health/get.md index 0c9d3921..1be37e5a 100644 --- a/docs/examples/health/get.md +++ b/docs/examples/health/get.md @@ -5,7 +5,7 @@ void main() { // Init SDK Health health = Health(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/locale/get.md b/docs/examples/locale/get.md index d2900630..9ecb18c5 100644 --- a/docs/examples/locale/get.md +++ b/docs/examples/locale/get.md @@ -5,7 +5,7 @@ void main() { // Init SDK Locale locale = Locale(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/locale/list-continents.md b/docs/examples/locale/list-continents.md index 4b17da4c..e6849303 100644 --- a/docs/examples/locale/list-continents.md +++ b/docs/examples/locale/list-continents.md @@ -5,7 +5,7 @@ void main() { // Init SDK Locale locale = Locale(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/locale/list-countries-e-u.md b/docs/examples/locale/list-countries-e-u.md index 41f8e83e..2d1ddcf8 100644 --- a/docs/examples/locale/list-countries-e-u.md +++ b/docs/examples/locale/list-countries-e-u.md @@ -5,7 +5,7 @@ void main() { // Init SDK Locale locale = Locale(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/locale/list-countries-phones.md b/docs/examples/locale/list-countries-phones.md index 5cf2db93..23057013 100644 --- a/docs/examples/locale/list-countries-phones.md +++ b/docs/examples/locale/list-countries-phones.md @@ -5,7 +5,7 @@ void main() { // Init SDK Locale locale = Locale(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/locale/list-countries.md b/docs/examples/locale/list-countries.md index d55d0fe1..ef115833 100644 --- a/docs/examples/locale/list-countries.md +++ b/docs/examples/locale/list-countries.md @@ -5,7 +5,7 @@ void main() { // Init SDK Locale locale = Locale(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/locale/list-currencies.md b/docs/examples/locale/list-currencies.md index e36775de..0810f3da 100644 --- a/docs/examples/locale/list-currencies.md +++ b/docs/examples/locale/list-currencies.md @@ -5,7 +5,7 @@ void main() { // Init SDK Locale locale = Locale(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/locale/list-languages.md b/docs/examples/locale/list-languages.md index b019ae4a..f3d642cc 100644 --- a/docs/examples/locale/list-languages.md +++ b/docs/examples/locale/list-languages.md @@ -5,7 +5,7 @@ void main() { // Init SDK Locale locale = Locale(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/storage/create-bucket.md b/docs/examples/storage/create-bucket.md index 90882fe4..745a6b50 100644 --- a/docs/examples/storage/create-bucket.md +++ b/docs/examples/storage/create-bucket.md @@ -5,7 +5,7 @@ void main() { // Init SDK Storage storage = Storage(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/storage/create-file.md b/docs/examples/storage/create-file.md index ef596fcc..ab4c661a 100644 --- a/docs/examples/storage/create-file.md +++ b/docs/examples/storage/create-file.md @@ -6,7 +6,7 @@ void main() { // Init SDK Storage storage = Storage(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/storage/delete-bucket.md b/docs/examples/storage/delete-bucket.md index 786084a1..de516561 100644 --- a/docs/examples/storage/delete-bucket.md +++ b/docs/examples/storage/delete-bucket.md @@ -5,7 +5,7 @@ void main() { // Init SDK Storage storage = Storage(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/storage/delete-file.md b/docs/examples/storage/delete-file.md index 574532c1..8e4460bb 100644 --- a/docs/examples/storage/delete-file.md +++ b/docs/examples/storage/delete-file.md @@ -5,7 +5,7 @@ void main() { // Init SDK Storage storage = Storage(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/storage/get-bucket.md b/docs/examples/storage/get-bucket.md index 22360826..9e39076e 100644 --- a/docs/examples/storage/get-bucket.md +++ b/docs/examples/storage/get-bucket.md @@ -5,7 +5,7 @@ void main() { // Init SDK Storage storage = Storage(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/storage/get-file-download.md b/docs/examples/storage/get-file-download.md index 6a87cafe..6534fe33 100644 --- a/docs/examples/storage/get-file-download.md +++ b/docs/examples/storage/get-file-download.md @@ -5,7 +5,7 @@ void main() { // Init SDK Storage storage = Storage(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/storage/get-file-preview.md b/docs/examples/storage/get-file-preview.md index f678eacb..ca16d635 100644 --- a/docs/examples/storage/get-file-preview.md +++ b/docs/examples/storage/get-file-preview.md @@ -5,7 +5,7 @@ void main() { // Init SDK Storage storage = Storage(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/storage/get-file-view.md b/docs/examples/storage/get-file-view.md index 2be352fe..5c3d69dc 100644 --- a/docs/examples/storage/get-file-view.md +++ b/docs/examples/storage/get-file-view.md @@ -5,7 +5,7 @@ void main() { // Init SDK Storage storage = Storage(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/storage/get-file.md b/docs/examples/storage/get-file.md index 7ecdcf9e..bc45c3f1 100644 --- a/docs/examples/storage/get-file.md +++ b/docs/examples/storage/get-file.md @@ -5,7 +5,7 @@ void main() { // Init SDK Storage storage = Storage(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/storage/list-buckets.md b/docs/examples/storage/list-buckets.md index fa5607a8..6a35febb 100644 --- a/docs/examples/storage/list-buckets.md +++ b/docs/examples/storage/list-buckets.md @@ -5,7 +5,7 @@ void main() { // Init SDK Storage storage = Storage(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/storage/list-files.md b/docs/examples/storage/list-files.md index 519a002c..40b8d3bc 100644 --- a/docs/examples/storage/list-files.md +++ b/docs/examples/storage/list-files.md @@ -5,7 +5,7 @@ void main() { // Init SDK Storage storage = Storage(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/storage/update-bucket.md b/docs/examples/storage/update-bucket.md index 6352ff7c..064d2f2e 100644 --- a/docs/examples/storage/update-bucket.md +++ b/docs/examples/storage/update-bucket.md @@ -5,7 +5,7 @@ void main() { // Init SDK Storage storage = Storage(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/storage/update-file.md b/docs/examples/storage/update-file.md index 77d43afb..2fa999a5 100644 --- a/docs/examples/storage/update-file.md +++ b/docs/examples/storage/update-file.md @@ -5,7 +5,7 @@ void main() { // Init SDK Storage storage = Storage(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index e89c2bf3..6a98fea0 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -5,7 +5,7 @@ void main() { // Init SDK Teams teams = Teams(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/teams/create.md b/docs/examples/teams/create.md index fd89a481..74895b23 100644 --- a/docs/examples/teams/create.md +++ b/docs/examples/teams/create.md @@ -5,7 +5,7 @@ void main() { // Init SDK Teams teams = Teams(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/teams/delete-membership.md b/docs/examples/teams/delete-membership.md index 28069ad0..8c135994 100644 --- a/docs/examples/teams/delete-membership.md +++ b/docs/examples/teams/delete-membership.md @@ -5,7 +5,7 @@ void main() { // Init SDK Teams teams = Teams(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/teams/delete.md b/docs/examples/teams/delete.md index a006e8f3..a5fee4d0 100644 --- a/docs/examples/teams/delete.md +++ b/docs/examples/teams/delete.md @@ -5,7 +5,7 @@ void main() { // Init SDK Teams teams = Teams(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/teams/get-membership.md b/docs/examples/teams/get-membership.md index 1beceeb3..4193b245 100644 --- a/docs/examples/teams/get-membership.md +++ b/docs/examples/teams/get-membership.md @@ -5,7 +5,7 @@ void main() { // Init SDK Teams teams = Teams(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/teams/get-prefs.md b/docs/examples/teams/get-prefs.md index d176392e..27f2ef15 100644 --- a/docs/examples/teams/get-prefs.md +++ b/docs/examples/teams/get-prefs.md @@ -5,7 +5,7 @@ void main() { // Init SDK Teams teams = Teams(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token ; diff --git a/docs/examples/teams/get.md b/docs/examples/teams/get.md index a1bfe8e7..daa67c4e 100644 --- a/docs/examples/teams/get.md +++ b/docs/examples/teams/get.md @@ -5,7 +5,7 @@ void main() { // Init SDK Teams teams = Teams(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/teams/list-memberships.md b/docs/examples/teams/list-memberships.md index 6f993910..74c66c03 100644 --- a/docs/examples/teams/list-memberships.md +++ b/docs/examples/teams/list-memberships.md @@ -5,7 +5,7 @@ void main() { // Init SDK Teams teams = Teams(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/teams/list.md b/docs/examples/teams/list.md index d55e58e3..11033f33 100644 --- a/docs/examples/teams/list.md +++ b/docs/examples/teams/list.md @@ -5,7 +5,7 @@ void main() { // Init SDK Teams teams = Teams(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/teams/update-membership-roles.md b/docs/examples/teams/update-membership-roles.md index e3488768..dcbef5c9 100644 --- a/docs/examples/teams/update-membership-roles.md +++ b/docs/examples/teams/update-membership-roles.md @@ -5,7 +5,7 @@ void main() { // Init SDK Teams teams = Teams(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/teams/update-membership-status.md b/docs/examples/teams/update-membership-status.md index 2a3f1e10..ca704e0f 100644 --- a/docs/examples/teams/update-membership-status.md +++ b/docs/examples/teams/update-membership-status.md @@ -5,7 +5,7 @@ void main() { // Init SDK Teams teams = Teams(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token ; diff --git a/docs/examples/teams/update-name.md b/docs/examples/teams/update-name.md index 17d2c5eb..088a5cfb 100644 --- a/docs/examples/teams/update-name.md +++ b/docs/examples/teams/update-name.md @@ -5,7 +5,7 @@ void main() { // Init SDK Teams teams = Teams(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/teams/update-prefs.md b/docs/examples/teams/update-prefs.md index cb171e20..d99e8217 100644 --- a/docs/examples/teams/update-prefs.md +++ b/docs/examples/teams/update-prefs.md @@ -5,7 +5,7 @@ void main() { // Init SDK Teams teams = Teams(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token ; diff --git a/docs/examples/users/create-argon2user.md b/docs/examples/users/create-argon2user.md index f2ece2b2..a40b3afd 100644 --- a/docs/examples/users/create-argon2user.md +++ b/docs/examples/users/create-argon2user.md @@ -5,7 +5,7 @@ void main() { // Init SDK Users users = Users(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/users/create-bcrypt-user.md b/docs/examples/users/create-bcrypt-user.md index b4951a94..8b55d656 100644 --- a/docs/examples/users/create-bcrypt-user.md +++ b/docs/examples/users/create-bcrypt-user.md @@ -5,7 +5,7 @@ void main() { // Init SDK Users users = Users(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/users/create-m-d5user.md b/docs/examples/users/create-m-d5user.md index 95f6e539..3ab8901f 100644 --- a/docs/examples/users/create-m-d5user.md +++ b/docs/examples/users/create-m-d5user.md @@ -5,7 +5,7 @@ void main() { // Init SDK Users users = Users(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/users/create-p-h-pass-user.md b/docs/examples/users/create-p-h-pass-user.md index 9013ccc9..bedb44f4 100644 --- a/docs/examples/users/create-p-h-pass-user.md +++ b/docs/examples/users/create-p-h-pass-user.md @@ -5,7 +5,7 @@ void main() { // Init SDK Users users = Users(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/users/create-s-h-a-user.md b/docs/examples/users/create-s-h-a-user.md index 44887650..361f309a 100644 --- a/docs/examples/users/create-s-h-a-user.md +++ b/docs/examples/users/create-s-h-a-user.md @@ -5,7 +5,7 @@ void main() { // Init SDK Users users = Users(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/users/create-scrypt-modified-user.md b/docs/examples/users/create-scrypt-modified-user.md index e1187488..fa5b8051 100644 --- a/docs/examples/users/create-scrypt-modified-user.md +++ b/docs/examples/users/create-scrypt-modified-user.md @@ -5,7 +5,7 @@ void main() { // Init SDK Users users = Users(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/users/create-scrypt-user.md b/docs/examples/users/create-scrypt-user.md index 01a11bbe..91e1f7dc 100644 --- a/docs/examples/users/create-scrypt-user.md +++ b/docs/examples/users/create-scrypt-user.md @@ -5,7 +5,7 @@ void main() { // Init SDK Users users = Users(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/users/create.md b/docs/examples/users/create.md index 6effead3..517cd22f 100644 --- a/docs/examples/users/create.md +++ b/docs/examples/users/create.md @@ -5,7 +5,7 @@ void main() { // Init SDK Users users = Users(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/users/delete-session.md b/docs/examples/users/delete-session.md index eaa98c17..3f761187 100644 --- a/docs/examples/users/delete-session.md +++ b/docs/examples/users/delete-session.md @@ -5,7 +5,7 @@ void main() { // Init SDK Users users = Users(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/users/delete-sessions.md b/docs/examples/users/delete-sessions.md index 8c889aad..69cbc5e8 100644 --- a/docs/examples/users/delete-sessions.md +++ b/docs/examples/users/delete-sessions.md @@ -5,7 +5,7 @@ void main() { // Init SDK Users users = Users(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/users/delete.md b/docs/examples/users/delete.md index b45f398b..1e1311d5 100644 --- a/docs/examples/users/delete.md +++ b/docs/examples/users/delete.md @@ -5,7 +5,7 @@ void main() { // Init SDK Users users = Users(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/users/get-prefs.md b/docs/examples/users/get-prefs.md index e5909422..eb33ae65 100644 --- a/docs/examples/users/get-prefs.md +++ b/docs/examples/users/get-prefs.md @@ -5,7 +5,7 @@ void main() { // Init SDK Users users = Users(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/users/get.md b/docs/examples/users/get.md index be582d52..c5685293 100644 --- a/docs/examples/users/get.md +++ b/docs/examples/users/get.md @@ -5,7 +5,7 @@ void main() { // Init SDK Users users = Users(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/users/list-logs.md b/docs/examples/users/list-logs.md index 35f78fb7..0d2143ad 100644 --- a/docs/examples/users/list-logs.md +++ b/docs/examples/users/list-logs.md @@ -5,7 +5,7 @@ void main() { // Init SDK Users users = Users(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/users/list-memberships.md b/docs/examples/users/list-memberships.md index 774f1b88..36a83ede 100644 --- a/docs/examples/users/list-memberships.md +++ b/docs/examples/users/list-memberships.md @@ -5,7 +5,7 @@ void main() { // Init SDK Users users = Users(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/users/list-sessions.md b/docs/examples/users/list-sessions.md index e69f59a7..5f77fdbf 100644 --- a/docs/examples/users/list-sessions.md +++ b/docs/examples/users/list-sessions.md @@ -5,7 +5,7 @@ void main() { // Init SDK Users users = Users(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/users/list.md b/docs/examples/users/list.md index e0ecf7ad..34498c00 100644 --- a/docs/examples/users/list.md +++ b/docs/examples/users/list.md @@ -5,7 +5,7 @@ void main() { // Init SDK Users users = Users(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/users/update-email-verification.md b/docs/examples/users/update-email-verification.md index fbbe2859..8853f865 100644 --- a/docs/examples/users/update-email-verification.md +++ b/docs/examples/users/update-email-verification.md @@ -5,7 +5,7 @@ void main() { // Init SDK Users users = Users(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/users/update-email.md b/docs/examples/users/update-email.md index dc3e063a..8813e110 100644 --- a/docs/examples/users/update-email.md +++ b/docs/examples/users/update-email.md @@ -5,7 +5,7 @@ void main() { // Init SDK Users users = Users(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/users/update-name.md b/docs/examples/users/update-name.md index 192add91..56797d58 100644 --- a/docs/examples/users/update-name.md +++ b/docs/examples/users/update-name.md @@ -5,7 +5,7 @@ void main() { // Init SDK Users users = Users(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/users/update-password.md b/docs/examples/users/update-password.md index 076e0e2c..3dfedb4d 100644 --- a/docs/examples/users/update-password.md +++ b/docs/examples/users/update-password.md @@ -5,7 +5,7 @@ void main() { // Init SDK Users users = Users(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/users/update-phone-verification.md b/docs/examples/users/update-phone-verification.md index 6993c0f3..37c3ced6 100644 --- a/docs/examples/users/update-phone-verification.md +++ b/docs/examples/users/update-phone-verification.md @@ -5,7 +5,7 @@ void main() { // Init SDK Users users = Users(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/users/update-phone.md b/docs/examples/users/update-phone.md index 00d4945b..4d5e3110 100644 --- a/docs/examples/users/update-phone.md +++ b/docs/examples/users/update-phone.md @@ -5,7 +5,7 @@ void main() { // Init SDK Users users = Users(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/users/update-prefs.md b/docs/examples/users/update-prefs.md index d148e52f..c6c1bbed 100644 --- a/docs/examples/users/update-prefs.md +++ b/docs/examples/users/update-prefs.md @@ -5,7 +5,7 @@ void main() { // Init SDK Users users = Users(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/docs/examples/users/update-status.md b/docs/examples/users/update-status.md index 43921889..6f80745a 100644 --- a/docs/examples/users/update-status.md +++ b/docs/examples/users/update-status.md @@ -5,7 +5,7 @@ void main() { // Init SDK Users users = Users(client); client - .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; diff --git a/lib/dart_appwrite.dart b/lib/dart_appwrite.dart index e90eaa3a..25a07d30 100644 --- a/lib/dart_appwrite.dart +++ b/lib/dart_appwrite.dart @@ -1,3 +1,8 @@ +/// Appwrite Dart SDK +/// +/// This SDK is compatible with Appwrite server version 1.3.x. +/// For older versions, please check +/// [previous releases](https://github.com/appwrite/sdk-for-dart/releases). library dart_appwrite; import 'dart:async'; diff --git a/lib/id.dart b/lib/id.dart index b7518828..ae9028ef 100644 --- a/lib/id.dart +++ b/lib/id.dart @@ -1,13 +1,16 @@ part of dart_appwrite; +/// Helper class to generate ID strings for resources. class ID { - ID._(); - - static String unique() { - return 'unique()'; - } + ID._(); - static String custom(String id) { - return id; - } + /// Have Appwrite generate a unique ID for you. + static String unique() { + return 'unique()'; + } + + /// Uses [id] as the ID for the resource. + static String custom(String id) { + return id; + } } \ No newline at end of file diff --git a/lib/models.dart b/lib/models.dart index d7a0a2da..f7bdc0af 100644 --- a/lib/models.dart +++ b/lib/models.dart @@ -1,3 +1,4 @@ +/// Appwrite Models library dart_appwrite.models; part 'src/models/model.dart'; diff --git a/lib/permission.dart b/lib/permission.dart index 0da10f62..5ad46d15 100644 --- a/lib/permission.dart +++ b/lib/permission.dart @@ -1,21 +1,34 @@ part of dart_appwrite; +/// Helper class to generate permission strings for resources. class Permission { - Permission._(); + Permission._(); - static String read(String role) { - return 'read("$role")'; - } - static String write(String role) { - return 'write("$role")'; - } - static String create(String role) { - return 'create("$role")'; - } - static String update(String role) { - return 'update("$role")'; - } - static String delete(String role) { - return 'delete("$role")'; - } + /// Read permission for provided [role] + static String read(String role) { + return 'read("$role")'; + } + + /// Write permission for provided [role] + /// + /// This is an alias of update, delete, and possibly create. + /// Don't use write in combination with update, delete, or create. + static String write(String role) { + return 'write("$role")'; + } + + /// Create permission for provided [role] + static String create(String role) { + return 'create("$role")'; + } + + /// Update permission for provided [role] + static String update(String role) { + return 'update("$role")'; + } + + /// Delete permission for provided [role] + static String delete(String role) { + return 'delete("$role")'; + } } diff --git a/lib/query.dart b/lib/query.dart index 91350530..658c034a 100644 --- a/lib/query.dart +++ b/lib/query.dart @@ -1,61 +1,99 @@ part of dart_appwrite; +/// Helper class to generate query strings. class Query { - Query._(); - + Query._(); + + /// Filter resources where [attribute] is 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 equal(String attribute, dynamic value) => _addQuery(attribute, 'equal', value); + /// 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); + /// Filter resources where [attribute] is less than [value]. static String lessThan(String attribute, dynamic value) => _addQuery(attribute, 'lessThan', value); + /// Filter resources where [attribute] is less than or equal to [value]. static String lessThanEqual(String attribute, dynamic value) => _addQuery(attribute, 'lessThanEqual', value); + /// Filter resources where [attribute] is greater than [value]. static String greaterThan(String attribute, dynamic value) => _addQuery(attribute, 'greaterThan', value); + /// Filter resources where [attribute] is greater than or equal to [value]. static String greaterThanEqual(String attribute, dynamic value) => _addQuery(attribute, 'greaterThanEqual', value); + /// Filter resources where by searching [attribute] for [value]. static String search(String attribute, String value) => _addQuery(attribute, 'search', value); + /// Filter resources where [attribute] is null. static String isNull(String attribute) => 'isNull("$attribute")'; + /// Filter resources where [attribute] is not null. static String isNotNull(String attribute) => 'isNotNull("$attribute")'; + /// Filter resources where [attribute] is between [start] and [end] (inclusive). static String between(String attribute, dynamic start, dynamic end) => _addQuery(attribute, 'between', [start, end]); + /// Filter resources where [attribute] starts with [value]. static String startsWith(String attribute, String value) => _addQuery(attribute, 'startsWith', value); + /// Filter resources where [attribute] ends with [value]. static String endsWith(String attribute, String value) => _addQuery(attribute, 'endsWith', value); - static String select(List attributes) => 'select([${attributes.map((attr) => "\"$attr\"").join(",")}])'; + /// Specify which attributes should be returned by the API call. + static String select(List attributes) => + 'select([${attributes.map((attr) => "\"$attr\"").join(",")}])'; + /// Sort results by [attribute] ascending. static String orderAsc(String attribute) => 'orderAsc("$attribute")'; + /// Sort results by [attribute] descending. static String orderDesc(String attribute) => 'orderDesc("$attribute")'; + /// 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")'; + /// 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")'; + /// Return only [limit] results. static String limit(int limit) => 'limit($limit)'; + /// 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)}])'; + ? '$method("$attribute", [${value.map((item) => _parseValues(item)).join(",")}])' + : '$method("$attribute", [${_parseValues(value)}])'; - static String parseValues(dynamic value) => + static String _parseValues(dynamic value) => (value is String) ? '"$value"' : '$value'; -} +} \ No newline at end of file diff --git a/lib/role.dart b/lib/role.dart index 25ac1fea..8ba5cd70 100644 --- a/lib/role.dart +++ b/lib/role.dart @@ -1,12 +1,20 @@ part of dart_appwrite; +/// Helper class to generate role strings for [Permission]. class Role { Role._(); + /// Grants access to anyone. + /// + /// This includes authenticated and unauthenticated users. static String any() { return 'any'; } + /// Grants access to a specific user by user ID. + /// + /// You can optionally pass verified or unverified for + /// [status] to target specific types of users. static String user(String id, [String status = '']) { if(status.isEmpty) { return 'user:$id'; @@ -14,6 +22,10 @@ class Role { return 'user:$id/$status'; } + /// Grants access to any authenticated or anonymous user. + /// + /// You can optionally pass verified or unverified for + /// [status] to target specific types of users. static String users([String status = '']) { if(status.isEmpty) { return 'users'; @@ -21,10 +33,17 @@ class Role { return 'users/$status'; } + /// Grants access to any guest user without a session. + /// + /// Authenticated users don't have access to this role. static String guests() { return 'guests'; } + /// Grants access to a team by team ID. + /// + /// You can optionally pass a role for [role] to target + /// team members with the specified role. static String team(String id, [String role = '']) { if(role.isEmpty) { return 'team:$id'; @@ -32,6 +51,10 @@ class Role { return 'team:$id/$role'; } + /// Grants access to a specific member of a team. + /// + /// When the member is removed from the team, they will + /// no longer have access. static String member(String id) { return 'member:$id'; } diff --git a/lib/services/account.dart b/lib/services/account.dart index c4bdf410..a5aca239 100644 --- a/lib/services/account.dart +++ b/lib/services/account.dart @@ -1,13 +1,12 @@ part of dart_appwrite; - /// The Account service allows you to authenticate and manage a user account. +/// The Account service allows you to authenticate and manage a user account. class Account extends Service { Account(super.client); /// Get Account /// /// Get currently logged in user data as JSON object. - /// Future get() async { final String path = '/account'; @@ -25,8 +24,8 @@ class Account extends Service { return models.User.fromMap(res.data); - } + /// Update Email /// /// Update currently logged in user account email address. After changing user @@ -37,7 +36,6 @@ class Account extends Service { /// This endpoint can also be used to convert an anonymous account to a normal /// one, by passing an email address and a new password. /// - /// Future updateEmail({required String email, required String password}) async { final String path = '/account/email'; @@ -57,13 +55,12 @@ class Account extends Service { return models.User.fromMap(res.data); - } + /// List Logs /// /// Get currently logged in user list of latest security activity logs. Each /// log returns user IP address, location and date and time of log. - /// Future listLogs({List? queries}) async { final String path = '/account/logs'; @@ -82,12 +79,11 @@ class Account extends Service { return models.LogList.fromMap(res.data); - } + /// Update Name /// /// Update currently logged in user account name. - /// Future updateName({required String name}) async { final String path = '/account/name'; @@ -106,14 +102,13 @@ class Account extends Service { return models.User.fromMap(res.data); - } + /// Update Password /// /// Update currently logged in user password. For validation, user is required /// to pass in the new password, and the old password. For users created with /// OAuth, Team Invites and Magic URL, oldPassword is optional. - /// Future updatePassword({required String password, String? oldPassword}) async { final String path = '/account/password'; @@ -133,8 +128,8 @@ class Account extends Service { return models.User.fromMap(res.data); - } + /// Update Phone /// /// Update the currently logged in user's phone number. After updating the @@ -142,7 +137,6 @@ class Account extends Service { /// SMS is not sent automatically, however you can use the [POST /// /account/verification/phone](/docs/client/account#accountCreatePhoneVerification) /// endpoint to send a confirmation SMS. - /// Future updatePhone({required String phone, required String password}) async { final String path = '/account/phone'; @@ -162,12 +156,11 @@ class Account extends Service { return models.User.fromMap(res.data); - } + /// Get Account Preferences /// /// Get currently logged in user preferences as a key-value object. - /// Future getPrefs() async { final String path = '/account/prefs'; @@ -185,14 +178,13 @@ class Account extends Service { return models.Preferences.fromMap(res.data); - } + /// Update Preferences /// /// Update currently logged in user account preferences. The object you pass is /// stored as is, and replaces any previous value. The maximum allowed prefs /// size is 64kB and throws error if exceeded. - /// Future updatePrefs({required Map prefs}) async { final String path = '/account/prefs'; @@ -211,8 +203,8 @@ class Account extends Service { return models.User.fromMap(res.data); - } + /// Create Password Recovery /// /// Sends the user an email with a temporary secret key for password reset. @@ -223,7 +215,6 @@ class Account extends Service { /// /account/recovery](/docs/client/account#accountUpdateRecovery) endpoint to /// complete the process. The verification link sent to the user's email /// address is valid for 1 hour. - /// Future createRecovery({required String email, required String url}) async { final String path = '/account/recovery'; @@ -243,8 +234,8 @@ class Account extends Service { return models.Token.fromMap(res.data); - } + /// Create Password Recovery (confirmation) /// /// Use this endpoint to complete the user account password reset. Both the @@ -256,7 +247,6 @@ 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 updateRecovery({required String userId, required String secret, required String password, required String passwordAgain}) async { final String path = '/account/recovery'; @@ -278,13 +268,12 @@ class Account extends Service { return models.Token.fromMap(res.data); - } + /// List Sessions /// /// Get currently logged in user list of active sessions across different /// devices. - /// Future listSessions() async { final String path = '/account/sessions'; @@ -302,13 +291,12 @@ class Account extends Service { return models.SessionList.fromMap(res.data); - } + /// Delete Sessions /// /// Delete all sessions from the user account and remove any sessions cookies /// from the end client. - /// Future deleteSessions() async { final String path = '/account/sessions'; @@ -326,13 +314,12 @@ class Account extends Service { return res.data; - } + /// Get Session /// /// Use this endpoint to get a logged in user's session using a Session ID. /// Inputting 'current' will return the current session being used. - /// Future getSession({required String sessionId}) async { final String path = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); @@ -350,14 +337,13 @@ class Account extends Service { return models.Session.fromMap(res.data); - } + /// Update OAuth Session (Refresh Tokens) /// /// 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. - /// Future updateSession({required String sessionId}) async { final String path = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); @@ -375,15 +361,14 @@ class Account extends Service { return models.Session.fromMap(res.data); - } + /// Delete Session /// /// Use this endpoint to log out the currently logged in user from all their /// account sessions across all of their different devices. When using the /// Session ID argument, only the unique session ID provided is deleted. /// - /// Future deleteSession({required String sessionId}) async { final String path = '/account/sessions/{sessionId}'.replaceAll('{sessionId}', sessionId); @@ -401,14 +386,13 @@ class Account extends Service { return res.data; - } + /// Update Status /// /// Block the currently logged in user account. Behind the scene, the user /// record is not deleted but permanently blocked from any access. To /// completely delete a user, use the Users API instead. - /// Future updateStatus() async { final String path = '/account/status'; @@ -426,8 +410,8 @@ class Account extends Service { return models.User.fromMap(res.data); - } + /// Create Email Verification /// /// Use this endpoint to send a verification message to your user email address @@ -445,7 +429,6 @@ class Account extends Service { /// the only valid redirect URLs are the ones from domains you have set when /// adding your platforms in the console interface. /// - /// Future createVerification({required String url}) async { final String path = '/account/verification'; @@ -464,15 +447,14 @@ class Account extends Service { return models.Token.fromMap(res.data); - } + /// Create Email Verification (confirmation) /// /// Use this endpoint to complete the user email verification process. Use both /// the **userId** and **secret** parameters that were attached to your app URL /// to verify the user email ownership. If confirmed this route will return a /// 200 status code. - /// Future updateVerification({required String userId, required String secret}) async { final String path = '/account/verification'; @@ -492,8 +474,8 @@ class Account extends Service { return models.Token.fromMap(res.data); - } + /// Create Phone Verification /// /// Use this endpoint to send a verification SMS to the currently logged in @@ -502,7 +484,6 @@ class Account extends Service { /// endpoint. Learn more about how to [complete the verification /// process](/docs/client/account#accountUpdatePhoneVerification). The /// verification code sent to the user's phone number is valid for 15 minutes. - /// Future createPhoneVerification() async { final String path = '/account/verification/phone'; @@ -520,15 +501,14 @@ class Account extends Service { return models.Token.fromMap(res.data); - } + /// Create Phone Verification (confirmation) /// /// Use this endpoint to complete the user phone verification process. Use the /// **userId** and **secret** that were sent to your user's phone number to /// verify the user email ownership. If confirmed this route will return a 200 /// status code. - /// Future updatePhoneVerification({required String userId, required String secret}) async { final String path = '/account/verification/phone'; @@ -548,6 +528,5 @@ class Account extends Service { return models.Token.fromMap(res.data); - } } \ No newline at end of file diff --git a/lib/services/avatars.dart b/lib/services/avatars.dart index 12c5d819..200ab77d 100644 --- a/lib/services/avatars.dart +++ b/lib/services/avatars.dart @@ -1,7 +1,7 @@ part of dart_appwrite; - /// The Avatars service aims to help you complete everyday tasks related to - /// your app image, icons, and avatars. +/// The Avatars service aims to help you complete everyday tasks related to +/// your app image, icons, and avatars. class Avatars extends Service { Avatars(super.client); @@ -16,7 +16,6 @@ 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 getBrowser({required String code, int? width, int? height, int? quality}) async { final String path = '/avatars/browsers/{code}'.replaceAll('{code}', code); @@ -32,8 +31,8 @@ class Avatars extends Service { final res = await client.call(HttpMethod.get, path: path, params: params, responseType: ResponseType.bytes); return res.data; - } + /// Get Credit Card Icon /// /// The credit card endpoint will return you the icon of the credit card @@ -45,7 +44,6 @@ class Avatars extends Service { /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. /// - /// Future getCreditCard({required String code, int? width, int? height, int? quality}) async { final String path = '/avatars/credit-cards/{code}'.replaceAll('{code}', code); @@ -61,14 +59,13 @@ class Avatars extends Service { final res = await client.call(HttpMethod.get, path: path, params: params, responseType: ResponseType.bytes); return res.data; - } + /// Get Favicon /// /// Use this endpoint to fetch the favorite icon (AKA favicon) of any remote /// website URL. /// - /// Future getFavicon({required String url}) async { final String path = '/avatars/favicon'; @@ -82,8 +79,8 @@ class Avatars extends Service { final res = await client.call(HttpMethod.get, path: path, params: params, responseType: ResponseType.bytes); return res.data; - } + /// Get Country Flag /// /// You can use this endpoint to show different country flags icons to your @@ -96,7 +93,6 @@ class Avatars extends Service { /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. /// - /// Future getFlag({required String code, int? width, int? height, int? quality}) async { final String path = '/avatars/flags/{code}'.replaceAll('{code}', code); @@ -112,8 +108,8 @@ class Avatars extends Service { final res = await client.call(HttpMethod.get, path: path, params: params, responseType: ResponseType.bytes); return res.data; - } + /// Get Image from URL /// /// Use this endpoint to fetch a remote image URL and crop it to any image size @@ -126,7 +122,6 @@ class Avatars extends Service { /// image at source quality. If dimensions are not specified, the default size /// of image returned is 400x400px. /// - /// Future getImage({required String url, int? width, int? height}) async { final String path = '/avatars/image'; @@ -142,8 +137,8 @@ class Avatars extends Service { final res = await client.call(HttpMethod.get, path: path, params: params, responseType: ResponseType.bytes); return res.data; - } + /// Get User Initials /// /// Use this endpoint to show your user initials avatar icon on your website or @@ -162,7 +157,6 @@ class Avatars extends Service { /// image at source quality. If dimensions are not specified, the default size /// of image returned is 100x100px. /// - /// Future getInitials({String? name, int? width, int? height, String? background}) async { final String path = '/avatars/initials'; @@ -179,14 +173,13 @@ class Avatars extends Service { final res = await client.call(HttpMethod.get, path: path, params: params, responseType: ResponseType.bytes); return res.data; - } + /// Get QR Code /// /// Converts a given plain text to a QR code image. You can use the query /// parameters to change the size and style of the resulting image. /// - /// Future getQR({required String text, int? size, int? margin, bool? download}) async { final String path = '/avatars/qr'; @@ -203,6 +196,5 @@ class Avatars extends Service { final res = await client.call(HttpMethod.get, path: path, params: params, responseType: ResponseType.bytes); return res.data; - } } \ No newline at end of file diff --git a/lib/services/databases.dart b/lib/services/databases.dart index dc7727e7..d4e9e586 100644 --- a/lib/services/databases.dart +++ b/lib/services/databases.dart @@ -1,7 +1,7 @@ part of dart_appwrite; - /// The Databases service allows you to create structured collections of - /// documents, query and filter lists of documents +/// The Databases service allows you to create structured collections of +/// documents, query and filter lists of documents class Databases extends Service { Databases(super.client); @@ -9,7 +9,6 @@ class Databases extends Service { /// /// Get a list of all databases from the current Appwrite project. You can use /// the search parameter to filter your results. - /// Future list({List? queries, String? search}) async { final String path = '/databases'; @@ -29,13 +28,12 @@ class Databases extends Service { return models.DatabaseList.fromMap(res.data); - } + /// Create Database /// /// Create a new Database. /// - /// Future create({required String databaseId, required String name}) async { final String path = '/databases'; @@ -55,13 +53,12 @@ class Databases extends Service { return models.Database.fromMap(res.data); - } + /// Get Database /// /// Get a database by its unique ID. This endpoint response returns a JSON /// object with the database metadata. - /// Future get({required String databaseId}) async { final String path = '/databases/{databaseId}'.replaceAll('{databaseId}', databaseId); @@ -79,12 +76,11 @@ class Databases extends Service { return models.Database.fromMap(res.data); - } + /// Update Database /// /// Update a database by its unique ID. - /// Future update({required String databaseId, required String name}) async { final String path = '/databases/{databaseId}'.replaceAll('{databaseId}', databaseId); @@ -103,13 +99,12 @@ class Databases extends Service { return models.Database.fromMap(res.data); - } + /// Delete Database /// /// Delete a database by its unique ID. Only API keys with with databases.write /// scope can delete a database. - /// Future delete({required String databaseId}) async { final String path = '/databases/{databaseId}'.replaceAll('{databaseId}', databaseId); @@ -127,13 +122,12 @@ class Databases extends Service { return res.data; - } + /// List Collections /// /// Get a list of all collections that belong to the provided databaseId. You /// can use the search parameter to filter your results. - /// Future listCollections({required String databaseId, List? queries, String? search}) async { final String path = '/databases/{databaseId}/collections'.replaceAll('{databaseId}', databaseId); @@ -153,15 +147,14 @@ class Databases extends Service { return models.CollectionList.fromMap(res.data); - } + /// Create Collection /// /// Create a new Collection. Before using this route, you should create a new /// database resource using either a [server /// integration](/docs/server/databases#databasesCreateCollection) API or /// directly from your database console. - /// Future createCollection({required String databaseId, required String collectionId, required String name, List? permissions, bool? documentSecurity}) async { final String path = '/databases/{databaseId}/collections'.replaceAll('{databaseId}', databaseId); @@ -183,13 +176,12 @@ class Databases extends Service { return models.Collection.fromMap(res.data); - } + /// Get Collection /// /// Get a collection by its unique ID. This endpoint response returns a JSON /// object with the collection metadata. - /// Future getCollection({required String databaseId, required String collectionId}) async { final String path = '/databases/{databaseId}/collections/{collectionId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); @@ -207,12 +199,11 @@ class Databases extends Service { return models.Collection.fromMap(res.data); - } + /// Update Collection /// /// Update a collection by its unique ID. - /// Future updateCollection({required String databaseId, required String collectionId, required String name, List? permissions, bool? documentSecurity, bool? enabled}) async { final String path = '/databases/{databaseId}/collections/{collectionId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); @@ -234,13 +225,12 @@ class Databases extends Service { return models.Collection.fromMap(res.data); - } + /// Delete Collection /// /// Delete a collection by its unique ID. Only users with write permissions /// have access to delete this resource. - /// Future deleteCollection({required String databaseId, required String collectionId}) async { final String path = '/databases/{databaseId}/collections/{collectionId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); @@ -258,9 +248,10 @@ class Databases extends Service { return res.data; - } + /// List Attributes + /// Future listAttributes({required String databaseId, required String collectionId}) async { final String path = '/databases/{databaseId}/collections/{collectionId}/attributes'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); @@ -278,13 +269,12 @@ class Databases extends Service { return models.AttributeList.fromMap(res.data); - } + /// Create Boolean Attribute /// /// Create a boolean attribute. /// - /// Future createBooleanAttribute({required String databaseId, required String collectionId, required String key, required bool xrequired, bool? xdefault, bool? array}) async { final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); @@ -306,9 +296,10 @@ class Databases extends Service { return models.AttributeBoolean.fromMap(res.data); - } + /// Update Boolean Attribute + /// Future updateBooleanAttribute({required String databaseId, required String collectionId, required String key, required bool xrequired, required bool? xdefault}) async { final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); @@ -328,9 +319,10 @@ class Databases extends Service { return models.AttributeBoolean.fromMap(res.data); - } + /// Create DateTime Attribute + /// Future createDatetimeAttribute({required String databaseId, required String collectionId, required String key, required bool xrequired, String? xdefault, bool? array}) async { final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); @@ -352,9 +344,10 @@ class Databases extends Service { return models.AttributeDatetime.fromMap(res.data); - } + /// Update DateTime Attribute + /// Future updateDatetimeAttribute({required String databaseId, required String collectionId, required String key, required bool xrequired, required String? xdefault}) async { final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); @@ -374,13 +367,12 @@ class Databases extends Service { return models.AttributeDatetime.fromMap(res.data); - } + /// Create Email Attribute /// /// Create an email attribute. /// - /// Future createEmailAttribute({required String databaseId, required String collectionId, required String key, required bool xrequired, String? xdefault, bool? array}) async { final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/email'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); @@ -402,14 +394,13 @@ class Databases extends Service { return models.AttributeEmail.fromMap(res.data); - } + /// Update Email Attribute /// /// Update an email attribute. Changing the `default` value will not update /// already existing documents. /// - /// Future updateEmailAttribute({required String databaseId, required String collectionId, required String key, required bool xrequired, required String? xdefault}) async { final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/email/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); @@ -429,9 +420,10 @@ class Databases extends Service { return models.AttributeEmail.fromMap(res.data); - } + /// Create Enum Attribute + /// Future createEnumAttribute({required String databaseId, required String collectionId, required String key, required List elements, required bool xrequired, String? xdefault, bool? array}) async { final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); @@ -454,14 +446,13 @@ class Databases extends Service { return models.AttributeEnum.fromMap(res.data); - } + /// Update Enum Attribute /// /// Update an enum attribute. Changing the `default` value will not update /// already existing documents. /// - /// Future updateEnumAttribute({required String databaseId, required String collectionId, required String key, required List elements, required bool xrequired, required String? xdefault}) async { final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); @@ -482,14 +473,13 @@ class Databases extends Service { return models.AttributeEnum.fromMap(res.data); - } + /// Create Float Attribute /// /// Create a float attribute. Optionally, minimum and maximum values can be /// provided. /// - /// Future createFloatAttribute({required String databaseId, required String collectionId, required String key, required bool xrequired, double? min, double? max, double? xdefault, bool? array}) async { final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/float'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); @@ -513,14 +503,13 @@ class Databases extends Service { return models.AttributeFloat.fromMap(res.data); - } + /// Update Float Attribute /// /// Update a float attribute. Changing the `default` value will not update /// already existing documents. /// - /// Future updateFloatAttribute({required String databaseId, required String collectionId, required String key, required bool xrequired, required double min, required double max, required double? xdefault}) async { final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/float/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); @@ -542,14 +531,13 @@ class Databases extends Service { return models.AttributeFloat.fromMap(res.data); - } + /// Create Integer Attribute /// /// Create an integer attribute. Optionally, minimum and maximum values can be /// provided. /// - /// Future createIntegerAttribute({required String databaseId, required String collectionId, required String key, required bool xrequired, int? min, int? max, int? xdefault, bool? array}) async { final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); @@ -573,14 +561,13 @@ class Databases extends Service { return models.AttributeInteger.fromMap(res.data); - } + /// Update Integer Attribute /// /// Update an integer attribute. Changing the `default` value will not update /// already existing documents. /// - /// Future updateIntegerAttribute({required String databaseId, required String collectionId, required String key, required bool xrequired, required int min, required int max, required int? xdefault}) async { final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); @@ -602,13 +589,12 @@ class Databases extends Service { return models.AttributeInteger.fromMap(res.data); - } + /// Create IP Address Attribute /// /// Create IP address attribute. /// - /// Future createIpAttribute({required String databaseId, required String collectionId, required String key, required bool xrequired, String? xdefault, bool? array}) async { final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); @@ -630,14 +616,13 @@ class Databases extends Service { return models.AttributeIp.fromMap(res.data); - } + /// Update IP Address Attribute /// /// Update an ip attribute. Changing the `default` value will not update /// already existing documents. /// - /// Future updateIpAttribute({required String databaseId, required String collectionId, required String key, required bool xrequired, required String? xdefault}) async { final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); @@ -657,14 +642,13 @@ class Databases extends Service { return models.AttributeIp.fromMap(res.data); - } + /// Create Relationship Attribute /// /// Create relationship attribute. [Learn more about relationship - /// attributes](docs/databases-relationships#relationship-attributes). + /// attributes](/docs/databases-relationships#relationship-attributes). /// - /// Future createRelationshipAttribute({required String databaseId, required String collectionId, required String relatedCollectionId, required String type, bool? twoWay, String? key, String? twoWayKey, String? onDelete}) async { final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); @@ -688,13 +672,12 @@ class Databases extends Service { return models.AttributeRelationship.fromMap(res.data); - } + /// Create String Attribute /// /// Create a string attribute. /// - /// Future createStringAttribute({required String databaseId, required String collectionId, required String key, required int size, required bool xrequired, String? xdefault, bool? array}) async { final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/string'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); @@ -717,14 +700,13 @@ class Databases extends Service { return models.AttributeString.fromMap(res.data); - } + /// Update String Attribute /// /// Update a string attribute. Changing the `default` value will not update /// already existing documents. /// - /// Future updateStringAttribute({required String databaseId, required String collectionId, required String key, required bool xrequired, required String? xdefault}) async { final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/string/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); @@ -744,13 +726,12 @@ class Databases extends Service { return models.AttributeString.fromMap(res.data); - } + /// Create URL Attribute /// /// Create a URL attribute. /// - /// Future createUrlAttribute({required String databaseId, required String collectionId, required String key, required bool xrequired, String? xdefault, bool? array}) async { final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/url'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); @@ -772,14 +753,13 @@ class Databases extends Service { return models.AttributeUrl.fromMap(res.data); - } + /// Update URL Attribute /// /// Update an url attribute. Changing the `default` value will not update /// already existing documents. /// - /// Future updateUrlAttribute({required String databaseId, required String collectionId, required String key, required bool xrequired, required String? xdefault}) async { final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/url/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); @@ -799,9 +779,10 @@ class Databases extends Service { return models.AttributeUrl.fromMap(res.data); - } + /// Get Attribute + /// Future getAttribute({required String databaseId, required String collectionId, required String key}) async { final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); @@ -819,9 +800,10 @@ class Databases extends Service { return res.data; - } + /// Delete Attribute + /// Future deleteAttribute({required String databaseId, required String collectionId, required String key}) async { final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); @@ -839,14 +821,13 @@ class Databases extends Service { return res.data; - } + /// Update Relationship Attribute /// /// Update relationship attribute. [Learn more about relationship - /// attributes](docs/databases-relationships#relationship-attributes). + /// attributes](/docs/databases-relationships#relationship-attributes). /// - /// Future updateRelationshipAttribute({required String databaseId, required String collectionId, required String key, String? onDelete}) async { final String path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}/relationship'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); @@ -865,13 +846,12 @@ class Databases extends Service { return models.AttributeRelationship.fromMap(res.data); - } + /// List Documents /// /// Get a list of all the user's documents in a given collection. You can use /// the query params to filter your results. - /// Future listDocuments({required String databaseId, required String collectionId, List? queries}) async { final String path = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); @@ -890,15 +870,14 @@ class Databases extends Service { return models.DocumentList.fromMap(res.data); - } + /// Create Document /// /// Create a new Document. Before using this route, you should create a new /// collection resource using either a [server /// integration](/docs/server/databases#databasesCreateCollection) API or /// directly from your database console. - /// Future createDocument({required String databaseId, required String collectionId, required String documentId, required Map data, List? permissions}) async { final String path = '/databases/{databaseId}/collections/{collectionId}/documents'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); @@ -919,13 +898,12 @@ class Databases extends Service { return models.Document.fromMap(res.data); - } + /// Get Document /// /// Get a document by its unique ID. This endpoint response returns a JSON /// object with the document data. - /// Future getDocument({required String databaseId, required String collectionId, required String documentId, List? queries}) async { final String path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); @@ -944,13 +922,12 @@ class Databases extends Service { return models.Document.fromMap(res.data); - } + /// Update Document /// /// Update a document by its unique ID. Using the patch method you can pass /// only specific fields that will get updated. - /// Future updateDocument({required String databaseId, required String collectionId, required String documentId, Map? data, List? permissions}) async { final String path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); @@ -970,12 +947,11 @@ class Databases extends Service { return models.Document.fromMap(res.data); - } + /// Delete Document /// /// Delete a document by its unique ID. - /// Future deleteDocument({required String databaseId, required String collectionId, required String documentId}) async { final String path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{documentId}', documentId); @@ -993,9 +969,10 @@ class Databases extends Service { return res.data; - } + /// List Indexes + /// Future listIndexes({required String databaseId, required String collectionId}) async { final String path = '/databases/{databaseId}/collections/{collectionId}/indexes'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); @@ -1013,9 +990,10 @@ class Databases extends Service { return models.IndexList.fromMap(res.data); - } + /// Create Index + /// Future createIndex({required String databaseId, required String collectionId, required String key, required String type, required List attributes, List? orders}) async { final String path = '/databases/{databaseId}/collections/{collectionId}/indexes'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId); @@ -1037,9 +1015,10 @@ class Databases extends Service { return models.Index.fromMap(res.data); - } + /// Get Index + /// Future getIndex({required String databaseId, required String collectionId, required String key}) async { final String path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); @@ -1057,9 +1036,10 @@ class Databases extends Service { return models.Index.fromMap(res.data); - } + /// Delete Index + /// Future deleteIndex({required String databaseId, required String collectionId, required String key}) async { final String path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'.replaceAll('{databaseId}', databaseId).replaceAll('{collectionId}', collectionId).replaceAll('{key}', key); @@ -1077,6 +1057,5 @@ class Databases extends Service { return res.data; - } } \ No newline at end of file diff --git a/lib/services/functions.dart b/lib/services/functions.dart index 09cd3b8b..ded4947b 100644 --- a/lib/services/functions.dart +++ b/lib/services/functions.dart @@ -1,7 +1,7 @@ part of dart_appwrite; - /// The Functions Service allows you view, create and manage your Cloud - /// Functions. +/// The Functions Service allows you view, create and manage your Cloud +/// Functions. class Functions extends Service { Functions(super.client); @@ -9,7 +9,6 @@ class Functions extends Service { /// /// Get a list of all the project's functions. You can use the query params to /// filter your results. - /// Future list({List? queries, String? search}) async { final String path = '/functions'; @@ -29,14 +28,13 @@ class Functions extends Service { return models.FunctionList.fromMap(res.data); - } + /// Create Function /// /// Create a new function. You can pass a list of /// [permissions](/docs/permissions) to allow different project users or team /// with access to execute the function using the client API. - /// Future create({required String functionId, required String name, required String runtime, List? execute, List? events, String? schedule, int? timeout, bool? enabled}) async { final String path = '/functions'; @@ -62,12 +60,11 @@ class Functions extends Service { return models.Func.fromMap(res.data); - } + /// List runtimes /// /// Get a list of all runtimes that are currently active on your instance. - /// Future listRuntimes() async { final String path = '/functions/runtimes'; @@ -85,12 +82,11 @@ class Functions extends Service { return models.RuntimeList.fromMap(res.data); - } + /// Get Function /// /// Get a function by its unique ID. - /// Future get({required String functionId}) async { final String path = '/functions/{functionId}'.replaceAll('{functionId}', functionId); @@ -108,12 +104,11 @@ class Functions extends Service { return models.Func.fromMap(res.data); - } + /// Update Function /// /// Update function by its unique ID. - /// Future update({required String functionId, required String name, List? execute, List? events, String? schedule, int? timeout, bool? enabled}) async { final String path = '/functions/{functionId}'.replaceAll('{functionId}', functionId); @@ -137,12 +132,11 @@ class Functions extends Service { return models.Func.fromMap(res.data); - } + /// Delete Function /// /// Delete a function by its unique ID. - /// Future delete({required String functionId}) async { final String path = '/functions/{functionId}'.replaceAll('{functionId}', functionId); @@ -160,13 +154,12 @@ class Functions extends Service { return res.data; - } + /// List Deployments /// /// Get a list of all the project's code deployments. You can use the query /// params to filter your results. - /// Future listDeployments({required String functionId, List? queries, String? search}) async { final String path = '/functions/{functionId}/deployments'.replaceAll('{functionId}', functionId); @@ -186,8 +179,8 @@ class Functions extends Service { return models.DeploymentList.fromMap(res.data); - } + /// Create Deployment /// /// Create a new function code deployment. Use this endpoint to upload a new @@ -200,7 +193,6 @@ class Functions extends Service { /// tutorial](/docs/functions). /// /// Use the "command" param to set the entry point used to execute your code. - /// Future createDeployment({required String functionId, required String entrypoint, required InputFile code, required bool activate, Function(UploadProgress)? onProgress}) async { final String path = '/functions/{functionId}/deployments'.replaceAll('{functionId}', functionId); @@ -230,12 +222,11 @@ class Functions extends Service { return models.Deployment.fromMap(res.data); - } + /// Get Deployment /// /// Get a code deployment by its unique ID. - /// Future getDeployment({required String functionId, required String deploymentId}) async { final String path = '/functions/{functionId}/deployments/{deploymentId}'.replaceAll('{functionId}', functionId).replaceAll('{deploymentId}', deploymentId); @@ -253,14 +244,13 @@ class Functions extends Service { return models.Deployment.fromMap(res.data); - } + /// Update Function Deployment /// /// Update the function code deployment ID using the unique function ID. Use /// this endpoint to switch the code deployment that should be executed by the /// execution endpoint. - /// Future updateDeployment({required String functionId, required String deploymentId}) async { final String path = '/functions/{functionId}/deployments/{deploymentId}'.replaceAll('{functionId}', functionId).replaceAll('{deploymentId}', deploymentId); @@ -278,12 +268,11 @@ class Functions extends Service { return models.Func.fromMap(res.data); - } + /// Delete Deployment /// /// Delete a code deployment by its unique ID. - /// Future deleteDeployment({required String functionId, required String deploymentId}) async { final String path = '/functions/{functionId}/deployments/{deploymentId}'.replaceAll('{functionId}', functionId).replaceAll('{deploymentId}', deploymentId); @@ -301,9 +290,10 @@ class Functions extends Service { return res.data; - } + /// Create Build + /// Future createBuild({required String functionId, required String deploymentId, required String buildId}) async { final String path = '/functions/{functionId}/deployments/{deploymentId}/builds/{buildId}'.replaceAll('{functionId}', functionId).replaceAll('{deploymentId}', deploymentId).replaceAll('{buildId}', buildId); @@ -321,13 +311,12 @@ class Functions extends Service { return res.data; - } + /// List Executions /// /// Get a list of all the current user function execution logs. You can use the /// query params to filter your results. - /// Future listExecutions({required String functionId, List? queries, String? search}) async { final String path = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); @@ -347,15 +336,14 @@ class Functions extends Service { return models.ExecutionList.fromMap(res.data); - } + /// Create Execution /// /// Trigger a function execution. The returned object will return you the /// 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 createExecution({required String functionId, String? data, bool? xasync}) async { final String path = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId); @@ -375,12 +363,11 @@ class Functions extends Service { return models.Execution.fromMap(res.data); - } + /// Get Execution /// /// Get a function execution log by its unique ID. - /// Future getExecution({required String functionId, required String executionId}) async { final String path = '/functions/{functionId}/executions/{executionId}'.replaceAll('{functionId}', functionId).replaceAll('{executionId}', executionId); @@ -398,12 +385,11 @@ class Functions extends Service { return models.Execution.fromMap(res.data); - } + /// List Variables /// /// Get a list of all variables of a specific function. - /// Future listVariables({required String functionId}) async { final String path = '/functions/{functionId}/variables'.replaceAll('{functionId}', functionId); @@ -421,13 +407,12 @@ class Functions extends Service { return models.VariableList.fromMap(res.data); - } + /// Create Variable /// /// Create a new function variable. These variables can be accessed within /// function in the `env` object under the request variable. - /// Future createVariable({required String functionId, required String key, required String value}) async { final String path = '/functions/{functionId}/variables'.replaceAll('{functionId}', functionId); @@ -447,12 +432,11 @@ class Functions extends Service { return models.Variable.fromMap(res.data); - } + /// Get Variable /// /// Get a variable by its unique ID. - /// Future getVariable({required String functionId, required String variableId}) async { final String path = '/functions/{functionId}/variables/{variableId}'.replaceAll('{functionId}', functionId).replaceAll('{variableId}', variableId); @@ -470,12 +454,11 @@ class Functions extends Service { return models.Variable.fromMap(res.data); - } + /// Update Variable /// /// Update variable by its unique ID. - /// Future updateVariable({required String functionId, required String variableId, required String key, String? value}) async { final String path = '/functions/{functionId}/variables/{variableId}'.replaceAll('{functionId}', functionId).replaceAll('{variableId}', variableId); @@ -495,12 +478,11 @@ class Functions extends Service { return models.Variable.fromMap(res.data); - } + /// Delete Variable /// /// Delete a variable by its unique ID. - /// Future deleteVariable({required String functionId, required String variableId}) async { final String path = '/functions/{functionId}/variables/{variableId}'.replaceAll('{functionId}', functionId).replaceAll('{variableId}', variableId); @@ -518,6 +500,5 @@ class Functions extends Service { return res.data; - } } \ No newline at end of file diff --git a/lib/services/graphql.dart b/lib/services/graphql.dart index 45d1ef57..798172bc 100644 --- a/lib/services/graphql.dart +++ b/lib/services/graphql.dart @@ -1,14 +1,13 @@ part of dart_appwrite; - /// The GraphQL API allows you to query and mutate your Appwrite server using - /// GraphQL. +/// The GraphQL API allows you to query and mutate your Appwrite server using +/// GraphQL. class Graphql extends Service { Graphql(super.client); /// GraphQL Endpoint /// /// Execute a GraphQL mutation. - /// Future query({required Map query}) async { final String path = '/graphql'; @@ -28,12 +27,11 @@ class Graphql extends Service { return res.data; - } + /// GraphQL Endpoint /// /// Execute a GraphQL mutation. - /// Future mutation({required Map query}) async { final String path = '/graphql/mutation'; @@ -53,6 +51,5 @@ class Graphql extends Service { return res.data; - } } \ No newline at end of file diff --git a/lib/services/health.dart b/lib/services/health.dart index eae57f6c..2e929727 100644 --- a/lib/services/health.dart +++ b/lib/services/health.dart @@ -1,14 +1,13 @@ part of dart_appwrite; - /// The Health service allows you to both validate and monitor your Appwrite - /// server's health. +/// The Health service allows you to both validate and monitor your Appwrite +/// server's health. class Health extends Service { Health(super.client); /// Get HTTP /// /// Check the Appwrite HTTP server is up and responsive. - /// Future get() async { final String path = '/health'; @@ -26,12 +25,11 @@ class Health extends Service { return models.HealthStatus.fromMap(res.data); - } + /// Get Antivirus /// /// Check the Appwrite Antivirus server is up and connection is successful. - /// Future getAntivirus() async { final String path = '/health/anti-virus'; @@ -49,13 +47,12 @@ class Health extends Service { return models.HealthAntivirus.fromMap(res.data); - } + /// Get Cache /// /// Check the Appwrite in-memory cache server is up and connection is /// successful. - /// Future getCache() async { final String path = '/health/cache'; @@ -73,12 +70,11 @@ class Health extends Service { return models.HealthStatus.fromMap(res.data); - } + /// Get DB /// /// Check the Appwrite database server is up and connection is successful. - /// Future getDB() async { final String path = '/health/db'; @@ -96,14 +92,13 @@ class Health extends Service { return models.HealthStatus.fromMap(res.data); - } + /// Get Certificates Queue /// /// Get the number of certificates that are waiting to be issued against /// [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue /// server. - /// Future getQueueCertificates() async { final String path = '/health/queue/certificates'; @@ -121,9 +116,10 @@ class Health extends Service { return models.HealthQueue.fromMap(res.data); - } + /// Get Functions Queue + /// Future getQueueFunctions() async { final String path = '/health/queue/functions'; @@ -141,13 +137,12 @@ class Health extends Service { return models.HealthQueue.fromMap(res.data); - } + /// Get Logs Queue /// /// Get the number of logs that are waiting to be processed in the Appwrite /// internal queue server. - /// Future getQueueLogs() async { final String path = '/health/queue/logs'; @@ -165,13 +160,12 @@ class Health extends Service { return models.HealthQueue.fromMap(res.data); - } + /// Get Webhooks Queue /// /// Get the number of webhooks that are waiting to be processed in the Appwrite /// internal queue server. - /// Future getQueueWebhooks() async { final String path = '/health/queue/webhooks'; @@ -189,12 +183,11 @@ class Health extends Service { return models.HealthQueue.fromMap(res.data); - } + /// Get Local Storage /// /// Check the Appwrite local storage device is up and connection is successful. - /// Future getStorageLocal() async { final String path = '/health/storage/local'; @@ -212,8 +205,8 @@ class Health extends Service { return models.HealthStatus.fromMap(res.data); - } + /// Get Time /// /// Check the Appwrite server time is synced with Google remote NTP server. We @@ -223,7 +216,6 @@ class Health extends Service { /// used by hundreds of millions of computers and devices to synchronize their /// clocks over the Internet. If your computer sets its own clock, it likely /// uses NTP. - /// Future getTime() async { final String path = '/health/time'; @@ -241,6 +233,5 @@ class Health extends Service { return models.HealthTime.fromMap(res.data); - } } \ No newline at end of file diff --git a/lib/services/locale.dart b/lib/services/locale.dart index ca5df563..75944864 100644 --- a/lib/services/locale.dart +++ b/lib/services/locale.dart @@ -1,7 +1,7 @@ part of dart_appwrite; - /// The Locale service allows you to customize your app based on your users' - /// location. +/// The Locale service allows you to customize your app based on your users' +/// location. class Locale extends Service { Locale(super.client); @@ -13,7 +13,6 @@ class Locale extends Service { /// supported language. /// /// ([IP Geolocation by DB-IP](https://db-ip.com)) - /// Future get() async { final String path = '/locale'; @@ -31,13 +30,12 @@ class Locale extends Service { return models.Locale.fromMap(res.data); - } + /// List Continents /// /// List of all continents. You can use the locale header to get the data in a /// supported language. - /// Future listContinents() async { final String path = '/locale/continents'; @@ -55,13 +53,12 @@ class Locale extends Service { return models.ContinentList.fromMap(res.data); - } + /// List Countries /// /// List of all countries. You can use the locale header to get the data in a /// supported language. - /// Future listCountries() async { final String path = '/locale/countries'; @@ -79,13 +76,12 @@ class Locale extends Service { return models.CountryList.fromMap(res.data); - } + /// List EU Countries /// /// List of all countries that are currently members of the EU. You can use the /// locale header to get the data in a supported language. - /// Future listCountriesEU() async { final String path = '/locale/countries/eu'; @@ -103,13 +99,12 @@ class Locale extends Service { return models.CountryList.fromMap(res.data); - } + /// List Countries Phone Codes /// /// List of all countries phone codes. You can use the locale header to get the /// data in a supported language. - /// Future listCountriesPhones() async { final String path = '/locale/countries/phones'; @@ -127,14 +122,13 @@ class Locale extends Service { return models.PhoneList.fromMap(res.data); - } + /// List Currencies /// /// List of all currencies, including currency symbol, name, plural, and /// decimal digits for all major and minor currencies. You can use the locale /// header to get the data in a supported language. - /// Future listCurrencies() async { final String path = '/locale/currencies'; @@ -152,13 +146,12 @@ class Locale extends Service { return models.CurrencyList.fromMap(res.data); - } + /// List Languages /// /// List of all languages classified by ISO 639-1 including 2-letter code, name /// in English, and name in the respective language. - /// Future listLanguages() async { final String path = '/locale/languages'; @@ -176,6 +169,5 @@ class Locale extends Service { return models.LanguageList.fromMap(res.data); - } } \ No newline at end of file diff --git a/lib/services/storage.dart b/lib/services/storage.dart index 9e16b4f5..8e3c1f8f 100644 --- a/lib/services/storage.dart +++ b/lib/services/storage.dart @@ -1,6 +1,6 @@ part of dart_appwrite; - /// The Storage service allows you to manage your project files. +/// The Storage service allows you to manage your project files. class Storage extends Service { Storage(super.client); @@ -8,7 +8,6 @@ class Storage extends Service { /// /// Get a list of all the storage buckets. You can use the query params to /// filter your results. - /// Future listBuckets({List? queries, String? search}) async { final String path = '/storage/buckets'; @@ -28,12 +27,11 @@ class Storage extends Service { return models.BucketList.fromMap(res.data); - } + /// Create bucket /// /// Create a new storage bucket. - /// Future createBucket({required String bucketId, required String name, List? permissions, bool? fileSecurity, bool? enabled, int? maximumFileSize, List? allowedFileExtensions, String? compression, bool? encryption, bool? antivirus}) async { final String path = '/storage/buckets'; @@ -61,13 +59,12 @@ class Storage extends Service { return models.Bucket.fromMap(res.data); - } + /// Get Bucket /// /// Get a storage bucket by its unique ID. This endpoint response returns a /// JSON object with the storage bucket metadata. - /// Future getBucket({required String bucketId}) async { final String path = '/storage/buckets/{bucketId}'.replaceAll('{bucketId}', bucketId); @@ -85,12 +82,11 @@ class Storage extends Service { return models.Bucket.fromMap(res.data); - } + /// Update Bucket /// /// Update a storage bucket by its unique ID. - /// Future updateBucket({required String bucketId, required String name, List? permissions, bool? fileSecurity, bool? enabled, int? maximumFileSize, List? allowedFileExtensions, String? compression, bool? encryption, bool? antivirus}) async { final String path = '/storage/buckets/{bucketId}'.replaceAll('{bucketId}', bucketId); @@ -117,12 +113,11 @@ class Storage extends Service { return models.Bucket.fromMap(res.data); - } + /// Delete Bucket /// /// Delete a storage bucket by its unique ID. - /// Future deleteBucket({required String bucketId}) async { final String path = '/storage/buckets/{bucketId}'.replaceAll('{bucketId}', bucketId); @@ -140,13 +135,12 @@ class Storage extends Service { return res.data; - } + /// List Files /// /// Get a list of all the user files. You can use the query params to filter /// your results. - /// Future listFiles({required String bucketId, List? queries, String? search}) async { final String path = '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); @@ -166,8 +160,8 @@ class Storage extends Service { return models.FileList.fromMap(res.data); - } + /// Create File /// /// Create a new file. Before using this route, you should create a new bucket @@ -188,7 +182,6 @@ class Storage extends Service { /// If you're creating a new file using one of the Appwrite SDKs, all the /// chunking logic will be managed by the SDK internally. /// - /// Future createFile({required String bucketId, required String fileId, required InputFile file, List? permissions, Function(UploadProgress)? onProgress}) async { final String path = '/storage/buckets/{bucketId}/files'.replaceAll('{bucketId}', bucketId); @@ -219,13 +212,12 @@ class Storage extends Service { return models.File.fromMap(res.data); - } + /// Get File /// /// Get a file by its unique ID. This endpoint response returns a JSON object /// with the file metadata. - /// Future getFile({required String bucketId, required String fileId}) async { final String path = '/storage/buckets/{bucketId}/files/{fileId}'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); @@ -243,13 +235,12 @@ class Storage extends Service { return models.File.fromMap(res.data); - } + /// Update File /// /// Update a file by its unique ID. Only users with write permissions have /// access to update this resource. - /// Future updateFile({required String bucketId, required String fileId, List? permissions}) async { final String path = '/storage/buckets/{bucketId}/files/{fileId}'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); @@ -268,13 +259,12 @@ class Storage extends Service { return models.File.fromMap(res.data); - } + /// Delete File /// /// Delete a file by its unique ID. Only users with write permissions have /// access to delete this resource. - /// Future deleteFile({required String bucketId, required String fileId}) async { final String path = '/storage/buckets/{bucketId}/files/{fileId}'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); @@ -292,14 +282,13 @@ class Storage extends Service { return res.data; - } + /// Get File for Download /// /// Get a file content by its unique ID. The endpoint response return with a /// 'Content-Disposition: attachment' header that tells the browser to start /// downloading the file to user downloads directory. - /// Future getFileDownload({required String bucketId, required String fileId}) async { final String path = '/storage/buckets/{bucketId}/files/{fileId}/download'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); @@ -312,8 +301,8 @@ class Storage extends Service { final res = await client.call(HttpMethod.get, path: path, params: params, responseType: ResponseType.bytes); return res.data; - } + /// Get File Preview /// /// Get a file preview image. Currently, this method supports preview for image @@ -321,7 +310,6 @@ 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 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 { final String path = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); @@ -345,14 +333,13 @@ class Storage extends Service { final res = await client.call(HttpMethod.get, path: path, params: params, responseType: ResponseType.bytes); return res.data; - } + /// Get File for View /// /// Get a file content by its unique ID. This endpoint is similar to the /// download method but returns with no 'Content-Disposition: attachment' /// header. - /// Future getFileView({required String bucketId, required String fileId}) async { final String path = '/storage/buckets/{bucketId}/files/{fileId}/view'.replaceAll('{bucketId}', bucketId).replaceAll('{fileId}', fileId); @@ -365,6 +352,5 @@ class Storage extends Service { final res = await client.call(HttpMethod.get, path: path, params: params, responseType: ResponseType.bytes); return res.data; - } } \ No newline at end of file diff --git a/lib/services/teams.dart b/lib/services/teams.dart index e319bd13..6f0d47e9 100644 --- a/lib/services/teams.dart +++ b/lib/services/teams.dart @@ -1,7 +1,7 @@ part of dart_appwrite; - /// The Teams service allows you to group users of your project and to enable - /// them to share read and write access to your project resources +/// The Teams service allows you to group users of your project and to enable +/// them to share read and write access to your project resources class Teams extends Service { Teams(super.client); @@ -9,7 +9,6 @@ class Teams extends Service { /// /// Get a list of all the teams in which the current user is a member. You can /// use the parameters to filter your results. - /// Future list({List? queries, String? search}) async { final String path = '/teams'; @@ -29,14 +28,13 @@ class Teams extends Service { return models.TeamList.fromMap(res.data); - } + /// Create Team /// /// Create a new team. The user who creates the team will automatically be /// assigned as the owner of the team. Only the users with the owner role can /// invite new members, add new owners and delete or update the team. - /// Future create({required String teamId, required String name, List? roles}) async { final String path = '/teams'; @@ -57,12 +55,11 @@ class Teams extends Service { return models.Team.fromMap(res.data); - } + /// Get Team /// /// Get a team by its ID. All team members have read access for this resource. - /// Future get({required String teamId}) async { final String path = '/teams/{teamId}'.replaceAll('{teamId}', teamId); @@ -80,12 +77,11 @@ class Teams extends Service { return models.Team.fromMap(res.data); - } + /// Update Name /// /// Update the team's name by its unique ID. - /// Future updateName({required String teamId, required String name}) async { final String path = '/teams/{teamId}'.replaceAll('{teamId}', teamId); @@ -104,13 +100,12 @@ class Teams extends Service { return models.Team.fromMap(res.data); - } + /// Delete Team /// /// Delete a team using its ID. Only team members with the owner role can /// delete the team. - /// Future delete({required String teamId}) async { final String path = '/teams/{teamId}'.replaceAll('{teamId}', teamId); @@ -128,13 +123,12 @@ class Teams extends Service { return res.data; - } + /// List Team Memberships /// /// Use this endpoint to list a team's members using the team's ID. All team /// members have read access to this endpoint. - /// Future listMemberships({required String teamId, List? queries, String? search}) async { final String path = '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); @@ -154,8 +148,8 @@ class Teams extends Service { return models.MembershipList.fromMap(res.data); - } + /// Create Team Membership /// /// Invite a new member to join your team. Provide an ID for existing users, or @@ -179,7 +173,6 @@ class Teams extends Service { /// Appwrite will accept the only redirect URLs under the domains you have /// added as a platform on the Appwrite Console. /// - /// Future createMembership({required String teamId, required List roles, required String url, String? email, String? userId, String? phone, String? name}) async { final String path = '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId); @@ -203,13 +196,12 @@ class Teams extends Service { return models.Membership.fromMap(res.data); - } + /// Get Team Membership /// /// Get a team member by the membership unique id. All team members have read /// access for this resource. - /// Future getMembership({required String teamId, required String membershipId}) async { final String path = '/teams/{teamId}/memberships/{membershipId}'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); @@ -227,14 +219,13 @@ class Teams extends Service { return models.Membership.fromMap(res.data); - } + /// Update Membership Roles /// /// Modify the roles of a team member. Only team members with the owner role /// have access to this endpoint. Learn more about [roles and /// permissions](/docs/permissions). - /// Future updateMembershipRoles({required String teamId, required String membershipId, required List roles}) async { final String path = '/teams/{teamId}/memberships/{membershipId}'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); @@ -253,14 +244,13 @@ class Teams extends Service { return models.Membership.fromMap(res.data); - } + /// Delete Team Membership /// /// This endpoint allows a user to leave a team or for a team owner to delete /// the membership of any other team member. You can also use this endpoint to /// delete a user membership even if it is not accepted. - /// Future deleteMembership({required String teamId, required String membershipId}) async { final String path = '/teams/{teamId}/memberships/{membershipId}'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); @@ -278,8 +268,8 @@ class Teams extends Service { return res.data; - } + /// Update Team Membership Status /// /// Use this endpoint to allow a user to accept an invitation to join a team @@ -289,7 +279,6 @@ class Teams extends Service { /// If the request is successful, a session for the user is automatically /// created. /// - /// Future updateMembershipStatus({required String teamId, required String membershipId, required String userId, required String secret}) async { final String path = '/teams/{teamId}/memberships/{membershipId}/status'.replaceAll('{teamId}', teamId).replaceAll('{membershipId}', membershipId); @@ -309,14 +298,13 @@ class Teams extends Service { return models.Membership.fromMap(res.data); - } + /// Get Team Preferences /// /// Get the team's shared preferences by its unique ID. If a preference doesn't /// need to be shared by all team members, prefer storing them in [user /// preferences](/docs/client/account#accountGetPrefs). - /// Future getPrefs({required String teamId}) async { final String path = '/teams/{teamId}/prefs'.replaceAll('{teamId}', teamId); @@ -334,14 +322,13 @@ class Teams extends Service { return models.Preferences.fromMap(res.data); - } + /// Update Preferences /// /// Update the team's preferences by its unique ID. The object you pass is /// stored as is and replaces any previous value. The maximum allowed prefs /// size is 64kB and throws an error if exceeded. - /// Future updatePrefs({required String teamId, required Map prefs}) async { final String path = '/teams/{teamId}/prefs'.replaceAll('{teamId}', teamId); @@ -360,6 +347,5 @@ class Teams extends Service { return models.Preferences.fromMap(res.data); - } } \ No newline at end of file diff --git a/lib/services/users.dart b/lib/services/users.dart index 5ba721b5..8214131b 100644 --- a/lib/services/users.dart +++ b/lib/services/users.dart @@ -1,6 +1,6 @@ part of dart_appwrite; - /// The Users service allows you to manage your project users. +/// The Users service allows you to manage your project users. class Users extends Service { Users(super.client); @@ -8,7 +8,6 @@ class Users extends Service { /// /// Get a list of all the project's users. You can use the query params to /// filter your results. - /// Future list({List? queries, String? search}) async { final String path = '/users'; @@ -28,12 +27,11 @@ class Users extends Service { return models.UserList.fromMap(res.data); - } + /// Create User /// /// Create a new user. - /// Future create({required String userId, String? email, String? phone, String? password, String? name}) async { final String path = '/users'; @@ -56,15 +54,14 @@ class Users extends Service { return models.User.fromMap(res.data); - } + /// Create User with Argon2 Password /// /// Create a new user. Password provided must be hashed with the /// [Argon2](https://en.wikipedia.org/wiki/Argon2) algorithm. Use the [POST /// /users](/docs/server/users#usersCreate) endpoint to create users with a /// plain text password. - /// Future createArgon2User({required String userId, required String email, required String password, String? name}) async { final String path = '/users/argon2'; @@ -86,15 +83,14 @@ class Users extends Service { return models.User.fromMap(res.data); - } + /// Create User with Bcrypt Password /// /// Create a new user. Password provided must be hashed with the /// [Bcrypt](https://en.wikipedia.org/wiki/Bcrypt) algorithm. Use the [POST /// /users](/docs/server/users#usersCreate) endpoint to create users with a /// plain text password. - /// Future createBcryptUser({required String userId, required String email, required String password, String? name}) async { final String path = '/users/bcrypt'; @@ -116,15 +112,14 @@ class Users extends Service { return models.User.fromMap(res.data); - } + /// Create User with MD5 Password /// /// Create a new user. Password provided must be hashed with the /// [MD5](https://en.wikipedia.org/wiki/MD5) algorithm. Use the [POST /// /users](/docs/server/users#usersCreate) endpoint to create users with a /// plain text password. - /// Future createMD5User({required String userId, required String email, required String password, String? name}) async { final String path = '/users/md5'; @@ -146,15 +141,14 @@ class Users extends Service { return models.User.fromMap(res.data); - } + /// Create User with PHPass Password /// /// Create a new user. Password provided must be hashed with the /// [PHPass](https://www.openwall.com/phpass/) algorithm. Use the [POST /// /users](/docs/server/users#usersCreate) endpoint to create users with a /// plain text password. - /// Future createPHPassUser({required String userId, required String email, required String password, String? name}) async { final String path = '/users/phpass'; @@ -176,15 +170,14 @@ class Users extends Service { return models.User.fromMap(res.data); - } + /// Create User with Scrypt Password /// /// Create a new user. Password provided must be hashed with the /// [Scrypt](https://github.com/Tarsnap/scrypt) algorithm. Use the [POST /// /users](/docs/server/users#usersCreate) endpoint to create users with a /// plain text password. - /// Future createScryptUser({required String userId, required String email, required String password, required String passwordSalt, required int passwordCpu, required int passwordMemory, required int passwordParallel, required int passwordLength, String? name}) async { final String path = '/users/scrypt'; @@ -211,15 +204,14 @@ class Users extends Service { return models.User.fromMap(res.data); - } + /// Create User with Scrypt Modified Password /// /// Create a new user. Password provided must be hashed with the [Scrypt /// Modified](https://gist.github.com/Meldiron/eecf84a0225eccb5a378d45bb27462cc) /// algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint /// to create users with a plain text password. - /// Future createScryptModifiedUser({required String userId, required String email, required String password, required String passwordSalt, required String passwordSaltSeparator, required String passwordSignerKey, String? name}) async { final String path = '/users/scrypt-modified'; @@ -244,15 +236,14 @@ class Users extends Service { return models.User.fromMap(res.data); - } + /// Create User with SHA Password /// /// Create a new user. Password provided must be hashed with the /// [SHA](https://en.wikipedia.org/wiki/Secure_Hash_Algorithm) algorithm. Use /// the [POST /users](/docs/server/users#usersCreate) endpoint to create users /// with a plain text password. - /// Future createSHAUser({required String userId, required String email, required String password, String? passwordVersion, String? name}) async { final String path = '/users/sha'; @@ -275,12 +266,11 @@ class Users extends Service { return models.User.fromMap(res.data); - } + /// Get User /// /// Get a user by its unique ID. - /// Future get({required String userId}) async { final String path = '/users/{userId}'.replaceAll('{userId}', userId); @@ -298,8 +288,8 @@ class Users extends Service { return models.User.fromMap(res.data); - } + /// Delete User /// /// Delete a user by its unique ID, thereby releasing it's ID. Since ID is @@ -307,7 +297,6 @@ class Users extends Service { /// storage files should be deleted before user deletion. If you want to keep /// ID reserved, use the [updateStatus](/docs/server/users#usersUpdateStatus) /// endpoint instead. - /// Future delete({required String userId}) async { final String path = '/users/{userId}'.replaceAll('{userId}', userId); @@ -325,12 +314,11 @@ class Users extends Service { return res.data; - } + /// Update Email /// /// Update the user email by its unique ID. - /// Future updateEmail({required String userId, required String email}) async { final String path = '/users/{userId}/email'.replaceAll('{userId}', userId); @@ -349,12 +337,11 @@ class Users extends Service { return models.User.fromMap(res.data); - } + /// List User Logs /// /// Get the user activity logs list by its unique ID. - /// Future listLogs({required String userId, List? queries}) async { final String path = '/users/{userId}/logs'.replaceAll('{userId}', userId); @@ -373,12 +360,11 @@ class Users extends Service { return models.LogList.fromMap(res.data); - } + /// List User Memberships /// /// Get the user membership list by its unique ID. - /// Future listMemberships({required String userId}) async { final String path = '/users/{userId}/memberships'.replaceAll('{userId}', userId); @@ -396,12 +382,11 @@ class Users extends Service { return models.MembershipList.fromMap(res.data); - } + /// Update Name /// /// Update the user name by its unique ID. - /// Future updateName({required String userId, required String name}) async { final String path = '/users/{userId}/name'.replaceAll('{userId}', userId); @@ -420,12 +405,11 @@ class Users extends Service { return models.User.fromMap(res.data); - } + /// Update Password /// /// Update the user password by its unique ID. - /// Future updatePassword({required String userId, required String password}) async { final String path = '/users/{userId}/password'.replaceAll('{userId}', userId); @@ -444,12 +428,11 @@ class Users extends Service { return models.User.fromMap(res.data); - } + /// Update Phone /// /// Update the user phone by its unique ID. - /// Future updatePhone({required String userId, required String number}) async { final String path = '/users/{userId}/phone'.replaceAll('{userId}', userId); @@ -468,12 +451,11 @@ class Users extends Service { return models.User.fromMap(res.data); - } + /// Get User Preferences /// /// Get the user preferences by its unique ID. - /// Future getPrefs({required String userId}) async { final String path = '/users/{userId}/prefs'.replaceAll('{userId}', userId); @@ -491,14 +473,13 @@ class Users extends Service { return models.Preferences.fromMap(res.data); - } + /// Update User Preferences /// /// Update the user preferences by its unique ID. The object you pass is stored /// as is, and replaces any previous value. The maximum allowed prefs size is /// 64kB and throws error if exceeded. - /// Future updatePrefs({required String userId, required Map prefs}) async { final String path = '/users/{userId}/prefs'.replaceAll('{userId}', userId); @@ -517,12 +498,11 @@ class Users extends Service { return models.Preferences.fromMap(res.data); - } + /// List User Sessions /// /// Get the user sessions list by its unique ID. - /// Future listSessions({required String userId}) async { final String path = '/users/{userId}/sessions'.replaceAll('{userId}', userId); @@ -540,12 +520,11 @@ class Users extends Service { return models.SessionList.fromMap(res.data); - } + /// Delete User Sessions /// /// Delete all user's sessions by using the user's unique ID. - /// Future deleteSessions({required String userId}) async { final String path = '/users/{userId}/sessions'.replaceAll('{userId}', userId); @@ -563,12 +542,11 @@ class Users extends Service { return res.data; - } + /// Delete User Session /// /// Delete a user sessions by its unique ID. - /// Future deleteSession({required String userId, required String sessionId}) async { final String path = '/users/{userId}/sessions/{sessionId}'.replaceAll('{userId}', userId).replaceAll('{sessionId}', sessionId); @@ -586,13 +564,12 @@ class Users extends Service { return res.data; - } + /// Update User Status /// /// Update the user status by its unique ID. Use this endpoint as an /// alternative to deleting a user if you want to keep user's ID reserved. - /// Future updateStatus({required String userId, required bool status}) async { final String path = '/users/{userId}/status'.replaceAll('{userId}', userId); @@ -611,12 +588,11 @@ class Users extends Service { return models.User.fromMap(res.data); - } + /// Update Email Verification /// /// Update the user email verification status by its unique ID. - /// Future updateEmailVerification({required String userId, required bool emailVerification}) async { final String path = '/users/{userId}/verification'.replaceAll('{userId}', userId); @@ -635,12 +611,11 @@ class Users extends Service { return models.User.fromMap(res.data); - } + /// Update Phone Verification /// /// Update the user phone verification status by its unique ID. - /// Future updatePhoneVerification({required String userId, required bool phoneVerification}) async { final String path = '/users/{userId}/verification/phone'.replaceAll('{userId}', userId); @@ -659,6 +634,5 @@ class Users extends Service { return models.User.fromMap(res.data); - } } \ No newline at end of file diff --git a/lib/src/client.dart b/lib/src/client.dart index 173062d2..474654d5 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -5,32 +5,56 @@ import 'client_stub.dart' import 'response.dart'; import 'upload_progress.dart'; +/// [Client] that handles requests to Appwrite abstract class Client { + /// The size for cunked uploads in bytes. static const int CHUNK_SIZE = 5*1024*1024; + + /// Holds configuration such as project. late Map config; late String _endPoint; + /// Appwrite endpoint. String get endPoint => _endPoint; + /// Initializes a [Client]. factory Client( {String endPoint = 'https://HOSTNAME/v1', bool selfSigned = false}) => createClient(endPoint: endPoint, selfSigned: selfSigned); + /// Set self signed to [status]. + /// + /// If self signed is true, [Client] will ignore invalid certificates. + /// This is helpful in environments where your Appwrite + /// instance does not have a valid SSL certificate. Client setSelfSigned({bool status = true}); + /// Set the Appwrite endpoint. Client setEndpoint(String endPoint); + /// Set Project + /// /// Your project ID Client setProject(value); + + /// Set Key + /// /// Your secret API key Client setKey(value); + + /// Set JWT + /// /// Your secret JSON Web Token Client setJWT(value); + + /// Set Locale Client setLocale(value); + /// Add headers that should be sent with all API calls. Client addHeader(String key, String value); + /// Upload a file in chunks. Future chunkedUpload({ required String path, required Map params, @@ -40,6 +64,7 @@ abstract class Client { Function(UploadProgress)? onProgress, }); + /// Send the API request. Future call(HttpMethod method, { String path = '', Map headers = const {}, diff --git a/lib/src/client_browser.dart b/lib/src/client_browser.dart index 6c3a9569..7b6f3f74 100644 --- a/lib/src/client_browser.dart +++ b/lib/src/client_browser.dart @@ -33,7 +33,7 @@ class ClientBrowser extends ClientBase with ClientMixin { 'x-sdk-name': 'Dart', 'x-sdk-platform': 'server', 'x-sdk-language': 'dart', - 'x-sdk-version': '8.0.0', + 'x-sdk-version': '8.0.1', 'X-Appwrite-Response-Format' : '1.0.0', }; diff --git a/lib/src/client_io.dart b/lib/src/client_io.dart index e8babbb1..7b2c32b8 100644 --- a/lib/src/client_io.dart +++ b/lib/src/client_io.dart @@ -42,7 +42,8 @@ class ClientIO extends ClientBase with ClientMixin { 'x-sdk-name': 'Dart', 'x-sdk-platform': 'server', 'x-sdk-language': 'dart', - 'x-sdk-version': '8.0.0', + 'x-sdk-version': '8.0.1', + 'user-agent' : 'AppwriteDartSDK/8.0.1 (${Platform.operatingSystem}; ${Platform.operatingSystemVersion})', 'X-Appwrite-Response-Format' : '1.0.0', }; diff --git a/lib/src/enums.dart b/lib/src/enums.dart index 9f84bd93..6566f2e1 100644 --- a/lib/src/enums.dart +++ b/lib/src/enums.dart @@ -1,6 +1,8 @@ +/// HTTP methods. enum HttpMethod { get, post, put, delete, patch } extension HttpMethodString on HttpMethod { + /// Returns the HTTP method in all caps. String name() { return toString().split('.').last.toUpperCase(); } diff --git a/lib/src/exception.dart b/lib/src/exception.dart index a5c6a9f2..f579bfb8 100644 --- a/lib/src/exception.dart +++ b/lib/src/exception.dart @@ -1,14 +1,23 @@ +/// Exception thrown by the dart_appwrite package. class AppwriteException implements Exception { + /// Error message. final String? message; + + /// Error type. + /// + /// See [Error Types](https://appwrite.io/docs/response-codes#errorTypes) + /// for more information. final String? type; final int? code; final dynamic response; + /// Initializes an Appwrite Exception. AppwriteException([this.message = "", this.code, this.type, this.response]); + /// Returns the error type, message, and code. @override String toString() { - if (message == null) return "AppwriteException"; - return "AppwriteException: $type, $message (${code ?? 0})"; + if (message == null || message == "") return "AppwriteException"; + return "AppwriteException: ${type ?? ''}, $message (${code ?? 0})"; } } diff --git a/lib/src/input_file.dart b/lib/src/input_file.dart index 13c6e752..c0be7c04 100644 --- a/lib/src/input_file.dart +++ b/lib/src/input_file.dart @@ -1,5 +1,6 @@ import 'exception.dart'; +/// Helper class to handle files. class InputFile { late final String? path; late final List? bytes; @@ -9,13 +10,13 @@ class InputFile { @Deprecated('Use `InputFile.fromPath` or `InputFile.fromBytes` instead.') InputFile({this.path, this.filename, this.contentType, this.bytes}) { if (path == null && bytes == null) { - throw AppwriteException('One of `path` or `bytes` is required'); + throw AppwriteException('One of `path` or `bytes` is required'); } } InputFile._({this.path, this.filename, this.contentType, this.bytes}) { if (path == null && bytes == null) { - throw AppwriteException('One of `path` or `bytes` is required'); + throw AppwriteException('One of `path` or `bytes` is required'); } } diff --git a/lib/src/response.dart b/lib/src/response.dart index bf4eea3f..ff7d14b2 100644 --- a/lib/src/response.dart +++ b/lib/src/response.dart @@ -1,8 +1,11 @@ import 'dart:convert'; +/// Appwrite Response class Response { + /// Initializes a [Response] Response({this.data}); + /// HTTP body returned from Appwrite T? data; @override diff --git a/lib/src/upload_progress.dart b/lib/src/upload_progress.dart index 4ed965d2..44cde383 100644 --- a/lib/src/upload_progress.dart +++ b/lib/src/upload_progress.dart @@ -1,11 +1,23 @@ import 'dart:convert'; +/// Progress of a File Upload class UploadProgress { + /// ID of the file. final String $id; + + /// Progress percentage. final double progress; + + /// Size uploaded in bytes. final int sizeUploaded; + + /// Total number of chunks. final int chunksTotal; + + /// Number of chunks uploaded. final int chunksUploaded; + + /// Initializes an [UploadProgress] UploadProgress({ required this.$id, required this.progress, @@ -14,6 +26,7 @@ class UploadProgress { required this.chunksUploaded, }); + /// Initializes an [UploadProgress] from a [Map] factory UploadProgress.fromMap(Map map) { return UploadProgress( $id: map['\$id'] ?? '', @@ -24,6 +37,7 @@ class UploadProgress { ); } + /// Converts an [UploadProgress] to a [Map] Map toMap() { return { "\$id": $id, @@ -34,11 +48,14 @@ class UploadProgress { }; } + /// Converts an [UploadProgress] to a JSON [String] String toJson() => json.encode(toMap()); + /// Initializes an [UploadProgress] from a JSON [String] factory UploadProgress.fromJson(String source) => UploadProgress.fromMap(json.decode(source)); + /// Returns a string representation of an [UploadProgress] @override String toString() { return 'UploadProgress(\$id: ${$id}, progress: $progress, sizeUploaded: $sizeUploaded, chunksTotal: $chunksTotal, chunksUploaded: $chunksUploaded)'; diff --git a/pubspec.yaml b/pubspec.yaml index b515fe7d..28d4c440 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: dart_appwrite -version: 8.0.0 +version: 8.0.1 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 @@ -8,8 +8,9 @@ documentation: https://appwrite.io/support environment: sdk: '>=2.17.0 <3.0.0' dependencies: - http: ^0.13.5 + http: '>=0.13.6 <1.0.1' dev_dependencies: lints: ^2.0.1 test: ^1.22.0 + mockito: ^5.4.2 diff --git a/test/id_test.dart b/test/id_test.dart new file mode 100644 index 00000000..9327beda --- /dev/null +++ b/test/id_test.dart @@ -0,0 +1,16 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:test/test.dart'; + +void main() { + group('unique()', () { + test('returns unique()', () { + expect(ID.unique(), 'unique()'); + }); + }); + + group('custom()', () { + test('returns the custom string', () { + expect(ID.custom('custom'), 'custom'); + }); + }); +} diff --git a/test/permission_test.dart b/test/permission_test.dart new file mode 100644 index 00000000..0ebbd18c --- /dev/null +++ b/test/permission_test.dart @@ -0,0 +1,34 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:test/test.dart'; + +void main() { + group('read()', () { + test('returns read', () { + expect(Permission.read(Role.any()), 'read("any")'); + }); + }); + + group('write()', () { + test('returns write', () { + expect(Permission.write(Role.any()), 'write("any")'); + }); + }); + + group('create()', () { + test('returns create', () { + expect(Permission.create(Role.any()), 'create("any")'); + }); + }); + + group('update()', () { + test('returns update', () { + expect(Permission.update(Role.any()), 'update("any")'); + }); + }); + + group('delete()', () { + test('returns delete', () { + expect(Permission.delete(Role.any()), 'delete("any")'); + }); + }); +} diff --git a/test/query_test.dart b/test/query_test.dart new file mode 100644 index 00000000..1939b4ff --- /dev/null +++ b/test/query_test.dart @@ -0,0 +1,192 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:test/test.dart'; + +class BasicFilterQueryTest { + final String description; + final dynamic value; + final String expectedValues; + + BasicFilterQueryTest({ + required this.description, + required this.value, + required this.expectedValues, + }); +} + +void main() { + group('basic filter tests', () { + final tests = [ + BasicFilterQueryTest( + description: 'with a string', + value: 's', + expectedValues: '["s"]', + ), + BasicFilterQueryTest( + description: 'with an integer', + value: 1, + expectedValues: '[1]', + ), + BasicFilterQueryTest( + description: 'with a double', + value: 1.2, + expectedValues: '[1.2]', + ), + BasicFilterQueryTest( + description: 'with a whole number double', + value: 1.0, + expectedValues: '[1.0]', + ), + BasicFilterQueryTest( + description: 'with a bool', + value: false, + expectedValues: '[false]', + ), + BasicFilterQueryTest( + description: 'with a list', + value: ['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})', + ); + }); + } + }); + + group('notEqual()', () { + for (var t in tests) { + test(t.description, () { + expect( + Query.notEqual('attr', t.value), + 'notEqual("attr", ${t.expectedValues})', + ); + }); + } + }); + + group('lessThan()', () { + for (var t in tests) { + test(t.description, () { + expect( + Query.lessThan('attr', t.value), + 'lessThan("attr", ${t.expectedValues})', + ); + }); + } + }); + + group('lessThanEqual()', () { + for (var t in tests) { + test(t.description, () { + expect( + Query.lessThanEqual('attr', t.value), + 'lessThanEqual("attr", ${t.expectedValues})', + ); + }); + } + }); + + group('greaterThan()', () { + for (var t in tests) { + test(t.description, () { + expect( + Query.greaterThan('attr', t.value), + 'greaterThan("attr", ${t.expectedValues})', + ); + }); + } + }); + + group('greaterThanEqual()', () { + for (var t in tests) { + test(t.description, () { + expect( + Query.greaterThanEqual('attr', t.value), + 'greaterThanEqual("attr", ${t.expectedValues})', + ); + }); + } + }); + }); + + group('search()', () { + test('returns search', () { + expect(Query.search('attr', 'keyword1 keyword2'), 'search("attr", ["keyword1 keyword2"])'); + }); + }); + + group('isNull()', () { + test('returns isNull', () { + expect(Query.isNull('attr'), 'isNull("attr")'); + }); + }); + + group('isNotNull()', () { + test('returns isNotNull', () { + expect(Query.isNotNull('attr'), 'isNotNull("attr")'); + }); + }); + + group('between()', () { + test('with integers', () { + expect(Query.between('attr', 1, 2), 'between("attr", [1,2])'); + }); + + test('with doubles', () { + expect(Query.between('attr', 1.0, 2.0), 'between("attr", [1.0,2.0])'); + }); + + test('with strings', () { + expect(Query.between('attr', "a", "z"), 'between("attr", ["a","z"])'); + }); + }); + + group('select()', () { + test('returns select', () { + expect(Query.select(['attr1', 'attr2']), 'select(["attr1","attr2"])'); + }); + }); + + group('orderAsc()', () { + test('returns orderAsc', () { + expect(Query.orderAsc('attr'), 'orderAsc("attr")'); + }); + }); + + group('orderDesc()', () { + test('returns orderDesc', () { + expect(Query.orderDesc('attr'), 'orderDesc("attr")'); + }); + }); + + group('cursorBefore()', () { + test('returns cursorBefore', () { + expect(Query.cursorBefore(ID.custom('custom')), 'cursorBefore("custom")'); + }); + }); + + group('cursorAfter()', () { + test('returns cursorAfter', () { + expect(Query.cursorAfter(ID.custom('custom')), 'cursorAfter("custom")'); + }); + }); + + group('limit()', () { + test('returns limit', () { + expect(Query.limit(1), 'limit(1)'); + }); + }); + + group('offset()', () { + test('returns offset', () { + expect(Query.offset(1), 'offset(1)'); + }); + }); +} + diff --git a/test/role_test.dart b/test/role_test.dart new file mode 100644 index 00000000..14507c74 --- /dev/null +++ b/test/role_test.dart @@ -0,0 +1,52 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:test/test.dart'; + +void main() { + group('any()', () { + test('returns any', () { + expect(Role.any(), 'any'); + }); + }); + + group('user()', () { + test('without status', () { + expect(Role.user('custom'), 'user:custom'); + }); + + test('with status', () { + expect(Role.user('custom', 'verified'), 'user:custom/verified'); + }); + }); + + group('users()', () { + test('without status', () { + expect(Role.users(), 'users'); + }); + + test('with status', () { + expect(Role.users('verified'), 'users/verified'); + }); + }); + + group('guests()', () { + test('returns guests', () { + expect(Role.guests(), 'guests'); + }); + }); + + group('team()', () { + test('without role', () { + expect(Role.team('custom'), 'team:custom'); + }); + + test('with role', () { + expect(Role.team('custom', 'owner'), 'team:custom/owner'); + }); + }); + + group('member()', () { + test('returns member', () { + expect(Role.member('custom'), 'member:custom'); + }); + }); +} diff --git a/test/services/account_test.dart b/test/services/account_test.dart new file mode 100644 index 00000000..316cbb34 --- /dev/null +++ b/test/services/account_test.dart @@ -0,0 +1,541 @@ +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 config = {'project': 'testproject'}; + String endPoint = 'https://localhost/v1'; + @override + Future call( + HttpMethod? method, { + String path = '', + Map headers = const {}, + Map 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 chunkedUpload({ + String? path, + Map? params, + String? paramName, + String? idParamName, + Map? headers, + Function(UploadProgress)? onProgress, + }) async { + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + } +} + +void main() { + group('Account test', () { + late MockClient client; + late Account account; + + setUp(() { + client = MockClient(); + account = Account(client); + }); + + test('test method get()', () async { + final Map 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, + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'prefs': {},}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.get( + ); + expect(response, isA()); + + }); + + test('test method updateEmail()', () async { + final Map 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, + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'prefs': {},}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateEmail( + email: 'email@example.com', + password: 'password', + ); + expect(response, isA()); + + }); + + test('test method listLogs()', () async { + final Map data = { + 'total': 5, + 'logs': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.listLogs( + ); + expect(response, isA()); + + }); + + test('test method updateName()', () async { + final Map 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, + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'prefs': {},}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateName( + name: '[NAME]', + ); + expect(response, isA()); + + }); + + test('test method updatePassword()', () async { + final Map 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, + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'prefs': {},}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updatePassword( + password: '', + ); + expect(response, isA()); + + }); + + test('test method updatePhone()', () async { + final Map 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, + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'prefs': {},}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updatePhone( + phone: '+12065550100', + password: 'password', + ); + expect(response, isA()); + + }); + + test('test method getPrefs()', () async { + final Map data = {}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.getPrefs( + ); + expect(response, isA()); + + }); + + test('test method updatePrefs()', () async { + final Map 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, + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'prefs': {},}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updatePrefs( + prefs: {}, + ); + expect(response, isA()); + + }); + + test('test method createRecovery()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createRecovery( + email: 'email@example.com', + url: 'https://example.com', + ); + expect(response, isA()); + + }); + + test('test method updateRecovery()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateRecovery( + userId: '[USER_ID]', + secret: '[SECRET]', + password: 'password', + passwordAgain: 'password', + ); + expect(response, isA()); + + }); + + test('test method listSessions()', () async { + final Map data = { + 'total': 5, + 'sessions': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.listSessions( + ); + expect(response, isA()); + + }); + + test('test method deleteSessions()', () async { + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.deleteSessions( + ); + }); + + test('test method getSession()', () async { + final Map 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,}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.getSession( + sessionId: '[SESSION_ID]', + ); + expect(response, isA()); + + }); + + test('test method updateSession()', () async { + final Map 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,}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateSession( + sessionId: '[SESSION_ID]', + ); + expect(response, isA()); + + }); + + test('test method deleteSession()', () async { + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.deleteSession( + sessionId: '[SESSION_ID]', + ); + }); + + test('test method updateStatus()', () async { + final Map 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, + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'prefs': {},}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateStatus( + ); + expect(response, isA()); + + }); + + test('test method createVerification()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createVerification( + url: 'https://example.com', + ); + expect(response, isA()); + + }); + + test('test method updateVerification()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updateVerification( + userId: '[USER_ID]', + secret: '[SECRET]', + ); + expect(response, isA()); + + }); + + test('test method createPhoneVerification()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.createPhoneVerification( + ); + expect(response, isA()); + + }); + + test('test method updatePhoneVerification()', () async { + final Map data = { + '\$id': 'bb8ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c168bb8', + 'secret': '', + 'expire': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await account.updatePhoneVerification( + userId: '[USER_ID]', + secret: '[SECRET]', + ); + expect(response, isA()); + + }); + + }); +} \ No newline at end of file diff --git a/test/services/avatars_test.dart b/test/services/avatars_test.dart new file mode 100644 index 00000000..db6ea9cd --- /dev/null +++ b/test/services/avatars_test.dart @@ -0,0 +1,155 @@ +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 config = {'project': 'testproject'}; + String endPoint = 'https://localhost/v1'; + @override + Future call( + HttpMethod? method, { + String path = '', + Map headers = const {}, + Map 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 chunkedUpload({ + String? path, + Map? params, + String? paramName, + String? idParamName, + Map? headers, + Function(UploadProgress)? onProgress, + }) async { + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + } +} + +void main() { + group('Avatars test', () { + late MockClient client; + late Avatars avatars; + + setUp(() { + client = MockClient(); + avatars = Avatars(client); + }); + + test('test method getBrowser()', () async {final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await avatars.getBrowser( + code: 'aa', + ); + expect(response, isA()); + + }); + + test('test method getCreditCard()', () async {final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await avatars.getCreditCard( + code: 'amex', + ); + expect(response, isA()); + + }); + + test('test method getFavicon()', () async {final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await avatars.getFavicon( + url: 'https://example.com', + ); + expect(response, isA()); + + }); + + test('test method getFlag()', () async {final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await avatars.getFlag( + code: 'af', + ); + expect(response, isA()); + + }); + + test('test method getImage()', () async {final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await avatars.getImage( + url: 'https://example.com', + ); + expect(response, isA()); + + }); + + test('test method getInitials()', () async {final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await avatars.getInitials( + ); + expect(response, isA()); + + }); + + test('test method getQR()', () async {final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await avatars.getQR( + text: '[TEXT]', + ); + expect(response, isA()); + + }); + + }); +} \ No newline at end of file diff --git a/test/services/databases_test.dart b/test/services/databases_test.dart new file mode 100644 index 00000000..c2c4a319 --- /dev/null +++ b/test/services/databases_test.dart @@ -0,0 +1,1002 @@ +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 config = {'project': 'testproject'}; + String endPoint = 'https://localhost/v1'; + @override + Future call( + HttpMethod? method, { + String path = '', + Map headers = const {}, + Map 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 chunkedUpload({ + String? path, + Map? params, + String? paramName, + String? idParamName, + Map? headers, + Function(UploadProgress)? onProgress, + }) async { + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + } +} + +void main() { + group('Databases test', () { + late MockClient client; + late Databases databases; + + setUp(() { + client = MockClient(); + databases = Databases(client); + }); + + test('test method list()', () async { + final Map data = { + 'total': 5, + 'databases': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.list( + ); + expect(response, isA()); + + }); + + test('test method create()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + 'name': 'My Database', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.create( + databaseId: '[DATABASE_ID]', + name: '[NAME]', + ); + expect(response, isA()); + + }); + + test('test method get()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + 'name': 'My Database', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.get( + databaseId: '[DATABASE_ID]', + ); + expect(response, isA()); + + }); + + test('test method update()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + 'name': 'My Database', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.update( + databaseId: '[DATABASE_ID]', + name: '[NAME]', + ); + expect(response, isA()); + + }); + + test('test method delete()', () async { + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.delete( + databaseId: '[DATABASE_ID]', + ); + }); + + test('test method listCollections()', () async { + final Map data = { + 'total': 5, + 'collections': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.listCollections( + databaseId: '[DATABASE_ID]', + ); + expect(response, isA()); + + }); + + test('test method createCollection()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'databaseId': '5e5ea5c16897e', + 'name': 'My Collection', + 'enabled': true, + 'documentSecurity': true, + 'attributes': [], + 'indexes': [],}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.createCollection( + databaseId: '[DATABASE_ID]', + collectionId: '[COLLECTION_ID]', + name: '[NAME]', + ); + expect(response, isA()); + + }); + + test('test method getCollection()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'databaseId': '5e5ea5c16897e', + 'name': 'My Collection', + 'enabled': true, + 'documentSecurity': true, + 'attributes': [], + 'indexes': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.getCollection( + databaseId: '[DATABASE_ID]', + collectionId: '[COLLECTION_ID]', + ); + expect(response, isA()); + + }); + + test('test method updateCollection()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'databaseId': '5e5ea5c16897e', + 'name': 'My Collection', + 'enabled': true, + 'documentSecurity': true, + 'attributes': [], + 'indexes': [],}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.updateCollection( + databaseId: '[DATABASE_ID]', + collectionId: '[COLLECTION_ID]', + name: '[NAME]', + ); + expect(response, isA()); + + }); + + test('test method deleteCollection()', () async { + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.deleteCollection( + databaseId: '[DATABASE_ID]', + collectionId: '[COLLECTION_ID]', + ); + }); + + test('test method listAttributes()', () async { + final Map data = { + 'total': 5, + 'attributes': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.listAttributes( + databaseId: '[DATABASE_ID]', + collectionId: '[COLLECTION_ID]', + ); + expect(response, isA()); + + }); + + test('test method createBooleanAttribute()', () async { + final Map data = { + 'key': 'isEnabled', + 'type': 'boolean', + 'status': 'available', + 'required': true,}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.createBooleanAttribute( + databaseId: '[DATABASE_ID]', + collectionId: '[COLLECTION_ID]', + key: '', + xrequired: true, + ); + expect(response, isA()); + + }); + + test('test method updateBooleanAttribute()', () async { + final Map data = { + 'key': 'isEnabled', + 'type': 'boolean', + 'status': 'available', + 'required': true,}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.updateBooleanAttribute( + databaseId: '[DATABASE_ID]', + collectionId: '[COLLECTION_ID]', + key: '', + xrequired: true, + xdefault: true, + ); + expect(response, isA()); + + }); + + test('test method createDatetimeAttribute()', () async { + final Map data = { + 'key': 'birthDay', + 'type': 'datetime', + 'status': 'available', + 'required': true, + 'format': 'datetime',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.createDatetimeAttribute( + databaseId: '[DATABASE_ID]', + collectionId: '[COLLECTION_ID]', + key: '', + xrequired: true, + ); + expect(response, isA()); + + }); + + test('test method updateDatetimeAttribute()', () async { + final Map data = { + 'key': 'birthDay', + 'type': 'datetime', + 'status': 'available', + 'required': true, + 'format': 'datetime',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.updateDatetimeAttribute( + databaseId: '[DATABASE_ID]', + collectionId: '[COLLECTION_ID]', + key: '', + xrequired: true, + xdefault: '', + ); + expect(response, isA()); + + }); + + test('test method createEmailAttribute()', () async { + final Map data = { + 'key': 'userEmail', + 'type': 'string', + 'status': 'available', + 'required': true, + 'format': 'email',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.createEmailAttribute( + databaseId: '[DATABASE_ID]', + collectionId: '[COLLECTION_ID]', + key: '', + xrequired: true, + ); + expect(response, isA()); + + }); + + test('test method updateEmailAttribute()', () async { + final Map data = { + 'key': 'userEmail', + 'type': 'string', + 'status': 'available', + 'required': true, + 'format': 'email',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.updateEmailAttribute( + databaseId: '[DATABASE_ID]', + collectionId: '[COLLECTION_ID]', + key: '', + xrequired: true, + xdefault: 'email@example.com', + ); + expect(response, isA()); + + }); + + test('test method createEnumAttribute()', () async { + final Map data = { + 'key': 'status', + 'type': 'string', + 'status': 'available', + 'required': true, + 'elements': [], + 'format': 'enum',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.createEnumAttribute( + databaseId: '[DATABASE_ID]', + collectionId: '[COLLECTION_ID]', + key: '', + elements: [], + xrequired: true, + ); + expect(response, isA()); + + }); + + test('test method updateEnumAttribute()', () async { + final Map data = { + 'key': 'status', + 'type': 'string', + 'status': 'available', + 'required': true, + 'elements': [], + 'format': 'enum',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.updateEnumAttribute( + databaseId: '[DATABASE_ID]', + collectionId: '[COLLECTION_ID]', + key: '', + elements: [], + xrequired: true, + xdefault: '[DEFAULT]', + ); + expect(response, isA()); + + }); + + test('test method createFloatAttribute()', () async { + final Map data = { + 'key': 'percentageCompleted', + 'type': 'double', + 'status': 'available', + 'required': true,}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.createFloatAttribute( + databaseId: '[DATABASE_ID]', + collectionId: '[COLLECTION_ID]', + key: '', + xrequired: true, + ); + expect(response, isA()); + + }); + + test('test method updateFloatAttribute()', () async { + final Map data = { + 'key': 'percentageCompleted', + 'type': 'double', + 'status': 'available', + 'required': true,}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.updateFloatAttribute( + databaseId: '[DATABASE_ID]', + collectionId: '[COLLECTION_ID]', + key: '', + xrequired: true, + min: 1.0, + max: 1.0, + xdefault: 1.0, + ); + expect(response, isA()); + + }); + + test('test method createIntegerAttribute()', () async { + final Map data = { + 'key': 'count', + 'type': 'integer', + 'status': 'available', + 'required': true,}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.createIntegerAttribute( + databaseId: '[DATABASE_ID]', + collectionId: '[COLLECTION_ID]', + key: '', + xrequired: true, + ); + expect(response, isA()); + + }); + + test('test method updateIntegerAttribute()', () async { + final Map data = { + 'key': 'count', + 'type': 'integer', + 'status': 'available', + 'required': true,}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.updateIntegerAttribute( + databaseId: '[DATABASE_ID]', + collectionId: '[COLLECTION_ID]', + key: '', + xrequired: true, + min: 1, + max: 1, + xdefault: 1, + ); + expect(response, isA()); + + }); + + test('test method createIpAttribute()', () async { + final Map data = { + 'key': 'ipAddress', + 'type': 'string', + 'status': 'available', + 'required': true, + 'format': 'ip',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.createIpAttribute( + databaseId: '[DATABASE_ID]', + collectionId: '[COLLECTION_ID]', + key: '', + xrequired: true, + ); + expect(response, isA()); + + }); + + test('test method updateIpAttribute()', () async { + final Map data = { + 'key': 'ipAddress', + 'type': 'string', + 'status': 'available', + 'required': true, + 'format': 'ip',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.updateIpAttribute( + databaseId: '[DATABASE_ID]', + collectionId: '[COLLECTION_ID]', + key: '', + xrequired: true, + xdefault: '', + ); + expect(response, isA()); + + }); + + test('test method createRelationshipAttribute()', () async { + final Map data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'required': true, + 'relatedCollection': 'collection', + 'relationType': 'oneToOne|oneToMany|manyToOne|manyToMany', + 'twoWay': true, + 'twoWayKey': 'string', + 'onDelete': 'restrict|cascade|setNull', + 'side': 'parent|child',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.createRelationshipAttribute( + databaseId: '[DATABASE_ID]', + collectionId: '[COLLECTION_ID]', + relatedCollectionId: '[RELATED_COLLECTION_ID]', + type: 'oneToOne', + ); + expect(response, isA()); + + }); + + test('test method createStringAttribute()', () async { + final Map data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'required': true, + 'size': 128,}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.createStringAttribute( + databaseId: '[DATABASE_ID]', + collectionId: '[COLLECTION_ID]', + key: '', + size: 1, + xrequired: true, + ); + expect(response, isA()); + + }); + + test('test method updateStringAttribute()', () async { + final Map data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'required': true, + 'size': 128,}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.updateStringAttribute( + databaseId: '[DATABASE_ID]', + collectionId: '[COLLECTION_ID]', + key: '', + xrequired: true, + xdefault: '[DEFAULT]', + ); + expect(response, isA()); + + }); + + test('test method createUrlAttribute()', () async { + final Map data = { + 'key': 'githubUrl', + 'type': 'string', + 'status': 'available', + 'required': true, + 'format': 'url',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.createUrlAttribute( + databaseId: '[DATABASE_ID]', + collectionId: '[COLLECTION_ID]', + key: '', + xrequired: true, + ); + expect(response, isA()); + + }); + + test('test method updateUrlAttribute()', () async { + final Map data = { + 'key': 'githubUrl', + 'type': 'string', + 'status': 'available', + 'required': true, + 'format': 'url',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.updateUrlAttribute( + databaseId: '[DATABASE_ID]', + collectionId: '[COLLECTION_ID]', + key: '', + xrequired: true, + xdefault: 'https://example.com', + ); + expect(response, isA()); + + }); + + test('test method getAttribute()', () async { + final data = ''; + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.getAttribute( + databaseId: '[DATABASE_ID]', + collectionId: '[COLLECTION_ID]', + key: '', + ); + }); + + test('test method deleteAttribute()', () async { + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.deleteAttribute( + databaseId: '[DATABASE_ID]', + collectionId: '[COLLECTION_ID]', + key: '', + ); + }); + + test('test method updateRelationshipAttribute()', () async { + final Map data = { + 'key': 'fullName', + 'type': 'string', + 'status': 'available', + 'required': true, + 'relatedCollection': 'collection', + 'relationType': 'oneToOne|oneToMany|manyToOne|manyToMany', + 'twoWay': true, + 'twoWayKey': 'string', + 'onDelete': 'restrict|cascade|setNull', + 'side': 'parent|child',}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.updateRelationshipAttribute( + databaseId: '[DATABASE_ID]', + collectionId: '[COLLECTION_ID]', + key: '', + ); + expect(response, isA()); + + }); + + test('test method listDocuments()', () async { + final Map data = { + 'total': 5, + 'documents': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.listDocuments( + databaseId: '[DATABASE_ID]', + collectionId: '[COLLECTION_ID]', + ); + expect(response, isA()); + + }); + + test('test method createDocument()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.createDocument( + databaseId: '[DATABASE_ID]', + collectionId: '[COLLECTION_ID]', + documentId: '[DOCUMENT_ID]', + data: {}, + ); + expect(response, isA()); + + }); + + test('test method getDocument()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.getDocument( + databaseId: '[DATABASE_ID]', + collectionId: '[COLLECTION_ID]', + documentId: '[DOCUMENT_ID]', + ); + expect(response, isA()); + + }); + + test('test method updateDocument()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$collectionId': '5e5ea5c15117e', + '\$databaseId': '5e5ea5c15117e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.updateDocument( + databaseId: '[DATABASE_ID]', + collectionId: '[COLLECTION_ID]', + documentId: '[DOCUMENT_ID]', + ); + expect(response, isA()); + + }); + + test('test method deleteDocument()', () async { + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.deleteDocument( + databaseId: '[DATABASE_ID]', + collectionId: '[COLLECTION_ID]', + documentId: '[DOCUMENT_ID]', + ); + }); + + test('test method listIndexes()', () async { + final Map data = { + 'total': 5, + 'indexes': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.listIndexes( + databaseId: '[DATABASE_ID]', + collectionId: '[COLLECTION_ID]', + ); + expect(response, isA()); + + }); + + test('test method createIndex()', () async { + final Map data = { + 'key': 'index1', + 'type': 'primary', + 'status': 'available', + 'attributes': [],}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.createIndex( + databaseId: '[DATABASE_ID]', + collectionId: '[COLLECTION_ID]', + key: '', + type: 'key', + attributes: [], + ); + expect(response, isA()); + + }); + + test('test method getIndex()', () async { + final Map data = { + 'key': 'index1', + 'type': 'primary', + 'status': 'available', + 'attributes': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.getIndex( + databaseId: '[DATABASE_ID]', + collectionId: '[COLLECTION_ID]', + key: '', + ); + expect(response, isA()); + + }); + + test('test method deleteIndex()', () async { + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await databases.deleteIndex( + databaseId: '[DATABASE_ID]', + collectionId: '[COLLECTION_ID]', + key: '', + ); + }); + + }); +} \ No newline at end of file diff --git a/test/services/functions_test.dart b/test/services/functions_test.dart new file mode 100644 index 00000000..583bacd4 --- /dev/null +++ b/test/services/functions_test.dart @@ -0,0 +1,520 @@ +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 config = {'project': 'testproject'}; + String endPoint = 'https://localhost/v1'; + @override + Future call( + HttpMethod? method, { + String path = '', + Map headers = const {}, + Map 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 chunkedUpload({ + String? path, + Map? params, + String? paramName, + String? idParamName, + Map? headers, + Function(UploadProgress)? onProgress, + }) async { + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + } +} + +void main() { + group('Functions test', () { + late MockClient client; + late Functions functions; + + setUp(() { + client = MockClient(); + functions = Functions(client); + }); + + test('test method list()', () async { + final Map data = { + 'total': 5, + 'functions': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await functions.list( + ); + expect(response, isA()); + + }); + + test('test method create()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'execute': [], + 'name': 'My Function', + 'enabled': true, + 'runtime': 'python-3.8', + 'deployment': '5e5ea5c16897e', + 'vars': [], + 'events': [], + 'schedule': '5 4 * * *', + 'scheduleNext': '2020-10-15T06:38:00.000+00:00', + 'schedulePrevious': '2020-10-15T06:38:00.000+00:00', + 'timeout': 15,}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await functions.create( + functionId: '[FUNCTION_ID]', + name: '[NAME]', + runtime: 'node-14.5', + ); + expect(response, isA()); + + }); + + test('test method listRuntimes()', () async { + final Map data = { + 'total': 5, + 'runtimes': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await functions.listRuntimes( + ); + expect(response, isA()); + + }); + + test('test method get()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'execute': [], + 'name': 'My Function', + 'enabled': true, + 'runtime': 'python-3.8', + 'deployment': '5e5ea5c16897e', + 'vars': [], + 'events': [], + 'schedule': '5 4 * * *', + 'scheduleNext': '2020-10-15T06:38:00.000+00:00', + 'schedulePrevious': '2020-10-15T06:38:00.000+00:00', + 'timeout': 15,}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await functions.get( + functionId: '[FUNCTION_ID]', + ); + expect(response, isA()); + + }); + + test('test method update()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'execute': [], + 'name': 'My Function', + 'enabled': true, + 'runtime': 'python-3.8', + 'deployment': '5e5ea5c16897e', + 'vars': [], + 'events': [], + 'schedule': '5 4 * * *', + 'scheduleNext': '2020-10-15T06:38:00.000+00:00', + 'schedulePrevious': '2020-10-15T06:38:00.000+00:00', + 'timeout': 15,}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await functions.update( + functionId: '[FUNCTION_ID]', + name: '[NAME]', + ); + expect(response, isA()); + + }); + + test('test method delete()', () async { + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await functions.delete( + functionId: '[FUNCTION_ID]', + ); + }); + + test('test method listDeployments()', () async { + final Map data = { + 'total': 5, + 'deployments': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await functions.listDeployments( + functionId: '[FUNCTION_ID]', + ); + expect(response, isA()); + + }); + + test('test method createDeployment()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'resourceId': '5e5ea6g16897e', + 'resourceType': 'functions', + 'entrypoint': 'enabled', + 'size': 128, + 'buildId': '5e5ea5c16897e', + 'activate': true, + 'status': 'ready', + 'buildStdout': 'enabled', + 'buildStderr': 'enabled', + 'buildTime': 128,}; + + + when(client.chunkedUpload( + path: argThat(isNotNull), + params: argThat(isNotNull), + paramName: argThat(isNotNull), + idParamName: argThat(isNotNull), + headers: argThat(isNotNull), + )).thenAnswer((_) async => Response(data: data)); + + + final response = await functions.createDeployment( + functionId: '[FUNCTION_ID]', + entrypoint: '[ENTRYPOINT]', + code: InputFile.fromPath(path: './image.png'), + activate: true, + ); + expect(response, isA()); + + }); + + test('test method getDeployment()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'resourceId': '5e5ea6g16897e', + 'resourceType': 'functions', + 'entrypoint': 'enabled', + 'size': 128, + 'buildId': '5e5ea5c16897e', + 'activate': true, + 'status': 'ready', + 'buildStdout': 'enabled', + 'buildStderr': 'enabled', + 'buildTime': 128,}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await functions.getDeployment( + functionId: '[FUNCTION_ID]', + deploymentId: '[DEPLOYMENT_ID]', + ); + expect(response, isA()); + + }); + + test('test method updateDeployment()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'execute': [], + 'name': 'My Function', + 'enabled': true, + 'runtime': 'python-3.8', + 'deployment': '5e5ea5c16897e', + 'vars': [], + 'events': [], + 'schedule': '5 4 * * *', + 'scheduleNext': '2020-10-15T06:38:00.000+00:00', + 'schedulePrevious': '2020-10-15T06:38:00.000+00:00', + 'timeout': 15,}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await functions.updateDeployment( + functionId: '[FUNCTION_ID]', + deploymentId: '[DEPLOYMENT_ID]', + ); + expect(response, isA()); + + }); + + test('test method deleteDeployment()', () async { + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await functions.deleteDeployment( + functionId: '[FUNCTION_ID]', + deploymentId: '[DEPLOYMENT_ID]', + ); + }); + + test('test method createBuild()', () async { + final data = ''; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await functions.createBuild( + functionId: '[FUNCTION_ID]', + deploymentId: '[DEPLOYMENT_ID]', + buildId: '[BUILD_ID]', + ); + }); + + test('test method listExecutions()', () async { + final Map data = { + 'total': 5, + 'executions': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await functions.listExecutions( + functionId: '[FUNCTION_ID]', + ); + expect(response, isA()); + + }); + + test('test method createExecution()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'functionId': '5e5ea6g16897e', + 'trigger': 'http', + 'status': 'processing', + 'statusCode': 0, + 'response': '', + 'stdout': '', + 'stderr': '', + 'duration': 0.4,}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await functions.createExecution( + functionId: '[FUNCTION_ID]', + ); + expect(response, isA()); + + }); + + test('test method getExecution()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'functionId': '5e5ea6g16897e', + 'trigger': 'http', + 'status': 'processing', + 'statusCode': 0, + 'response': '', + 'stdout': '', + 'stderr': '', + 'duration': 0.4,}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await functions.getExecution( + functionId: '[FUNCTION_ID]', + executionId: '[EXECUTION_ID]', + ); + expect(response, isA()); + + }); + + test('test method listVariables()', () async { + final Map data = { + 'total': 5, + 'variables': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await functions.listVariables( + functionId: '[FUNCTION_ID]', + ); + expect(response, isA()); + + }); + + test('test method createVariable()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'key': 'API_KEY', + 'value': 'myPa\$\$word1', + 'functionId': '5e5ea5c16897e',}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await functions.createVariable( + functionId: '[FUNCTION_ID]', + key: '[KEY]', + value: '[VALUE]', + ); + expect(response, isA()); + + }); + + test('test method getVariable()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'key': 'API_KEY', + 'value': 'myPa\$\$word1', + 'functionId': '5e5ea5c16897e',}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await functions.getVariable( + functionId: '[FUNCTION_ID]', + variableId: '[VARIABLE_ID]', + ); + expect(response, isA()); + + }); + + test('test method updateVariable()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'key': 'API_KEY', + 'value': 'myPa\$\$word1', + 'functionId': '5e5ea5c16897e',}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await functions.updateVariable( + functionId: '[FUNCTION_ID]', + variableId: '[VARIABLE_ID]', + key: '[KEY]', + ); + expect(response, isA()); + + }); + + test('test method deleteVariable()', () async { + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await functions.deleteVariable( + functionId: '[FUNCTION_ID]', + variableId: '[VARIABLE_ID]', + ); + }); + + }); +} \ No newline at end of file diff --git a/test/services/graphql_test.dart b/test/services/graphql_test.dart new file mode 100644 index 00000000..20ace7b1 --- /dev/null +++ b/test/services/graphql_test.dart @@ -0,0 +1,84 @@ +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 config = {'project': 'testproject'}; + String endPoint = 'https://localhost/v1'; + @override + Future call( + HttpMethod? method, { + String path = '', + Map headers = const {}, + Map 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 chunkedUpload({ + String? path, + Map? params, + String? paramName, + String? idParamName, + Map? headers, + Function(UploadProgress)? onProgress, + }) async { + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + } +} + +void main() { + group('Graphql test', () { + late MockClient client; + late Graphql graphql; + + setUp(() { + client = MockClient(); + graphql = Graphql(client); + }); + + test('test method query()', () async { + final data = ''; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await graphql.query( + query: {}, + ); + }); + + test('test method mutation()', () async { + final data = ''; + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await graphql.mutation( + query: {}, + ); + }); + + }); +} \ No newline at end of file diff --git a/test/services/health_test.dart b/test/services/health_test.dart new file mode 100644 index 00000000..3f0117a3 --- /dev/null +++ b/test/services/health_test.dart @@ -0,0 +1,225 @@ +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 config = {'project': 'testproject'}; + String endPoint = 'https://localhost/v1'; + @override + Future call( + HttpMethod? method, { + String path = '', + Map headers = const {}, + Map 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 chunkedUpload({ + String? path, + Map? params, + String? paramName, + String? idParamName, + Map? headers, + Function(UploadProgress)? onProgress, + }) async { + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + } +} + +void main() { + group('Health test', () { + late MockClient client; + late Health health; + + setUp(() { + client = MockClient(); + health = Health(client); + }); + + test('test method get()', () async { + final Map data = { + 'ping': 128, + 'status': 'pass',}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await health.get( + ); + expect(response, isA()); + + }); + + test('test method getAntivirus()', () async { + final Map data = { + 'version': '1.0.0', + 'status': 'online',}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await health.getAntivirus( + ); + expect(response, isA()); + + }); + + test('test method getCache()', () async { + final Map data = { + 'ping': 128, + 'status': 'pass',}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await health.getCache( + ); + expect(response, isA()); + + }); + + test('test method getDB()', () async { + final Map data = { + 'ping': 128, + 'status': 'pass',}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await health.getDB( + ); + expect(response, isA()); + + }); + + test('test method getQueueCertificates()', () async { + final Map data = { + 'size': 8,}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await health.getQueueCertificates( + ); + expect(response, isA()); + + }); + + test('test method getQueueFunctions()', () async { + final Map data = { + 'size': 8,}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await health.getQueueFunctions( + ); + expect(response, isA()); + + }); + + test('test method getQueueLogs()', () async { + final Map data = { + 'size': 8,}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await health.getQueueLogs( + ); + expect(response, isA()); + + }); + + test('test method getQueueWebhooks()', () async { + final Map data = { + 'size': 8,}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await health.getQueueWebhooks( + ); + expect(response, isA()); + + }); + + test('test method getStorageLocal()', () async { + final Map data = { + 'ping': 128, + 'status': 'pass',}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await health.getStorageLocal( + ); + expect(response, isA()); + + }); + + test('test method getTime()', () async { + final Map data = { + 'remoteTime': 1639490751, + 'localTime': 1639490844, + 'diff': 93,}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await health.getTime( + ); + expect(response, isA()); + + }); + + }); +} \ No newline at end of file diff --git a/test/services/locale_test.dart b/test/services/locale_test.dart new file mode 100644 index 00000000..9a9453c1 --- /dev/null +++ b/test/services/locale_test.dart @@ -0,0 +1,182 @@ +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 config = {'project': 'testproject'}; + String endPoint = 'https://localhost/v1'; + @override + Future call( + HttpMethod? method, { + String path = '', + Map headers = const {}, + Map 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 chunkedUpload({ + String? path, + Map? params, + String? paramName, + String? idParamName, + Map? headers, + Function(UploadProgress)? onProgress, + }) async { + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + } +} + +void main() { + group('Locale test', () { + late MockClient client; + late Locale locale; + + setUp(() { + client = MockClient(); + locale = Locale(client); + }); + + test('test method get()', () async { + final Map data = { + 'ip': '127.0.0.1', + 'countryCode': 'US', + 'country': 'United States', + 'continentCode': 'NA', + 'continent': 'North America', + 'eu': true, + 'currency': 'USD',}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await locale.get( + ); + expect(response, isA()); + + }); + + test('test method listContinents()', () async { + final Map data = { + 'total': 5, + 'continents': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await locale.listContinents( + ); + expect(response, isA()); + + }); + + test('test method listCountries()', () async { + final Map data = { + 'total': 5, + 'countries': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await locale.listCountries( + ); + expect(response, isA()); + + }); + + test('test method listCountriesEU()', () async { + final Map data = { + 'total': 5, + 'countries': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await locale.listCountriesEU( + ); + expect(response, isA()); + + }); + + test('test method listCountriesPhones()', () async { + final Map data = { + 'total': 5, + 'phones': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await locale.listCountriesPhones( + ); + expect(response, isA()); + + }); + + test('test method listCurrencies()', () async { + final Map data = { + 'total': 5, + 'currencies': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await locale.listCurrencies( + ); + expect(response, isA()); + + }); + + test('test method listLanguages()', () async { + final Map data = { + 'total': 5, + 'languages': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await locale.listLanguages( + ); + expect(response, isA()); + + }); + + }); +} \ No newline at end of file diff --git a/test/services/storage_test.dart b/test/services/storage_test.dart new file mode 100644 index 00000000..78ed21c7 --- /dev/null +++ b/test/services/storage_test.dart @@ -0,0 +1,340 @@ +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 config = {'project': 'testproject'}; + String endPoint = 'https://localhost/v1'; + @override + Future call( + HttpMethod? method, { + String path = '', + Map headers = const {}, + Map 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 chunkedUpload({ + String? path, + Map? params, + String? paramName, + String? idParamName, + Map? headers, + Function(UploadProgress)? onProgress, + }) async { + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + } +} + +void main() { + group('Storage test', () { + late MockClient client; + late Storage storage; + + setUp(() { + client = MockClient(); + storage = Storage(client); + }); + + test('test method listBuckets()', () async { + final Map data = { + 'total': 5, + 'buckets': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await storage.listBuckets( + ); + expect(response, isA()); + + }); + + test('test method createBucket()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'fileSecurity': true, + 'name': 'Documents', + 'enabled': true, + 'maximumFileSize': 100, + 'allowedFileExtensions': [], + 'compression': 'gzip', + 'encryption': true, + 'antivirus': true,}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await storage.createBucket( + bucketId: '[BUCKET_ID]', + name: '[NAME]', + ); + expect(response, isA()); + + }); + + test('test method getBucket()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'fileSecurity': true, + 'name': 'Documents', + 'enabled': true, + 'maximumFileSize': 100, + 'allowedFileExtensions': [], + 'compression': 'gzip', + 'encryption': true, + 'antivirus': true,}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await storage.getBucket( + bucketId: '[BUCKET_ID]', + ); + expect(response, isA()); + + }); + + test('test method updateBucket()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'fileSecurity': true, + 'name': 'Documents', + 'enabled': true, + 'maximumFileSize': 100, + 'allowedFileExtensions': [], + 'compression': 'gzip', + 'encryption': true, + 'antivirus': true,}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await storage.updateBucket( + bucketId: '[BUCKET_ID]', + name: '[NAME]', + ); + expect(response, isA()); + + }); + + test('test method deleteBucket()', () async { + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await storage.deleteBucket( + bucketId: '[BUCKET_ID]', + ); + }); + + test('test method listFiles()', () async { + final Map data = { + 'total': 5, + 'files': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await storage.listFiles( + bucketId: '[BUCKET_ID]', + ); + expect(response, isA()); + + }); + + test('test method createFile()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + 'bucketId': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'name': 'Pink.png', + 'signature': '5d529fd02b544198ae075bd57c1762bb', + 'mimeType': 'image/png', + 'sizeOriginal': 17890, + 'chunksTotal': 17890, + 'chunksUploaded': 17890,}; + + + when(client.chunkedUpload( + path: argThat(isNotNull), + params: argThat(isNotNull), + paramName: argThat(isNotNull), + idParamName: argThat(isNotNull), + headers: argThat(isNotNull), + )).thenAnswer((_) async => Response(data: data)); + + + final response = await storage.createFile( + bucketId: '[BUCKET_ID]', + fileId: '[FILE_ID]', + file: InputFile.fromPath(path: './image.png'), + ); + expect(response, isA()); + + }); + + test('test method getFile()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + 'bucketId': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'name': 'Pink.png', + 'signature': '5d529fd02b544198ae075bd57c1762bb', + 'mimeType': 'image/png', + 'sizeOriginal': 17890, + 'chunksTotal': 17890, + 'chunksUploaded': 17890,}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await storage.getFile( + bucketId: '[BUCKET_ID]', + fileId: '[FILE_ID]', + ); + expect(response, isA()); + + }); + + test('test method updateFile()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + 'bucketId': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + '\$permissions': [], + 'name': 'Pink.png', + 'signature': '5d529fd02b544198ae075bd57c1762bb', + 'mimeType': 'image/png', + 'sizeOriginal': 17890, + 'chunksTotal': 17890, + 'chunksUploaded': 17890,}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await storage.updateFile( + bucketId: '[BUCKET_ID]', + fileId: '[FILE_ID]', + ); + expect(response, isA()); + + }); + + test('test method deleteFile()', () async { + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await storage.deleteFile( + bucketId: '[BUCKET_ID]', + fileId: '[FILE_ID]', + ); + }); + + test('test method getFileDownload()', () async {final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await storage.getFileDownload( + bucketId: '[BUCKET_ID]', + fileId: '[FILE_ID]', + ); + expect(response, isA()); + + }); + + test('test method getFilePreview()', () async {final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await storage.getFilePreview( + bucketId: '[BUCKET_ID]', + fileId: '[FILE_ID]', + ); + expect(response, isA()); + + }); + + test('test method getFileView()', () async {final Uint8List data = Uint8List.fromList([]); + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await storage.getFileView( + bucketId: '[BUCKET_ID]', + fileId: '[FILE_ID]', + ); + expect(response, isA()); + + }); + + }); +} \ No newline at end of file diff --git a/test/services/teams_test.dart b/test/services/teams_test.dart new file mode 100644 index 00000000..a7347b10 --- /dev/null +++ b/test/services/teams_test.dart @@ -0,0 +1,341 @@ +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 config = {'project': 'testproject'}; + String endPoint = 'https://localhost/v1'; + @override + Future call( + HttpMethod? method, { + String path = '', + Map headers = const {}, + Map 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 chunkedUpload({ + String? path, + Map? params, + String? paramName, + String? idParamName, + Map? headers, + Function(UploadProgress)? onProgress, + }) async { + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + } +} + +void main() { + group('Teams test', () { + late MockClient client; + late Teams teams; + + setUp(() { + client = MockClient(); + teams = Teams(client); + }); + + test('test method list()', () async { + final Map data = { + 'total': 5, + 'teams': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.list( + ); + expect(response, isA()); + + }); + + test('test method create()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'VIP', + 'total': 7, + 'prefs': {},}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.create( + teamId: '[TEAM_ID]', + name: '[NAME]', + ); + expect(response, isA()); + + }); + + test('test method get()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'VIP', + 'total': 7, + 'prefs': {},}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.get( + teamId: '[TEAM_ID]', + ); + expect(response, isA()); + + }); + + test('test method updateName()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'name': 'VIP', + 'total': 7, + 'prefs': {},}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.updateName( + teamId: '[TEAM_ID]', + name: '[NAME]', + ); + expect(response, isA()); + + }); + + test('test method delete()', () async { + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.delete( + teamId: '[TEAM_ID]', + ); + }); + + test('test method listMemberships()', () async { + final Map data = { + 'total': 5, + 'memberships': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.listMemberships( + teamId: '[TEAM_ID]', + ); + expect(response, isA()); + + }); + + test('test method createMembership()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'roles': [],}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.createMembership( + teamId: '[TEAM_ID]', + roles: [], + url: 'https://example.com', + ); + expect(response, isA()); + + }); + + test('test method getMembership()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'roles': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.getMembership( + teamId: '[TEAM_ID]', + membershipId: '[MEMBERSHIP_ID]', + ); + expect(response, isA()); + + }); + + test('test method updateMembershipRoles()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'roles': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.updateMembershipRoles( + teamId: '[TEAM_ID]', + membershipId: '[MEMBERSHIP_ID]', + roles: [], + ); + expect(response, isA()); + + }); + + test('test method deleteMembership()', () async { + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.deleteMembership( + teamId: '[TEAM_ID]', + membershipId: '[MEMBERSHIP_ID]', + ); + }); + + test('test method updateMembershipStatus()', () async { + final Map data = { + '\$id': '5e5ea5c16897e', + '\$createdAt': '2020-10-15T06:38:00.000+00:00', + '\$updatedAt': '2020-10-15T06:38:00.000+00:00', + 'userId': '5e5ea5c16897e', + 'userName': 'John Doe', + 'userEmail': 'john@appwrite.io', + 'teamId': '5e5ea5c16897e', + 'teamName': 'VIP', + 'invited': '2020-10-15T06:38:00.000+00:00', + 'joined': '2020-10-15T06:38:00.000+00:00', + 'confirm': true, + 'roles': [],}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.updateMembershipStatus( + teamId: '[TEAM_ID]', + membershipId: '[MEMBERSHIP_ID]', + userId: '[USER_ID]', + secret: '[SECRET]', + ); + expect(response, isA()); + + }); + + test('test method getPrefs()', () async { + final Map data = {}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.getPrefs( + teamId: '[TEAM_ID]', + ); + expect(response, isA()); + + }); + + test('test method updatePrefs()', () async { + final Map data = {}; + + + when(client.call( + HttpMethod.put, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await teams.updatePrefs( + teamId: '[TEAM_ID]', + prefs: {}, + ); + expect(response, isA()); + + }); + + }); +} \ No newline at end of file diff --git a/test/services/users_test.dart b/test/services/users_test.dart new file mode 100644 index 00000000..c832b8c8 --- /dev/null +++ b/test/services/users_test.dart @@ -0,0 +1,679 @@ +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 config = {'project': 'testproject'}; + String endPoint = 'https://localhost/v1'; + @override + Future call( + HttpMethod? method, { + String path = '', + Map headers = const {}, + Map 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 chunkedUpload({ + String? path, + Map? params, + String? paramName, + String? idParamName, + Map? headers, + Function(UploadProgress)? onProgress, + }) async { + return super.noSuchMethod(Invocation.method(#chunkedUpload, [path, params, paramName, idParamName, headers]), returnValue: Response(data: {})); + } +} + +void main() { + group('Users test', () { + late MockClient client; + late Users users; + + setUp(() { + client = MockClient(); + users = Users(client); + }); + + test('test method list()', () async { + final Map data = { + 'total': 5, + 'users': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.list( + ); + expect(response, isA()); + + }); + + test('test method create()', () async { + final Map 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, + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'prefs': {},}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.create( + userId: '[USER_ID]', + ); + expect(response, isA()); + + }); + + test('test method createArgon2User()', () async { + final Map 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, + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'prefs': {},}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.createArgon2User( + userId: '[USER_ID]', + email: 'email@example.com', + password: 'password', + ); + expect(response, isA()); + + }); + + test('test method createBcryptUser()', () async { + final Map 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, + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'prefs': {},}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.createBcryptUser( + userId: '[USER_ID]', + email: 'email@example.com', + password: 'password', + ); + expect(response, isA()); + + }); + + test('test method createMD5User()', () async { + final Map 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, + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'prefs': {},}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.createMD5User( + userId: '[USER_ID]', + email: 'email@example.com', + password: 'password', + ); + expect(response, isA()); + + }); + + test('test method createPHPassUser()', () async { + final Map 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, + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'prefs': {},}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.createPHPassUser( + userId: '[USER_ID]', + email: 'email@example.com', + password: 'password', + ); + expect(response, isA()); + + }); + + test('test method createScryptUser()', () async { + final Map 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, + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'prefs': {},}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.createScryptUser( + userId: '[USER_ID]', + email: 'email@example.com', + password: 'password', + passwordSalt: '[PASSWORD_SALT]', + passwordCpu: 1, + passwordMemory: 1, + passwordParallel: 1, + passwordLength: 1, + ); + expect(response, isA()); + + }); + + test('test method createScryptModifiedUser()', () async { + final Map 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, + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'prefs': {},}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.createScryptModifiedUser( + userId: '[USER_ID]', + email: 'email@example.com', + password: 'password', + passwordSalt: '[PASSWORD_SALT]', + passwordSaltSeparator: '[PASSWORD_SALT_SEPARATOR]', + passwordSignerKey: '[PASSWORD_SIGNER_KEY]', + ); + expect(response, isA()); + + }); + + test('test method createSHAUser()', () async { + final Map 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, + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'prefs': {},}; + + + when(client.call( + HttpMethod.post, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.createSHAUser( + userId: '[USER_ID]', + email: 'email@example.com', + password: 'password', + ); + expect(response, isA()); + + }); + + test('test method get()', () async { + final Map 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, + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'prefs': {},}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.get( + userId: '[USER_ID]', + ); + expect(response, isA()); + + }); + + test('test method delete()', () async { + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.delete( + userId: '[USER_ID]', + ); + }); + + test('test method updateEmail()', () async { + final Map 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, + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'prefs': {},}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.updateEmail( + userId: '[USER_ID]', + email: 'email@example.com', + ); + expect(response, isA()); + + }); + + test('test method listLogs()', () async { + final Map data = { + 'total': 5, + 'logs': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.listLogs( + userId: '[USER_ID]', + ); + expect(response, isA()); + + }); + + test('test method listMemberships()', () async { + final Map data = { + 'total': 5, + 'memberships': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.listMemberships( + userId: '[USER_ID]', + ); + expect(response, isA()); + + }); + + test('test method updateName()', () async { + final Map 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, + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'prefs': {},}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.updateName( + userId: '[USER_ID]', + name: '[NAME]', + ); + expect(response, isA()); + + }); + + test('test method updatePassword()', () async { + final Map 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, + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'prefs': {},}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.updatePassword( + userId: '[USER_ID]', + password: '', + ); + expect(response, isA()); + + }); + + test('test method updatePhone()', () async { + final Map 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, + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'prefs': {},}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.updatePhone( + userId: '[USER_ID]', + number: '+12065550100', + ); + expect(response, isA()); + + }); + + test('test method getPrefs()', () async { + final Map data = {}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.getPrefs( + userId: '[USER_ID]', + ); + expect(response, isA()); + + }); + + test('test method updatePrefs()', () async { + final Map data = {}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.updatePrefs( + userId: '[USER_ID]', + prefs: {}, + ); + expect(response, isA()); + + }); + + test('test method listSessions()', () async { + final Map data = { + 'total': 5, + 'sessions': [],}; + + + when(client.call( + HttpMethod.get, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.listSessions( + userId: '[USER_ID]', + ); + expect(response, isA()); + + }); + + test('test method deleteSessions()', () async { + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.deleteSessions( + userId: '[USER_ID]', + ); + }); + + test('test method deleteSession()', () async { + final data = ''; + + when(client.call( + HttpMethod.delete, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.deleteSession( + userId: '[USER_ID]', + sessionId: '[SESSION_ID]', + ); + }); + + test('test method updateStatus()', () async { + final Map 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, + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'prefs': {},}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.updateStatus( + userId: '[USER_ID]', + status: true, + ); + expect(response, isA()); + + }); + + test('test method updateEmailVerification()', () async { + final Map 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, + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'prefs': {},}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.updateEmailVerification( + userId: '[USER_ID]', + emailVerification: true, + ); + expect(response, isA()); + + }); + + test('test method updatePhoneVerification()', () async { + final Map 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, + 'passwordUpdate': '2020-10-15T06:38:00.000+00:00', + 'email': 'john@appwrite.io', + 'phone': '+4930901820', + 'emailVerification': true, + 'phoneVerification': true, + 'prefs': {},}; + + + when(client.call( + HttpMethod.patch, + )).thenAnswer((_) async => Response(data: data)); + + + final response = await users.updatePhoneVerification( + userId: '[USER_ID]', + phoneVerification: true, + ); + expect(response, isA()); + + }); + + }); +} \ No newline at end of file diff --git a/test/src/enums_test.dart b/test/src/enums_test.dart new file mode 100644 index 00000000..120ab2c9 --- /dev/null +++ b/test/src/enums_test.dart @@ -0,0 +1,12 @@ +import 'package:dart_appwrite/src/enums.dart'; +import 'package:test/test.dart'; + +void main() { + group('name()', () { + for (final method in HttpMethod.values) { + test('returns ${method.toString().split('.').last.toUpperCase()} for $method', () { + expect(method.name(), method.toString().split('.').last.toUpperCase()); + }); + } + }); +} \ No newline at end of file diff --git a/test/src/exception_test.dart b/test/src/exception_test.dart new file mode 100644 index 00000000..f55782cf --- /dev/null +++ b/test/src/exception_test.dart @@ -0,0 +1,17 @@ +import 'package:dart_appwrite/src/exception.dart'; +import 'package:test/test.dart'; + +void main() { + group('AppwriteException', () { + test('toString should return correct string representation', () { + final exception1 = AppwriteException(); + expect(exception1.toString(), equals('AppwriteException')); + + final exception2 = AppwriteException('Some error message'); + expect(exception2.toString(), equals('AppwriteException: , Some error message (0)')); + + final exception3 = AppwriteException('Invalid request', 400, 'ValidationError'); + expect(exception3.toString(), equals('AppwriteException: ValidationError, Invalid request (400)')); + }); + }); +} diff --git a/test/src/input_file_test.dart b/test/src/input_file_test.dart new file mode 100644 index 00000000..ccbd4387 --- /dev/null +++ b/test/src/input_file_test.dart @@ -0,0 +1,47 @@ +import 'package:test/test.dart'; +import 'package:dart_appwrite/src/exception.dart'; +import 'package:dart_appwrite/src/input_file.dart'; + +void main() { + group('InputFile', () { + test('throws exception when neither path nor bytes are provided', () { + expect( + () => InputFile(), + throwsA(isA().having( + (e) => e.message, + 'message', + 'One of `path` or `bytes` is required', + )), + ); + }); + + test('throws exception when path and bytes are both null', () { + expect( + () => InputFile(path: null, bytes: null), + throwsA(isA().having( + (e) => e.message, + 'message', + 'One of `path` or `bytes` is required', + )), + ); + }); + + test('creates InputFile from path', () { + final inputFile = InputFile.fromPath(path: '/path/to/file'); + + expect(inputFile.path, '/path/to/file'); + expect(inputFile.filename, isNull); + expect(inputFile.contentType, isNull); + expect(inputFile.bytes, isNull); + }); + + test('creates InputFile from bytes', () { + final inputFile = InputFile.fromBytes(bytes: [1, 2, 3], filename: 'file.txt'); + + expect(inputFile.path, isNull); + expect(inputFile.filename, 'file.txt'); + expect(inputFile.contentType, isNull); + expect(inputFile.bytes, [1, 2, 3]); + }); + }); +} diff --git a/test/src/models/algo_argon2_test.dart b/test/src/models/algo_argon2_test.dart new file mode 100644 index 00000000..13a1bbb0 --- /dev/null +++ b/test/src/models/algo_argon2_test.dart @@ -0,0 +1,24 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('AlgoArgon2', () { + + test('model', () { + final model = AlgoArgon2( + type: 'argon2', + memoryCost: 65536, + timeCost: 4, + threads: 3, + ); + + final map = model.toMap(); + final result = AlgoArgon2.fromMap(map); + + expect(result.type, 'argon2'); + expect(result.memoryCost, 65536); + expect(result.timeCost, 4); + expect(result.threads, 3); + }); + }); +} diff --git a/test/src/models/algo_bcrypt_test.dart b/test/src/models/algo_bcrypt_test.dart new file mode 100644 index 00000000..3b3735a8 --- /dev/null +++ b/test/src/models/algo_bcrypt_test.dart @@ -0,0 +1,18 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('AlgoBcrypt', () { + + test('model', () { + final model = AlgoBcrypt( + type: 'bcrypt', + ); + + final map = model.toMap(); + final result = AlgoBcrypt.fromMap(map); + + expect(result.type, 'bcrypt'); + }); + }); +} diff --git a/test/src/models/algo_md5_test.dart b/test/src/models/algo_md5_test.dart new file mode 100644 index 00000000..beb757ab --- /dev/null +++ b/test/src/models/algo_md5_test.dart @@ -0,0 +1,18 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('AlgoMd5', () { + + test('model', () { + final model = AlgoMd5( + type: 'md5', + ); + + final map = model.toMap(); + final result = AlgoMd5.fromMap(map); + + expect(result.type, 'md5'); + }); + }); +} diff --git a/test/src/models/algo_phpass_test.dart b/test/src/models/algo_phpass_test.dart new file mode 100644 index 00000000..4dd25578 --- /dev/null +++ b/test/src/models/algo_phpass_test.dart @@ -0,0 +1,18 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('AlgoPhpass', () { + + test('model', () { + final model = AlgoPhpass( + type: 'phpass', + ); + + final map = model.toMap(); + final result = AlgoPhpass.fromMap(map); + + expect(result.type, 'phpass'); + }); + }); +} diff --git a/test/src/models/algo_scrypt_modified_test.dart b/test/src/models/algo_scrypt_modified_test.dart new file mode 100644 index 00000000..fe32160d --- /dev/null +++ b/test/src/models/algo_scrypt_modified_test.dart @@ -0,0 +1,24 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('AlgoScryptModified', () { + + test('model', () { + final model = AlgoScryptModified( + type: 'scryptMod', + salt: 'UxLMreBr6tYyjQ==', + saltSeparator: 'Bw==', + signerKey: 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ==', + ); + + final map = model.toMap(); + final result = AlgoScryptModified.fromMap(map); + + expect(result.type, 'scryptMod'); + expect(result.salt, 'UxLMreBr6tYyjQ=='); + expect(result.saltSeparator, 'Bw=='); + expect(result.signerKey, 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ=='); + }); + }); +} diff --git a/test/src/models/algo_scrypt_test.dart b/test/src/models/algo_scrypt_test.dart new file mode 100644 index 00000000..12ea9fa2 --- /dev/null +++ b/test/src/models/algo_scrypt_test.dart @@ -0,0 +1,26 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('AlgoScrypt', () { + + test('model', () { + final model = AlgoScrypt( + type: 'scrypt', + costCpu: 8, + costMemory: 14, + costParallel: 1, + length: 64, + ); + + final map = model.toMap(); + final result = AlgoScrypt.fromMap(map); + + expect(result.type, 'scrypt'); + expect(result.costCpu, 8); + expect(result.costMemory, 14); + expect(result.costParallel, 1); + expect(result.length, 64); + }); + }); +} diff --git a/test/src/models/algo_sha_test.dart b/test/src/models/algo_sha_test.dart new file mode 100644 index 00000000..1f7a7817 --- /dev/null +++ b/test/src/models/algo_sha_test.dart @@ -0,0 +1,18 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('AlgoSha', () { + + test('model', () { + final model = AlgoSha( + type: 'sha', + ); + + final map = model.toMap(); + final result = AlgoSha.fromMap(map); + + expect(result.type, 'sha'); + }); + }); +} diff --git a/test/src/models/attribute_boolean_test.dart b/test/src/models/attribute_boolean_test.dart new file mode 100644 index 00000000..86846c39 --- /dev/null +++ b/test/src/models/attribute_boolean_test.dart @@ -0,0 +1,24 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('AttributeBoolean', () { + + test('model', () { + final model = AttributeBoolean( + key: 'isEnabled', + type: 'boolean', + status: 'available', + xrequired: true, + ); + + final map = model.toMap(); + final result = AttributeBoolean.fromMap(map); + + expect(result.key, 'isEnabled'); + expect(result.type, 'boolean'); + expect(result.status, 'available'); + expect(result.xrequired, true); + }); + }); +} diff --git a/test/src/models/attribute_datetime_test.dart b/test/src/models/attribute_datetime_test.dart new file mode 100644 index 00000000..d8cfbd30 --- /dev/null +++ b/test/src/models/attribute_datetime_test.dart @@ -0,0 +1,26 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('AttributeDatetime', () { + + test('model', () { + final model = AttributeDatetime( + key: 'birthDay', + type: 'datetime', + status: 'available', + xrequired: true, + format: 'datetime', + ); + + final map = model.toMap(); + final result = AttributeDatetime.fromMap(map); + + expect(result.key, 'birthDay'); + expect(result.type, 'datetime'); + expect(result.status, 'available'); + expect(result.xrequired, true); + expect(result.format, 'datetime'); + }); + }); +} diff --git a/test/src/models/attribute_email_test.dart b/test/src/models/attribute_email_test.dart new file mode 100644 index 00000000..a7dc6590 --- /dev/null +++ b/test/src/models/attribute_email_test.dart @@ -0,0 +1,26 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('AttributeEmail', () { + + test('model', () { + final model = AttributeEmail( + key: 'userEmail', + type: 'string', + status: 'available', + xrequired: true, + format: 'email', + ); + + final map = model.toMap(); + final result = AttributeEmail.fromMap(map); + + expect(result.key, 'userEmail'); + expect(result.type, 'string'); + expect(result.status, 'available'); + expect(result.xrequired, true); + expect(result.format, 'email'); + }); + }); +} diff --git a/test/src/models/attribute_enum_test.dart b/test/src/models/attribute_enum_test.dart new file mode 100644 index 00000000..6dfa3ce6 --- /dev/null +++ b/test/src/models/attribute_enum_test.dart @@ -0,0 +1,28 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('AttributeEnum', () { + + test('model', () { + final model = AttributeEnum( + key: 'status', + type: 'string', + status: 'available', + xrequired: true, + elements: [], + format: 'enum', + ); + + final map = model.toMap(); + final result = AttributeEnum.fromMap(map); + + expect(result.key, 'status'); + expect(result.type, 'string'); + expect(result.status, 'available'); + expect(result.xrequired, true); + expect(result.elements, []); + expect(result.format, 'enum'); + }); + }); +} diff --git a/test/src/models/attribute_float_test.dart b/test/src/models/attribute_float_test.dart new file mode 100644 index 00000000..c0fc0c1c --- /dev/null +++ b/test/src/models/attribute_float_test.dart @@ -0,0 +1,24 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('AttributeFloat', () { + + test('model', () { + final model = AttributeFloat( + key: 'percentageCompleted', + type: 'double', + status: 'available', + xrequired: true, + ); + + final map = model.toMap(); + final result = AttributeFloat.fromMap(map); + + expect(result.key, 'percentageCompleted'); + expect(result.type, 'double'); + expect(result.status, 'available'); + expect(result.xrequired, true); + }); + }); +} diff --git a/test/src/models/attribute_integer_test.dart b/test/src/models/attribute_integer_test.dart new file mode 100644 index 00000000..3dd7fd19 --- /dev/null +++ b/test/src/models/attribute_integer_test.dart @@ -0,0 +1,24 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('AttributeInteger', () { + + test('model', () { + final model = AttributeInteger( + key: 'count', + type: 'integer', + status: 'available', + xrequired: true, + ); + + final map = model.toMap(); + final result = AttributeInteger.fromMap(map); + + expect(result.key, 'count'); + expect(result.type, 'integer'); + expect(result.status, 'available'); + expect(result.xrequired, true); + }); + }); +} diff --git a/test/src/models/attribute_ip_test.dart b/test/src/models/attribute_ip_test.dart new file mode 100644 index 00000000..43b87507 --- /dev/null +++ b/test/src/models/attribute_ip_test.dart @@ -0,0 +1,26 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('AttributeIp', () { + + test('model', () { + final model = AttributeIp( + key: 'ipAddress', + type: 'string', + status: 'available', + xrequired: true, + format: 'ip', + ); + + final map = model.toMap(); + final result = AttributeIp.fromMap(map); + + expect(result.key, 'ipAddress'); + expect(result.type, 'string'); + expect(result.status, 'available'); + expect(result.xrequired, true); + expect(result.format, 'ip'); + }); + }); +} diff --git a/test/src/models/attribute_list_test.dart b/test/src/models/attribute_list_test.dart new file mode 100644 index 00000000..e4af0248 --- /dev/null +++ b/test/src/models/attribute_list_test.dart @@ -0,0 +1,20 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('AttributeList', () { + + test('model', () { + final model = AttributeList( + total: 5, + attributes: [], + ); + + final map = model.toMap(); + final result = AttributeList.fromMap(map); + + expect(result.total, 5); + expect(result.attributes, []); + }); + }); +} diff --git a/test/src/models/attribute_relationship_test.dart b/test/src/models/attribute_relationship_test.dart new file mode 100644 index 00000000..9264d905 --- /dev/null +++ b/test/src/models/attribute_relationship_test.dart @@ -0,0 +1,36 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('AttributeRelationship', () { + + test('model', () { + final model = AttributeRelationship( + key: 'fullName', + type: 'string', + status: 'available', + xrequired: true, + relatedCollection: 'collection', + relationType: 'oneToOne|oneToMany|manyToOne|manyToMany', + twoWay: true, + twoWayKey: 'string', + onDelete: 'restrict|cascade|setNull', + side: 'parent|child', + ); + + final map = model.toMap(); + final result = AttributeRelationship.fromMap(map); + + expect(result.key, 'fullName'); + expect(result.type, 'string'); + expect(result.status, 'available'); + expect(result.xrequired, true); + expect(result.relatedCollection, 'collection'); + expect(result.relationType, 'oneToOne|oneToMany|manyToOne|manyToMany'); + expect(result.twoWay, true); + expect(result.twoWayKey, 'string'); + expect(result.onDelete, 'restrict|cascade|setNull'); + expect(result.side, 'parent|child'); + }); + }); +} diff --git a/test/src/models/attribute_string_test.dart b/test/src/models/attribute_string_test.dart new file mode 100644 index 00000000..203dcbb6 --- /dev/null +++ b/test/src/models/attribute_string_test.dart @@ -0,0 +1,26 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('AttributeString', () { + + test('model', () { + final model = AttributeString( + key: 'fullName', + type: 'string', + status: 'available', + xrequired: true, + size: 128, + ); + + final map = model.toMap(); + final result = AttributeString.fromMap(map); + + expect(result.key, 'fullName'); + expect(result.type, 'string'); + expect(result.status, 'available'); + expect(result.xrequired, true); + expect(result.size, 128); + }); + }); +} diff --git a/test/src/models/attribute_url_test.dart b/test/src/models/attribute_url_test.dart new file mode 100644 index 00000000..f0bf1a99 --- /dev/null +++ b/test/src/models/attribute_url_test.dart @@ -0,0 +1,26 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('AttributeUrl', () { + + test('model', () { + final model = AttributeUrl( + key: 'githubUrl', + type: 'string', + status: 'available', + xrequired: true, + format: 'url', + ); + + final map = model.toMap(); + final result = AttributeUrl.fromMap(map); + + expect(result.key, 'githubUrl'); + expect(result.type, 'string'); + expect(result.status, 'available'); + expect(result.xrequired, true); + expect(result.format, 'url'); + }); + }); +} diff --git a/test/src/models/bucket_list_test.dart b/test/src/models/bucket_list_test.dart new file mode 100644 index 00000000..3290c390 --- /dev/null +++ b/test/src/models/bucket_list_test.dart @@ -0,0 +1,20 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('BucketList', () { + + test('model', () { + final model = BucketList( + total: 5, + buckets: [], + ); + + final map = model.toMap(); + final result = BucketList.fromMap(map); + + expect(result.total, 5); + expect(result.buckets, []); + }); + }); +} diff --git a/test/src/models/bucket_test.dart b/test/src/models/bucket_test.dart new file mode 100644 index 00000000..3ead5259 --- /dev/null +++ b/test/src/models/bucket_test.dart @@ -0,0 +1,40 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('Bucket', () { + + test('model', () { + final model = Bucket( + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + $permissions: [], + fileSecurity: true, + name: 'Documents', + enabled: true, + maximumFileSize: 100, + allowedFileExtensions: [], + compression: 'gzip', + encryption: true, + antivirus: true, + ); + + final map = model.toMap(); + final result = Bucket.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.$permissions, []); + expect(result.fileSecurity, true); + expect(result.name, 'Documents'); + expect(result.enabled, true); + expect(result.maximumFileSize, 100); + expect(result.allowedFileExtensions, []); + expect(result.compression, 'gzip'); + expect(result.encryption, true); + expect(result.antivirus, true); + }); + }); +} diff --git a/test/src/models/collection_list_test.dart b/test/src/models/collection_list_test.dart new file mode 100644 index 00000000..0842a382 --- /dev/null +++ b/test/src/models/collection_list_test.dart @@ -0,0 +1,20 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('CollectionList', () { + + test('model', () { + final model = CollectionList( + total: 5, + collections: [], + ); + + final map = model.toMap(); + final result = CollectionList.fromMap(map); + + expect(result.total, 5); + expect(result.collections, []); + }); + }); +} diff --git a/test/src/models/collection_test.dart b/test/src/models/collection_test.dart new file mode 100644 index 00000000..9eeb507f --- /dev/null +++ b/test/src/models/collection_test.dart @@ -0,0 +1,36 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('Collection', () { + + test('model', () { + final model = Collection( + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + $permissions: [], + databaseId: '5e5ea5c16897e', + name: 'My Collection', + enabled: true, + documentSecurity: true, + attributes: [], + indexes: [], + ); + + final map = model.toMap(); + final result = Collection.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.$permissions, []); + expect(result.databaseId, '5e5ea5c16897e'); + expect(result.name, 'My Collection'); + expect(result.enabled, true); + expect(result.documentSecurity, true); + expect(result.attributes, []); + expect(result.indexes, []); + }); + }); +} diff --git a/test/src/models/continent_list_test.dart b/test/src/models/continent_list_test.dart new file mode 100644 index 00000000..095989f7 --- /dev/null +++ b/test/src/models/continent_list_test.dart @@ -0,0 +1,20 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('ContinentList', () { + + test('model', () { + final model = ContinentList( + total: 5, + continents: [], + ); + + final map = model.toMap(); + final result = ContinentList.fromMap(map); + + expect(result.total, 5); + expect(result.continents, []); + }); + }); +} diff --git a/test/src/models/continent_test.dart b/test/src/models/continent_test.dart new file mode 100644 index 00000000..90b1a6bd --- /dev/null +++ b/test/src/models/continent_test.dart @@ -0,0 +1,20 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('Continent', () { + + test('model', () { + final model = Continent( + name: 'Europe', + code: 'EU', + ); + + final map = model.toMap(); + final result = Continent.fromMap(map); + + expect(result.name, 'Europe'); + expect(result.code, 'EU'); + }); + }); +} diff --git a/test/src/models/country_list_test.dart b/test/src/models/country_list_test.dart new file mode 100644 index 00000000..5aa53423 --- /dev/null +++ b/test/src/models/country_list_test.dart @@ -0,0 +1,20 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('CountryList', () { + + test('model', () { + final model = CountryList( + total: 5, + countries: [], + ); + + final map = model.toMap(); + final result = CountryList.fromMap(map); + + expect(result.total, 5); + expect(result.countries, []); + }); + }); +} diff --git a/test/src/models/country_test.dart b/test/src/models/country_test.dart new file mode 100644 index 00000000..2465bbd3 --- /dev/null +++ b/test/src/models/country_test.dart @@ -0,0 +1,20 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('Country', () { + + test('model', () { + final model = Country( + name: 'United States', + code: 'US', + ); + + final map = model.toMap(); + final result = Country.fromMap(map); + + expect(result.name, 'United States'); + expect(result.code, 'US'); + }); + }); +} diff --git a/test/src/models/currency_list_test.dart b/test/src/models/currency_list_test.dart new file mode 100644 index 00000000..93215f53 --- /dev/null +++ b/test/src/models/currency_list_test.dart @@ -0,0 +1,20 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('CurrencyList', () { + + test('model', () { + final model = CurrencyList( + total: 5, + currencies: [], + ); + + final map = model.toMap(); + final result = CurrencyList.fromMap(map); + + expect(result.total, 5); + expect(result.currencies, []); + }); + }); +} diff --git a/test/src/models/currency_test.dart b/test/src/models/currency_test.dart new file mode 100644 index 00000000..1fa35e61 --- /dev/null +++ b/test/src/models/currency_test.dart @@ -0,0 +1,30 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('Currency', () { + + test('model', () { + final model = Currency( + symbol: '\$', + name: 'US dollar', + symbolNative: '\$', + decimalDigits: 2, + rounding: 0, + code: 'USD', + namePlural: 'US dollars', + ); + + final map = model.toMap(); + final result = Currency.fromMap(map); + + expect(result.symbol, '\$'); + expect(result.name, 'US dollar'); + expect(result.symbolNative, '\$'); + expect(result.decimalDigits, 2); + expect(result.rounding, 0); + expect(result.code, 'USD'); + expect(result.namePlural, 'US dollars'); + }); + }); +} diff --git a/test/src/models/database_list_test.dart b/test/src/models/database_list_test.dart new file mode 100644 index 00000000..eaa0cb53 --- /dev/null +++ b/test/src/models/database_list_test.dart @@ -0,0 +1,20 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('DatabaseList', () { + + test('model', () { + final model = DatabaseList( + total: 5, + databases: [], + ); + + final map = model.toMap(); + final result = DatabaseList.fromMap(map); + + expect(result.total, 5); + expect(result.databases, []); + }); + }); +} diff --git a/test/src/models/database_test.dart b/test/src/models/database_test.dart new file mode 100644 index 00000000..b0f8b938 --- /dev/null +++ b/test/src/models/database_test.dart @@ -0,0 +1,24 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('Database', () { + + test('model', () { + final model = Database( + $id: '5e5ea5c16897e', + name: 'My Database', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + ); + + final map = model.toMap(); + final result = Database.fromMap(map); + + expect(result.$id, '5e5ea5c16897e'); + expect(result.name, 'My Database'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + }); + }); +} diff --git a/test/src/models/deployment_list_test.dart b/test/src/models/deployment_list_test.dart new file mode 100644 index 00000000..1021fb7b --- /dev/null +++ b/test/src/models/deployment_list_test.dart @@ -0,0 +1,20 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('DeploymentList', () { + + test('model', () { + final model = DeploymentList( + total: 5, + deployments: [], + ); + + final map = model.toMap(); + final result = DeploymentList.fromMap(map); + + expect(result.total, 5); + expect(result.deployments, []); + }); + }); +} diff --git a/test/src/models/deployment_test.dart b/test/src/models/deployment_test.dart new file mode 100644 index 00000000..0821b4c0 --- /dev/null +++ b/test/src/models/deployment_test.dart @@ -0,0 +1,42 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('Deployment', () { + + test('model', () { + final model = Deployment( + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + resourceId: '5e5ea6g16897e', + resourceType: 'functions', + entrypoint: 'enabled', + size: 128, + buildId: '5e5ea5c16897e', + activate: true, + status: 'ready', + buildStdout: 'enabled', + buildStderr: 'enabled', + buildTime: 128, + ); + + final map = model.toMap(); + final result = Deployment.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.resourceId, '5e5ea6g16897e'); + expect(result.resourceType, 'functions'); + expect(result.entrypoint, 'enabled'); + expect(result.size, 128); + expect(result.buildId, '5e5ea5c16897e'); + expect(result.activate, true); + expect(result.status, 'ready'); + expect(result.buildStdout, 'enabled'); + expect(result.buildStderr, 'enabled'); + expect(result.buildTime, 128); + }); + }); +} diff --git a/test/src/models/document_list_test.dart b/test/src/models/document_list_test.dart new file mode 100644 index 00000000..f25a98fc --- /dev/null +++ b/test/src/models/document_list_test.dart @@ -0,0 +1,20 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('DocumentList', () { + + test('model', () { + final model = DocumentList( + total: 5, + documents: [], + ); + + final map = model.toMap(); + final result = DocumentList.fromMap(map); + + expect(result.total, 5); + expect(result.documents, []); + }); + }); +} diff --git a/test/src/models/document_test.dart b/test/src/models/document_test.dart new file mode 100644 index 00000000..ca367594 --- /dev/null +++ b/test/src/models/document_test.dart @@ -0,0 +1,29 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('Document', () { + + test('model', () { + final model = Document( + $id: '5e5ea5c16897e', + $collectionId: '5e5ea5c15117e', + $databaseId: '5e5ea5c15117e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + $permissions: [], + data: {}, + ); + + final map = model.toMap(); + final result = Document.fromMap(map); + + expect(result.$id, '5e5ea5c16897e'); + expect(result.$collectionId, '5e5ea5c15117e'); + expect(result.$databaseId, '5e5ea5c15117e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$updatedAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.$permissions, []); + }); + }); +} diff --git a/test/src/models/execution_list_test.dart b/test/src/models/execution_list_test.dart new file mode 100644 index 00000000..fe10bf3f --- /dev/null +++ b/test/src/models/execution_list_test.dart @@ -0,0 +1,20 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('ExecutionList', () { + + test('model', () { + final model = ExecutionList( + total: 5, + executions: [], + ); + + final map = model.toMap(); + final result = ExecutionList.fromMap(map); + + expect(result.total, 5); + expect(result.executions, []); + }); + }); +} diff --git a/test/src/models/execution_test.dart b/test/src/models/execution_test.dart new file mode 100644 index 00000000..5b0cc7f2 --- /dev/null +++ b/test/src/models/execution_test.dart @@ -0,0 +1,40 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('Execution', () { + + test('model', () { + final model = Execution( + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + $permissions: [], + functionId: '5e5ea6g16897e', + trigger: 'http', + status: 'processing', + statusCode: 0, + response: '', + stdout: '', + stderr: '', + duration: 0.4, + ); + + final map = model.toMap(); + final result = Execution.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.$permissions, []); + expect(result.functionId, '5e5ea6g16897e'); + expect(result.trigger, 'http'); + expect(result.status, 'processing'); + expect(result.statusCode, 0); + expect(result.response, ''); + expect(result.stdout, ''); + expect(result.stderr, ''); + expect(result.duration, 0.4); + }); + }); +} diff --git a/test/src/models/file_list_test.dart b/test/src/models/file_list_test.dart new file mode 100644 index 00000000..5bd1c5ad --- /dev/null +++ b/test/src/models/file_list_test.dart @@ -0,0 +1,20 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('FileList', () { + + test('model', () { + final model = FileList( + total: 5, + files: [], + ); + + final map = model.toMap(); + final result = FileList.fromMap(map); + + expect(result.total, 5); + expect(result.files, []); + }); + }); +} diff --git a/test/src/models/file_test.dart b/test/src/models/file_test.dart new file mode 100644 index 00000000..8d1321ea --- /dev/null +++ b/test/src/models/file_test.dart @@ -0,0 +1,38 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('File', () { + + test('model', () { + final model = File( + $id: '5e5ea5c16897e', + bucketId: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + $permissions: [], + name: 'Pink.png', + signature: '5d529fd02b544198ae075bd57c1762bb', + mimeType: 'image/png', + sizeOriginal: 17890, + chunksTotal: 17890, + chunksUploaded: 17890, + ); + + final map = model.toMap(); + final result = File.fromMap(map); + + expect(result.$id, '5e5ea5c16897e'); + expect(result.bucketId, '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.$permissions, []); + expect(result.name, 'Pink.png'); + expect(result.signature, '5d529fd02b544198ae075bd57c1762bb'); + expect(result.mimeType, 'image/png'); + expect(result.sizeOriginal, 17890); + expect(result.chunksTotal, 17890); + expect(result.chunksUploaded, 17890); + }); + }); +} diff --git a/test/src/models/function_list_test.dart b/test/src/models/function_list_test.dart new file mode 100644 index 00000000..4ed251f5 --- /dev/null +++ b/test/src/models/function_list_test.dart @@ -0,0 +1,20 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('FunctionList', () { + + test('model', () { + final model = FunctionList( + total: 5, + functions: [], + ); + + final map = model.toMap(); + final result = FunctionList.fromMap(map); + + expect(result.total, 5); + expect(result.functions, []); + }); + }); +} diff --git a/test/src/models/function_test.dart b/test/src/models/function_test.dart new file mode 100644 index 00000000..18e5c0bb --- /dev/null +++ b/test/src/models/function_test.dart @@ -0,0 +1,44 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('Func', () { + + test('model', () { + final model = Func( + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + execute: [], + name: 'My Function', + enabled: true, + runtime: 'python-3.8', + deployment: '5e5ea5c16897e', + vars: [], + events: [], + schedule: '5 4 * * *', + scheduleNext: '2020-10-15T06:38:00.000+00:00', + schedulePrevious: '2020-10-15T06:38:00.000+00:00', + timeout: 15, + ); + + final map = model.toMap(); + final result = Func.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.execute, []); + expect(result.name, 'My Function'); + expect(result.enabled, true); + expect(result.runtime, 'python-3.8'); + expect(result.deployment, '5e5ea5c16897e'); + expect(result.vars, []); + expect(result.events, []); + expect(result.schedule, '5 4 * * *'); + expect(result.scheduleNext, '2020-10-15T06:38:00.000+00:00'); + expect(result.schedulePrevious, '2020-10-15T06:38:00.000+00:00'); + expect(result.timeout, 15); + }); + }); +} diff --git a/test/src/models/health_antivirus_test.dart b/test/src/models/health_antivirus_test.dart new file mode 100644 index 00000000..38209b33 --- /dev/null +++ b/test/src/models/health_antivirus_test.dart @@ -0,0 +1,20 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('HealthAntivirus', () { + + test('model', () { + final model = HealthAntivirus( + version: '1.0.0', + status: 'online', + ); + + final map = model.toMap(); + final result = HealthAntivirus.fromMap(map); + + expect(result.version, '1.0.0'); + expect(result.status, 'online'); + }); + }); +} diff --git a/test/src/models/health_queue_test.dart b/test/src/models/health_queue_test.dart new file mode 100644 index 00000000..934df1bf --- /dev/null +++ b/test/src/models/health_queue_test.dart @@ -0,0 +1,18 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('HealthQueue', () { + + test('model', () { + final model = HealthQueue( + size: 8, + ); + + final map = model.toMap(); + final result = HealthQueue.fromMap(map); + + expect(result.size, 8); + }); + }); +} diff --git a/test/src/models/health_status_test.dart b/test/src/models/health_status_test.dart new file mode 100644 index 00000000..f1c2b5d0 --- /dev/null +++ b/test/src/models/health_status_test.dart @@ -0,0 +1,20 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('HealthStatus', () { + + test('model', () { + final model = HealthStatus( + ping: 128, + status: 'pass', + ); + + final map = model.toMap(); + final result = HealthStatus.fromMap(map); + + expect(result.ping, 128); + expect(result.status, 'pass'); + }); + }); +} diff --git a/test/src/models/health_time_test.dart b/test/src/models/health_time_test.dart new file mode 100644 index 00000000..a6c8d853 --- /dev/null +++ b/test/src/models/health_time_test.dart @@ -0,0 +1,22 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('HealthTime', () { + + test('model', () { + final model = HealthTime( + remoteTime: 1639490751, + localTime: 1639490844, + diff: 93, + ); + + final map = model.toMap(); + final result = HealthTime.fromMap(map); + + expect(result.remoteTime, 1639490751); + expect(result.localTime, 1639490844); + expect(result.diff, 93); + }); + }); +} diff --git a/test/src/models/index_list_test.dart b/test/src/models/index_list_test.dart new file mode 100644 index 00000000..83f5900c --- /dev/null +++ b/test/src/models/index_list_test.dart @@ -0,0 +1,20 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('IndexList', () { + + test('model', () { + final model = IndexList( + total: 5, + indexes: [], + ); + + final map = model.toMap(); + final result = IndexList.fromMap(map); + + expect(result.total, 5); + expect(result.indexes, []); + }); + }); +} diff --git a/test/src/models/index_test.dart b/test/src/models/index_test.dart new file mode 100644 index 00000000..3e2abb60 --- /dev/null +++ b/test/src/models/index_test.dart @@ -0,0 +1,24 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('Index', () { + + test('model', () { + final model = Index( + key: 'index1', + type: 'primary', + status: 'available', + attributes: [], + ); + + final map = model.toMap(); + final result = Index.fromMap(map); + + expect(result.key, 'index1'); + expect(result.type, 'primary'); + expect(result.status, 'available'); + expect(result.attributes, []); + }); + }); +} diff --git a/test/src/models/language_list_test.dart b/test/src/models/language_list_test.dart new file mode 100644 index 00000000..8b39a179 --- /dev/null +++ b/test/src/models/language_list_test.dart @@ -0,0 +1,20 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('LanguageList', () { + + test('model', () { + final model = LanguageList( + total: 5, + languages: [], + ); + + final map = model.toMap(); + final result = LanguageList.fromMap(map); + + expect(result.total, 5); + expect(result.languages, []); + }); + }); +} diff --git a/test/src/models/language_test.dart b/test/src/models/language_test.dart new file mode 100644 index 00000000..214a6ee8 --- /dev/null +++ b/test/src/models/language_test.dart @@ -0,0 +1,22 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('Language', () { + + test('model', () { + final model = Language( + name: 'Italian', + code: 'it', + nativeName: 'Italiano', + ); + + final map = model.toMap(); + final result = Language.fromMap(map); + + expect(result.name, 'Italian'); + expect(result.code, 'it'); + expect(result.nativeName, 'Italiano'); + }); + }); +} diff --git a/test/src/models/locale_test.dart b/test/src/models/locale_test.dart new file mode 100644 index 00000000..55515a36 --- /dev/null +++ b/test/src/models/locale_test.dart @@ -0,0 +1,30 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('Locale', () { + + test('model', () { + final model = Locale( + ip: '127.0.0.1', + countryCode: 'US', + country: 'United States', + continentCode: 'NA', + continent: 'North America', + eu: true, + currency: 'USD', + ); + + final map = model.toMap(); + final result = Locale.fromMap(map); + + expect(result.ip, '127.0.0.1'); + expect(result.countryCode, 'US'); + expect(result.country, 'United States'); + expect(result.continentCode, 'NA'); + expect(result.continent, 'North America'); + expect(result.eu, true); + expect(result.currency, 'USD'); + }); + }); +} diff --git a/test/src/models/log_list_test.dart b/test/src/models/log_list_test.dart new file mode 100644 index 00000000..cb84b9f8 --- /dev/null +++ b/test/src/models/log_list_test.dart @@ -0,0 +1,20 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('LogList', () { + + test('model', () { + final model = LogList( + total: 5, + logs: [], + ); + + final map = model.toMap(); + final result = LogList.fromMap(map); + + expect(result.total, 5); + expect(result.logs, []); + }); + }); +} diff --git a/test/src/models/log_test.dart b/test/src/models/log_test.dart new file mode 100644 index 00000000..f1fe1e97 --- /dev/null +++ b/test/src/models/log_test.dart @@ -0,0 +1,58 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('Log', () { + + test('model', () { + final model = Log( + event: 'account.sessions.create', + userId: '610fc2f985ee0', + userEmail: 'john@appwrite.io', + userName: 'John Doe', + mode: 'admin', + ip: '127.0.0.1', + time: '2020-10-15T06:38:00.000+00:00', + 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', + ); + + final map = model.toMap(); + final result = Log.fromMap(map); + + expect(result.event, 'account.sessions.create'); + expect(result.userId, '610fc2f985ee0'); + expect(result.userEmail, 'john@appwrite.io'); + expect(result.userName, 'John Doe'); + expect(result.mode, 'admin'); + expect(result.ip, '127.0.0.1'); + expect(result.time, '2020-10-15T06:38:00.000+00:00'); + expect(result.osCode, 'Mac'); + expect(result.osName, 'Mac'); + expect(result.osVersion, 'Mac'); + expect(result.clientType, 'browser'); + expect(result.clientCode, 'CM'); + expect(result.clientName, 'Chrome Mobile iOS'); + expect(result.clientVersion, '84.0'); + expect(result.clientEngine, 'WebKit'); + expect(result.clientEngineVersion, '605.1.15'); + expect(result.deviceName, 'smartphone'); + expect(result.deviceBrand, 'Google'); + expect(result.deviceModel, 'Nexus 5'); + expect(result.countryCode, 'US'); + expect(result.countryName, 'United States'); + }); + }); +} diff --git a/test/src/models/membership_list_test.dart b/test/src/models/membership_list_test.dart new file mode 100644 index 00000000..47bec4b8 --- /dev/null +++ b/test/src/models/membership_list_test.dart @@ -0,0 +1,20 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('MembershipList', () { + + test('model', () { + final model = MembershipList( + total: 5, + memberships: [], + ); + + final map = model.toMap(); + final result = MembershipList.fromMap(map); + + expect(result.total, 5); + expect(result.memberships, []); + }); + }); +} diff --git a/test/src/models/membership_test.dart b/test/src/models/membership_test.dart new file mode 100644 index 00000000..6a6f8201 --- /dev/null +++ b/test/src/models/membership_test.dart @@ -0,0 +1,40 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('Membership', () { + + test('model', () { + final model = Membership( + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + userId: '5e5ea5c16897e', + userName: 'John Doe', + userEmail: 'john@appwrite.io', + teamId: '5e5ea5c16897e', + teamName: 'VIP', + invited: '2020-10-15T06:38:00.000+00:00', + joined: '2020-10-15T06:38:00.000+00:00', + confirm: true, + roles: [], + ); + + final map = model.toMap(); + final result = Membership.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.userId, '5e5ea5c16897e'); + expect(result.userName, 'John Doe'); + expect(result.userEmail, 'john@appwrite.io'); + expect(result.teamId, '5e5ea5c16897e'); + expect(result.teamName, 'VIP'); + 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.roles, []); + }); + }); +} diff --git a/test/src/models/phone_list_test.dart b/test/src/models/phone_list_test.dart new file mode 100644 index 00000000..1ee77396 --- /dev/null +++ b/test/src/models/phone_list_test.dart @@ -0,0 +1,20 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('PhoneList', () { + + test('model', () { + final model = PhoneList( + total: 5, + phones: [], + ); + + final map = model.toMap(); + final result = PhoneList.fromMap(map); + + expect(result.total, 5); + expect(result.phones, []); + }); + }); +} diff --git a/test/src/models/phone_test.dart b/test/src/models/phone_test.dart new file mode 100644 index 00000000..64ff093a --- /dev/null +++ b/test/src/models/phone_test.dart @@ -0,0 +1,22 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('Phone', () { + + test('model', () { + final model = Phone( + code: '+1', + countryCode: 'US', + countryName: 'United States', + ); + + final map = model.toMap(); + final result = Phone.fromMap(map); + + expect(result.code, '+1'); + expect(result.countryCode, 'US'); + expect(result.countryName, 'United States'); + }); + }); +} diff --git a/test/src/models/preferences_test.dart b/test/src/models/preferences_test.dart new file mode 100644 index 00000000..f2e654dc --- /dev/null +++ b/test/src/models/preferences_test.dart @@ -0,0 +1,17 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('Preferences', () { + + test('model', () { + final model = Preferences( + data: {}, + ); + + final map = model.toMap(); + final result = Preferences.fromMap(map); + + }); + }); +} diff --git a/test/src/models/runtime_list_test.dart b/test/src/models/runtime_list_test.dart new file mode 100644 index 00000000..1a5a266e --- /dev/null +++ b/test/src/models/runtime_list_test.dart @@ -0,0 +1,20 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('RuntimeList', () { + + test('model', () { + final model = RuntimeList( + total: 5, + runtimes: [], + ); + + final map = model.toMap(); + final result = RuntimeList.fromMap(map); + + expect(result.total, 5); + expect(result.runtimes, []); + }); + }); +} diff --git a/test/src/models/runtime_test.dart b/test/src/models/runtime_test.dart new file mode 100644 index 00000000..9f53b2b4 --- /dev/null +++ b/test/src/models/runtime_test.dart @@ -0,0 +1,30 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('Runtime', () { + + test('model', () { + final model = Runtime( + $id: 'python-3.8', + name: 'Python', + version: '3.8', + base: 'python:3.8-alpine', + image: 'appwrite\/runtime-for-python:3.8', + logo: 'python.png', + supports: [], + ); + + final map = model.toMap(); + final result = Runtime.fromMap(map); + + expect(result.$id, 'python-3.8'); + expect(result.name, 'Python'); + expect(result.version, '3.8'); + expect(result.base, 'python:3.8-alpine'); + expect(result.image, 'appwrite\/runtime-for-python:3.8'); + expect(result.logo, 'python.png'); + expect(result.supports, []); + }); + }); +} diff --git a/test/src/models/session_list_test.dart b/test/src/models/session_list_test.dart new file mode 100644 index 00000000..1430b151 --- /dev/null +++ b/test/src/models/session_list_test.dart @@ -0,0 +1,20 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('SessionList', () { + + test('model', () { + final model = SessionList( + total: 5, + sessions: [], + ); + + final map = model.toMap(); + final result = SessionList.fromMap(map); + + expect(result.total, 5); + expect(result.sessions, []); + }); + }); +} diff --git a/test/src/models/session_test.dart b/test/src/models/session_test.dart new file mode 100644 index 00000000..991fa90f --- /dev/null +++ b/test/src/models/session_test.dart @@ -0,0 +1,66 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('Session', () { + + test('model', () { + final model = Session( + $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, + ); + + final map = model.toMap(); + final result = Session.fromMap(map); + + expect(result.$id, '5e5ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5bb8c16897e'); + expect(result.expire, '2020-10-15T06:38:00.000+00:00'); + expect(result.provider, 'email'); + expect(result.providerUid, 'user@example.com'); + expect(result.providerAccessToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + expect(result.providerAccessTokenExpiry, '2020-10-15T06:38:00.000+00:00'); + expect(result.providerRefreshToken, 'MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3'); + expect(result.ip, '127.0.0.1'); + expect(result.osCode, 'Mac'); + expect(result.osName, 'Mac'); + expect(result.osVersion, 'Mac'); + expect(result.clientType, 'browser'); + expect(result.clientCode, 'CM'); + expect(result.clientName, 'Chrome Mobile iOS'); + expect(result.clientVersion, '84.0'); + expect(result.clientEngine, 'WebKit'); + expect(result.clientEngineVersion, '605.1.15'); + expect(result.deviceName, 'smartphone'); + expect(result.deviceBrand, 'Google'); + expect(result.deviceModel, 'Nexus 5'); + expect(result.countryCode, 'US'); + expect(result.countryName, 'United States'); + expect(result.current, true); + }); + }); +} diff --git a/test/src/models/team_list_test.dart b/test/src/models/team_list_test.dart new file mode 100644 index 00000000..f2f044d9 --- /dev/null +++ b/test/src/models/team_list_test.dart @@ -0,0 +1,20 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('TeamList', () { + + test('model', () { + final model = TeamList( + total: 5, + teams: [], + ); + + final map = model.toMap(); + final result = TeamList.fromMap(map); + + expect(result.total, 5); + expect(result.teams, []); + }); + }); +} diff --git a/test/src/models/team_test.dart b/test/src/models/team_test.dart new file mode 100644 index 00000000..904f0eea --- /dev/null +++ b/test/src/models/team_test.dart @@ -0,0 +1,28 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('Team', () { + + test('model', () { + final model = Team( + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + name: 'VIP', + total: 7, + prefs: Preferences(data: {}), + ); + + final map = model.toMap(); + final result = Team.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, 'VIP'); + expect(result.total, 7); + expect(result.prefs.data, {"data": {}}); + }); + }); +} diff --git a/test/src/models/token_test.dart b/test/src/models/token_test.dart new file mode 100644 index 00000000..1668da70 --- /dev/null +++ b/test/src/models/token_test.dart @@ -0,0 +1,26 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('Token', () { + + test('model', () { + final model = Token( + $id: 'bb8ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + userId: '5e5ea5c168bb8', + secret: '', + expire: '2020-10-15T06:38:00.000+00:00', + ); + + final map = model.toMap(); + final result = Token.fromMap(map); + + expect(result.$id, 'bb8ea5c16897e'); + expect(result.$createdAt, '2020-10-15T06:38:00.000+00:00'); + expect(result.userId, '5e5ea5c168bb8'); + expect(result.secret, ''); + expect(result.expire, '2020-10-15T06:38:00.000+00:00'); + }); + }); +} diff --git a/test/src/models/user_list_test.dart b/test/src/models/user_list_test.dart new file mode 100644 index 00000000..954daa37 --- /dev/null +++ b/test/src/models/user_list_test.dart @@ -0,0 +1,20 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('UserList', () { + + test('model', () { + final model = UserList( + total: 5, + users: [], + ); + + final map = model.toMap(); + final result = UserList.fromMap(map); + + expect(result.total, 5); + expect(result.users, []); + }); + }); +} diff --git a/test/src/models/user_test.dart b/test/src/models/user_test.dart new file mode 100644 index 00000000..f6d93cf4 --- /dev/null +++ b/test/src/models/user_test.dart @@ -0,0 +1,40 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('User', () { + + test('model', () { + final model = User( + $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, + passwordUpdate: '2020-10-15T06:38:00.000+00:00', + email: 'john@appwrite.io', + phone: '+4930901820', + emailVerification: true, + phoneVerification: true, + prefs: Preferences(data: {}), + ); + + final map = model.toMap(); + final result = User.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, 'John Doe'); + expect(result.registration, '2020-10-15T06:38:00.000+00:00'); + expect(result.status, true); + expect(result.passwordUpdate, '2020-10-15T06:38:00.000+00:00'); + expect(result.email, 'john@appwrite.io'); + expect(result.phone, '+4930901820'); + expect(result.emailVerification, true); + expect(result.phoneVerification, true); + expect(result.prefs.data, {"data": {}}); + }); + }); +} diff --git a/test/src/models/variable_list_test.dart b/test/src/models/variable_list_test.dart new file mode 100644 index 00000000..55e8f4ab --- /dev/null +++ b/test/src/models/variable_list_test.dart @@ -0,0 +1,20 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('VariableList', () { + + test('model', () { + final model = VariableList( + total: 5, + variables: [], + ); + + final map = model.toMap(); + final result = VariableList.fromMap(map); + + expect(result.total, 5); + expect(result.variables, []); + }); + }); +} diff --git a/test/src/models/variable_test.dart b/test/src/models/variable_test.dart new file mode 100644 index 00000000..dfda29cb --- /dev/null +++ b/test/src/models/variable_test.dart @@ -0,0 +1,28 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('Variable', () { + + test('model', () { + final model = Variable( + $id: '5e5ea5c16897e', + $createdAt: '2020-10-15T06:38:00.000+00:00', + $updatedAt: '2020-10-15T06:38:00.000+00:00', + key: 'API_KEY', + value: 'myPa\$\$word1', + functionId: '5e5ea5c16897e', + ); + + final map = model.toMap(); + final result = Variable.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.key, 'API_KEY'); + expect(result.value, 'myPa\$\$word1'); + expect(result.functionId, '5e5ea5c16897e'); + }); + }); +} diff --git a/test/src/response_test.dart b/test/src/response_test.dart new file mode 100644 index 00000000..8accb45f --- /dev/null +++ b/test/src/response_test.dart @@ -0,0 +1,18 @@ +import 'package:dart_appwrite/src/response.dart'; +import 'package:test/test.dart'; + +void main() { + group('toString()', () { + test('with a string', () { + final response = Response(data: 'string'); + + expect(response.toString(), 'string'); + }); + + test('with a map', () { + final response = Response(data: {'x': 1}); + + expect(response.toString(), '{"x":1}'); + }); + }); +} \ No newline at end of file diff --git a/test/src/upload_progress_test.dart b/test/src/upload_progress_test.dart new file mode 100644 index 00000000..ba498ad3 --- /dev/null +++ b/test/src/upload_progress_test.dart @@ -0,0 +1,90 @@ +import 'dart:convert'; +import 'package:test/test.dart'; +import 'package:dart_appwrite/src/upload_progress.dart'; + +void main() { + group('UploadProgress', () { + final id = '12345'; + final progress = 0.75; + final sizeUploaded = 1024; + final chunksTotal = 10; + final chunksUploaded = 5; + final progressMap = { + "\$id": id, + "progress": progress, + "sizeUploaded": sizeUploaded, + "chunksTotal": chunksTotal, + "chunksUploaded": chunksUploaded + }; + final uploadProgress = UploadProgress( + $id: id, + progress: progress, + sizeUploaded: sizeUploaded, + chunksTotal: chunksTotal, + chunksUploaded: chunksUploaded, + ); + + test('fromMap should create an instance from a map', () { + final result = UploadProgress.fromMap(progressMap); + + expect(result.$id, equals(id)); + expect(result.progress, equals(progress)); + expect(result.sizeUploaded, equals(sizeUploaded)); + expect(result.chunksTotal, equals(chunksTotal)); + expect(result.chunksUploaded, equals(chunksUploaded)); + }); + + test('toMap should return a map representation of the progress', () { + final result = uploadProgress.toMap(); + + expect(result, equals(progressMap)); + }); + + test('toJson and fromJson should convert to/from JSON', () { + final jsonString = uploadProgress.toJson(); + + final result = UploadProgress.fromJson(jsonString); + + expect(result.$id, equals(id)); + expect(result.progress, equals(progress)); + expect(result.sizeUploaded, equals(sizeUploaded)); + expect(result.chunksTotal, equals(chunksTotal)); + expect(result.chunksUploaded, equals(chunksUploaded)); + }); + + test('toString should return a string representation of the progress', () { + final expectedString = + 'UploadProgress(\$id: $id, progress: $progress, sizeUploaded: $sizeUploaded, chunksTotal: $chunksTotal, chunksUploaded: $chunksUploaded)'; + final resultString = uploadProgress.toString(); + + expect(resultString, equals(expectedString)); + }); + + test('equality operator should compare two instances', () { + final uploadProgress2 = UploadProgress( + $id: id, + progress: progress, + sizeUploaded: sizeUploaded, + chunksTotal: chunksTotal, + chunksUploaded: chunksUploaded, + ); + + expect(uploadProgress == uploadProgress2, isTrue); + }); + + test('hashCode should return a unique hash value', () { + final hashCode1 = uploadProgress.hashCode; + + final uploadProgress2 = UploadProgress( + $id: id, + progress: progress, + sizeUploaded: sizeUploaded, + chunksTotal: chunksTotal, + chunksUploaded: chunksUploaded, + ); + final hashCode2 = uploadProgress2.hashCode; + + expect(hashCode1, equals(hashCode2)); + }); + }); +}