From 43d9c416a352e547911e96d7966b08570742ceb8 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Fri, 11 Jun 2021 12:44:30 +0530 Subject: [PATCH] feat: added iOS platform to origin validator --- .../.github/workflows/publish.yml | 53 ++ app/sdks/client-android/.gitignore | 12 + app/sdks/client-android/CHANGELOG.md | 1 + app/sdks/client-android/LICENSE.md | 12 + app/sdks/client-android/README.md | 157 +++++ app/sdks/client-android/build.gradle | 36 + .../account/create-anonymous-session.md | 10 + .../docs/examples/account/create-j-w-t.md | 10 + .../examples/account/create-o-auth2session.md | 10 + .../docs/examples/account/create-recovery.md | 10 + .../docs/examples/account/create-session.md | 10 + .../examples/account/create-verification.md | 10 + .../docs/examples/account/create.md | 10 + .../docs/examples/account/delete-session.md | 10 + .../docs/examples/account/delete-sessions.md | 10 + .../docs/examples/account/delete.md | 10 + .../docs/examples/account/get-logs.md | 10 + .../docs/examples/account/get-prefs.md | 10 + .../docs/examples/account/get-sessions.md | 10 + .../docs/examples/account/get.md | 10 + .../docs/examples/account/update-email.md | 10 + .../docs/examples/account/update-name.md | 10 + .../docs/examples/account/update-password.md | 10 + .../docs/examples/account/update-prefs.md | 10 + .../docs/examples/account/update-recovery.md | 10 + .../examples/account/update-verification.md | 10 + .../docs/examples/avatars/get-browser.md | 10 + .../docs/examples/avatars/get-credit-card.md | 10 + .../docs/examples/avatars/get-favicon.md | 10 + .../docs/examples/avatars/get-flag.md | 10 + .../docs/examples/avatars/get-image.md | 10 + .../docs/examples/avatars/get-initials.md | 10 + .../docs/examples/avatars/get-q-r.md | 10 + .../docs/examples/database/create-document.md | 10 + .../docs/examples/database/delete-document.md | 10 + .../docs/examples/database/get-document.md | 10 + .../docs/examples/database/list-documents.md | 10 + .../docs/examples/database/update-document.md | 10 + .../examples/functions/create-execution.md | 10 + .../docs/examples/functions/get-execution.md | 10 + .../examples/functions/list-executions.md | 10 + .../docs/examples/locale/get-continents.md | 10 + .../docs/examples/locale/get-countries-e-u.md | 10 + .../examples/locale/get-countries-phones.md | 10 + .../docs/examples/locale/get-countries.md | 10 + .../docs/examples/locale/get-currencies.md | 10 + .../docs/examples/locale/get-languages.md | 10 + .../docs/examples/locale/get.md | 10 + .../docs/examples/storage/create-file.md | 10 + .../docs/examples/storage/delete-file.md | 10 + .../examples/storage/get-file-download.md | 10 + .../docs/examples/storage/get-file-preview.md | 10 + .../docs/examples/storage/get-file-view.md | 10 + .../docs/examples/storage/get-file.md | 10 + .../docs/examples/storage/list-files.md | 10 + .../docs/examples/storage/update-file.md | 10 + .../docs/examples/teams/create-membership.md | 10 + .../docs/examples/teams/create.md | 10 + .../docs/examples/teams/delete-membership.md | 10 + .../docs/examples/teams/delete.md | 10 + .../docs/examples/teams/get-memberships.md | 10 + .../client-android/docs/examples/teams/get.md | 10 + .../docs/examples/teams/list.md | 10 + .../examples/teams/update-membership-roles.md | 10 + .../teams/update-membership-status.md | 10 + .../docs/examples/teams/update.md | 10 + app/sdks/client-android/example/.gitignore | 1 + app/sdks/client-android/example/build.gradle | 59 ++ .../example/src/main/AndroidManifest.xml | 20 + .../java/io/appwrite/android/MainActivity.kt | 23 + .../android/ui/accounts/AccountsFragment.kt | 69 ++ .../android/ui/accounts/AccountsViewModel.kt | 96 +++ .../java/io/appwrite/android/utils/Client.kt | 20 + .../java/io/appwrite/android/utils/Event.kt | 27 + .../res/drawable/ic_launcher_background.xml | 170 +++++ .../res/drawable/ic_launcher_foreground.xml | 30 + .../src/main/res/layout/activity_main.xml | 15 + .../src/main/res/layout/fragment_account.xml | 124 ++++ .../res/mipmap-anydpi-v26/ic_launcher.xml | 5 + .../mipmap-anydpi-v26/ic_launcher_round.xml | 5 + .../example/src/main/res/values/colors.xml | 10 + .../example/src/main/res/values/strings.xml | 3 + .../example/src/main/res/values/themes.xml | 16 + app/sdks/client-android/gradle.properties | 19 + .../gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 54329 bytes .../gradle/wrapper/gradle-wrapper.properties | 6 + app/sdks/client-android/gradlew | 172 +++++ app/sdks/client-android/gradlew.bat | 84 +++ app/sdks/client-android/library/.gitignore | 1 + app/sdks/client-android/library/build.gradle | 77 +++ .../client-android/library/example/README.md | 0 .../library/src/main/AndroidManifest.xml | 8 + .../src/main/java/io/appwrite/Client.kt | 259 ++++++++ .../main/java/io/appwrite/KeepAliveService.kt | 14 + .../main/java/io/appwrite/WebAuthComponent.kt | 100 +++ .../appwrite/exceptions/AppwriteException.kt | 9 + .../io/appwrite/extensions/JsonExtensions.kt | 12 + .../src/main/java/io/appwrite/models/Error.kt | 6 + .../main/java/io/appwrite/services/Account.kt | 626 ++++++++++++++++++ .../main/java/io/appwrite/services/Avatars.kt | 241 +++++++ .../java/io/appwrite/services/BaseService.kt | 5 + .../java/io/appwrite/services/Database.kt | 196 ++++++ .../java/io/appwrite/services/Functions.kt | 107 +++ .../main/java/io/appwrite/services/Locale.kt | 171 +++++ .../main/java/io/appwrite/services/Storage.kt | 264 ++++++++ .../main/java/io/appwrite/services/Teams.kt | 332 ++++++++++ .../io/appwrite/views/CallbackActivity.kt | 20 + .../scripts/publish-config.gradle | 37 ++ .../scripts/publish-module.gradle | 84 +++ app/sdks/client-android/settings.gradle | 3 + app/tasks/sdks.php | 4 +- composer.json | 2 +- composer.lock | 224 ++++--- .../account/create-anonymous-session.md | 10 + .../examples/account/create-j-w-t.md | 10 + .../examples/account/create-o-auth2session.md | 10 + .../examples/account/create-recovery.md | 10 + .../examples/account/create-session.md | 10 + .../examples/account/create-verification.md | 10 + .../client-android/examples/account/create.md | 10 + .../examples/account/delete-session.md | 10 + .../examples/account/delete-sessions.md | 10 + .../client-android/examples/account/delete.md | 10 + .../examples/account/get-logs.md | 10 + .../examples/account/get-prefs.md | 10 + .../examples/account/get-sessions.md | 10 + .../client-android/examples/account/get.md | 10 + .../examples/account/update-email.md | 10 + .../examples/account/update-name.md | 10 + .../examples/account/update-password.md | 10 + .../examples/account/update-prefs.md | 10 + .../examples/account/update-recovery.md | 10 + .../examples/account/update-verification.md | 10 + .../examples/avatars/get-browser.md | 10 + .../examples/avatars/get-credit-card.md | 10 + .../examples/avatars/get-favicon.md | 10 + .../examples/avatars/get-flag.md | 10 + .../examples/avatars/get-image.md | 10 + .../examples/avatars/get-initials.md | 10 + .../examples/avatars/get-q-r.md | 10 + .../examples/database/create-document.md | 10 + .../examples/database/delete-document.md | 10 + .../examples/database/get-document.md | 10 + .../examples/database/list-documents.md | 10 + .../examples/database/update-document.md | 10 + .../examples/functions/create-execution.md | 10 + .../examples/functions/get-execution.md | 10 + .../examples/functions/list-executions.md | 10 + .../examples/locale/get-continents.md | 10 + .../examples/locale/get-countries-e-u.md | 10 + .../examples/locale/get-countries-phones.md | 10 + .../examples/locale/get-countries.md | 10 + .../examples/locale/get-currencies.md | 10 + .../examples/locale/get-languages.md | 10 + .../client-android/examples/locale/get.md | 10 + .../examples/storage/create-file.md | 10 + .../examples/storage/delete-file.md | 10 + .../examples/storage/get-file-download.md | 10 + .../examples/storage/get-file-preview.md | 10 + .../examples/storage/get-file-view.md | 10 + .../examples/storage/get-file.md | 10 + .../examples/storage/list-files.md | 10 + .../examples/storage/update-file.md | 10 + .../examples/teams/create-membership.md | 10 + .../client-android/examples/teams/create.md | 10 + .../examples/teams/delete-membership.md | 10 + .../client-android/examples/teams/delete.md | 10 + .../examples/teams/get-memberships.md | 10 + .../client-android/examples/teams/get.md | 10 + .../client-android/examples/teams/list.md | 10 + .../examples/teams/update-membership-roles.md | 10 + .../teams/update-membership-status.md | 10 + .../client-android/examples/teams/update.md | 10 + src/Appwrite/Network/Validator/Origin.php | 2 + 174 files changed, 5169 insertions(+), 80 deletions(-) create mode 100644 app/sdks/client-android/.github/workflows/publish.yml create mode 100644 app/sdks/client-android/.gitignore create mode 100644 app/sdks/client-android/CHANGELOG.md create mode 100644 app/sdks/client-android/LICENSE.md create mode 100644 app/sdks/client-android/README.md create mode 100644 app/sdks/client-android/build.gradle create mode 100644 app/sdks/client-android/docs/examples/account/create-anonymous-session.md create mode 100644 app/sdks/client-android/docs/examples/account/create-j-w-t.md create mode 100644 app/sdks/client-android/docs/examples/account/create-o-auth2session.md create mode 100644 app/sdks/client-android/docs/examples/account/create-recovery.md create mode 100644 app/sdks/client-android/docs/examples/account/create-session.md create mode 100644 app/sdks/client-android/docs/examples/account/create-verification.md create mode 100644 app/sdks/client-android/docs/examples/account/create.md create mode 100644 app/sdks/client-android/docs/examples/account/delete-session.md create mode 100644 app/sdks/client-android/docs/examples/account/delete-sessions.md create mode 100644 app/sdks/client-android/docs/examples/account/delete.md create mode 100644 app/sdks/client-android/docs/examples/account/get-logs.md create mode 100644 app/sdks/client-android/docs/examples/account/get-prefs.md create mode 100644 app/sdks/client-android/docs/examples/account/get-sessions.md create mode 100644 app/sdks/client-android/docs/examples/account/get.md create mode 100644 app/sdks/client-android/docs/examples/account/update-email.md create mode 100644 app/sdks/client-android/docs/examples/account/update-name.md create mode 100644 app/sdks/client-android/docs/examples/account/update-password.md create mode 100644 app/sdks/client-android/docs/examples/account/update-prefs.md create mode 100644 app/sdks/client-android/docs/examples/account/update-recovery.md create mode 100644 app/sdks/client-android/docs/examples/account/update-verification.md create mode 100644 app/sdks/client-android/docs/examples/avatars/get-browser.md create mode 100644 app/sdks/client-android/docs/examples/avatars/get-credit-card.md create mode 100644 app/sdks/client-android/docs/examples/avatars/get-favicon.md create mode 100644 app/sdks/client-android/docs/examples/avatars/get-flag.md create mode 100644 app/sdks/client-android/docs/examples/avatars/get-image.md create mode 100644 app/sdks/client-android/docs/examples/avatars/get-initials.md create mode 100644 app/sdks/client-android/docs/examples/avatars/get-q-r.md create mode 100644 app/sdks/client-android/docs/examples/database/create-document.md create mode 100644 app/sdks/client-android/docs/examples/database/delete-document.md create mode 100644 app/sdks/client-android/docs/examples/database/get-document.md create mode 100644 app/sdks/client-android/docs/examples/database/list-documents.md create mode 100644 app/sdks/client-android/docs/examples/database/update-document.md create mode 100644 app/sdks/client-android/docs/examples/functions/create-execution.md create mode 100644 app/sdks/client-android/docs/examples/functions/get-execution.md create mode 100644 app/sdks/client-android/docs/examples/functions/list-executions.md create mode 100644 app/sdks/client-android/docs/examples/locale/get-continents.md create mode 100644 app/sdks/client-android/docs/examples/locale/get-countries-e-u.md create mode 100644 app/sdks/client-android/docs/examples/locale/get-countries-phones.md create mode 100644 app/sdks/client-android/docs/examples/locale/get-countries.md create mode 100644 app/sdks/client-android/docs/examples/locale/get-currencies.md create mode 100644 app/sdks/client-android/docs/examples/locale/get-languages.md create mode 100644 app/sdks/client-android/docs/examples/locale/get.md create mode 100644 app/sdks/client-android/docs/examples/storage/create-file.md create mode 100644 app/sdks/client-android/docs/examples/storage/delete-file.md create mode 100644 app/sdks/client-android/docs/examples/storage/get-file-download.md create mode 100644 app/sdks/client-android/docs/examples/storage/get-file-preview.md create mode 100644 app/sdks/client-android/docs/examples/storage/get-file-view.md create mode 100644 app/sdks/client-android/docs/examples/storage/get-file.md create mode 100644 app/sdks/client-android/docs/examples/storage/list-files.md create mode 100644 app/sdks/client-android/docs/examples/storage/update-file.md create mode 100644 app/sdks/client-android/docs/examples/teams/create-membership.md create mode 100644 app/sdks/client-android/docs/examples/teams/create.md create mode 100644 app/sdks/client-android/docs/examples/teams/delete-membership.md create mode 100644 app/sdks/client-android/docs/examples/teams/delete.md create mode 100644 app/sdks/client-android/docs/examples/teams/get-memberships.md create mode 100644 app/sdks/client-android/docs/examples/teams/get.md create mode 100644 app/sdks/client-android/docs/examples/teams/list.md create mode 100644 app/sdks/client-android/docs/examples/teams/update-membership-roles.md create mode 100644 app/sdks/client-android/docs/examples/teams/update-membership-status.md create mode 100644 app/sdks/client-android/docs/examples/teams/update.md create mode 100644 app/sdks/client-android/example/.gitignore create mode 100644 app/sdks/client-android/example/build.gradle create mode 100644 app/sdks/client-android/example/src/main/AndroidManifest.xml create mode 100644 app/sdks/client-android/example/src/main/java/io/appwrite/android/MainActivity.kt create mode 100644 app/sdks/client-android/example/src/main/java/io/appwrite/android/ui/accounts/AccountsFragment.kt create mode 100644 app/sdks/client-android/example/src/main/java/io/appwrite/android/ui/accounts/AccountsViewModel.kt create mode 100644 app/sdks/client-android/example/src/main/java/io/appwrite/android/utils/Client.kt create mode 100644 app/sdks/client-android/example/src/main/java/io/appwrite/android/utils/Event.kt create mode 100644 app/sdks/client-android/example/src/main/res/drawable/ic_launcher_background.xml create mode 100644 app/sdks/client-android/example/src/main/res/drawable/ic_launcher_foreground.xml create mode 100644 app/sdks/client-android/example/src/main/res/layout/activity_main.xml create mode 100644 app/sdks/client-android/example/src/main/res/layout/fragment_account.xml create mode 100644 app/sdks/client-android/example/src/main/res/mipmap-anydpi-v26/ic_launcher.xml create mode 100644 app/sdks/client-android/example/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml create mode 100644 app/sdks/client-android/example/src/main/res/values/colors.xml create mode 100644 app/sdks/client-android/example/src/main/res/values/strings.xml create mode 100644 app/sdks/client-android/example/src/main/res/values/themes.xml create mode 100644 app/sdks/client-android/gradle.properties create mode 100644 app/sdks/client-android/gradle/wrapper/gradle-wrapper.jar create mode 100644 app/sdks/client-android/gradle/wrapper/gradle-wrapper.properties create mode 100644 app/sdks/client-android/gradlew create mode 100644 app/sdks/client-android/gradlew.bat create mode 100644 app/sdks/client-android/library/.gitignore create mode 100644 app/sdks/client-android/library/build.gradle create mode 100644 app/sdks/client-android/library/example/README.md create mode 100644 app/sdks/client-android/library/src/main/AndroidManifest.xml create mode 100644 app/sdks/client-android/library/src/main/java/io/appwrite/Client.kt create mode 100644 app/sdks/client-android/library/src/main/java/io/appwrite/KeepAliveService.kt create mode 100644 app/sdks/client-android/library/src/main/java/io/appwrite/WebAuthComponent.kt create mode 100644 app/sdks/client-android/library/src/main/java/io/appwrite/exceptions/AppwriteException.kt create mode 100644 app/sdks/client-android/library/src/main/java/io/appwrite/extensions/JsonExtensions.kt create mode 100644 app/sdks/client-android/library/src/main/java/io/appwrite/models/Error.kt create mode 100644 app/sdks/client-android/library/src/main/java/io/appwrite/services/Account.kt create mode 100644 app/sdks/client-android/library/src/main/java/io/appwrite/services/Avatars.kt create mode 100644 app/sdks/client-android/library/src/main/java/io/appwrite/services/BaseService.kt create mode 100644 app/sdks/client-android/library/src/main/java/io/appwrite/services/Database.kt create mode 100644 app/sdks/client-android/library/src/main/java/io/appwrite/services/Functions.kt create mode 100644 app/sdks/client-android/library/src/main/java/io/appwrite/services/Locale.kt create mode 100644 app/sdks/client-android/library/src/main/java/io/appwrite/services/Storage.kt create mode 100644 app/sdks/client-android/library/src/main/java/io/appwrite/services/Teams.kt create mode 100644 app/sdks/client-android/library/src/main/java/io/appwrite/views/CallbackActivity.kt create mode 100644 app/sdks/client-android/scripts/publish-config.gradle create mode 100644 app/sdks/client-android/scripts/publish-module.gradle create mode 100644 app/sdks/client-android/settings.gradle create mode 100644 docs/examples/0.8.x/client-android/examples/account/create-anonymous-session.md create mode 100644 docs/examples/0.8.x/client-android/examples/account/create-j-w-t.md create mode 100644 docs/examples/0.8.x/client-android/examples/account/create-o-auth2session.md create mode 100644 docs/examples/0.8.x/client-android/examples/account/create-recovery.md create mode 100644 docs/examples/0.8.x/client-android/examples/account/create-session.md create mode 100644 docs/examples/0.8.x/client-android/examples/account/create-verification.md create mode 100644 docs/examples/0.8.x/client-android/examples/account/create.md create mode 100644 docs/examples/0.8.x/client-android/examples/account/delete-session.md create mode 100644 docs/examples/0.8.x/client-android/examples/account/delete-sessions.md create mode 100644 docs/examples/0.8.x/client-android/examples/account/delete.md create mode 100644 docs/examples/0.8.x/client-android/examples/account/get-logs.md create mode 100644 docs/examples/0.8.x/client-android/examples/account/get-prefs.md create mode 100644 docs/examples/0.8.x/client-android/examples/account/get-sessions.md create mode 100644 docs/examples/0.8.x/client-android/examples/account/get.md create mode 100644 docs/examples/0.8.x/client-android/examples/account/update-email.md create mode 100644 docs/examples/0.8.x/client-android/examples/account/update-name.md create mode 100644 docs/examples/0.8.x/client-android/examples/account/update-password.md create mode 100644 docs/examples/0.8.x/client-android/examples/account/update-prefs.md create mode 100644 docs/examples/0.8.x/client-android/examples/account/update-recovery.md create mode 100644 docs/examples/0.8.x/client-android/examples/account/update-verification.md create mode 100644 docs/examples/0.8.x/client-android/examples/avatars/get-browser.md create mode 100644 docs/examples/0.8.x/client-android/examples/avatars/get-credit-card.md create mode 100644 docs/examples/0.8.x/client-android/examples/avatars/get-favicon.md create mode 100644 docs/examples/0.8.x/client-android/examples/avatars/get-flag.md create mode 100644 docs/examples/0.8.x/client-android/examples/avatars/get-image.md create mode 100644 docs/examples/0.8.x/client-android/examples/avatars/get-initials.md create mode 100644 docs/examples/0.8.x/client-android/examples/avatars/get-q-r.md create mode 100644 docs/examples/0.8.x/client-android/examples/database/create-document.md create mode 100644 docs/examples/0.8.x/client-android/examples/database/delete-document.md create mode 100644 docs/examples/0.8.x/client-android/examples/database/get-document.md create mode 100644 docs/examples/0.8.x/client-android/examples/database/list-documents.md create mode 100644 docs/examples/0.8.x/client-android/examples/database/update-document.md create mode 100644 docs/examples/0.8.x/client-android/examples/functions/create-execution.md create mode 100644 docs/examples/0.8.x/client-android/examples/functions/get-execution.md create mode 100644 docs/examples/0.8.x/client-android/examples/functions/list-executions.md create mode 100644 docs/examples/0.8.x/client-android/examples/locale/get-continents.md create mode 100644 docs/examples/0.8.x/client-android/examples/locale/get-countries-e-u.md create mode 100644 docs/examples/0.8.x/client-android/examples/locale/get-countries-phones.md create mode 100644 docs/examples/0.8.x/client-android/examples/locale/get-countries.md create mode 100644 docs/examples/0.8.x/client-android/examples/locale/get-currencies.md create mode 100644 docs/examples/0.8.x/client-android/examples/locale/get-languages.md create mode 100644 docs/examples/0.8.x/client-android/examples/locale/get.md create mode 100644 docs/examples/0.8.x/client-android/examples/storage/create-file.md create mode 100644 docs/examples/0.8.x/client-android/examples/storage/delete-file.md create mode 100644 docs/examples/0.8.x/client-android/examples/storage/get-file-download.md create mode 100644 docs/examples/0.8.x/client-android/examples/storage/get-file-preview.md create mode 100644 docs/examples/0.8.x/client-android/examples/storage/get-file-view.md create mode 100644 docs/examples/0.8.x/client-android/examples/storage/get-file.md create mode 100644 docs/examples/0.8.x/client-android/examples/storage/list-files.md create mode 100644 docs/examples/0.8.x/client-android/examples/storage/update-file.md create mode 100644 docs/examples/0.8.x/client-android/examples/teams/create-membership.md create mode 100644 docs/examples/0.8.x/client-android/examples/teams/create.md create mode 100644 docs/examples/0.8.x/client-android/examples/teams/delete-membership.md create mode 100644 docs/examples/0.8.x/client-android/examples/teams/delete.md create mode 100644 docs/examples/0.8.x/client-android/examples/teams/get-memberships.md create mode 100644 docs/examples/0.8.x/client-android/examples/teams/get.md create mode 100644 docs/examples/0.8.x/client-android/examples/teams/list.md create mode 100644 docs/examples/0.8.x/client-android/examples/teams/update-membership-roles.md create mode 100644 docs/examples/0.8.x/client-android/examples/teams/update-membership-status.md create mode 100644 docs/examples/0.8.x/client-android/examples/teams/update.md diff --git a/app/sdks/client-android/.github/workflows/publish.yml b/app/sdks/client-android/.github/workflows/publish.yml new file mode 100644 index 000000000..b777478bf --- /dev/null +++ b/app/sdks/client-android/.github/workflows/publish.yml @@ -0,0 +1,53 @@ +name: Publish to Maven Central + +# Run this workflow when a release is created +on: + release: + types: [released] + +jobs: + publish: + name: Release build and publish + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + # Base64 decodes and pipes the GPG key content into the secret file + - name: Prepare environment + env: + GPG_KEY_CONTENTS: ${{ secrets.GPG_KEY_CONTENTS }} + SIGNING_SECRET_KEY_RING_FILE: ${{ secrets.SIGNING_SECRET_KEY_RING_FILE }} + run: | + git fetch --unshallow + sudo bash -c "echo '$GPG_KEY_CONTENTS' | base64 -d > '$SIGNING_SECRET_KEY_RING_FILE'" + chmod +x ./gradlew + + # Builds the release artifacts of the library + - name: Build Release Artifacts + run: ./gradlew --info library:assembleRelease + + # Generates other artifacts (javadocJar is optional) + - name: Generate Source jar + run: ./gradlew javadocJar + + # Runs upload, and then closes & releases the repository + - name: Publish Release Version to MavenCentral + run: | + if ${{ endswith(github.event.release.tag_name, '-SNAPSHOT') }}; then + echo "Publising Snapshot Version ${{ github.event.release.tag_name}} to Snapshot repository" + ./gradlew publishReleasePublicationToSonatypeRepository + else + echo "Publising Release Version ${{ github.event.release.tag_name}} to Staging repository" + ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 closeAndReleaseSonatypeStagingRepository + fi + env: + OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} + OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} + SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} + SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} + SIGNING_SECRET_KEY_RING_FILE: ${{ secrets.SIGNING_SECRET_KEY_RING_FILE }} + SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} \ No newline at end of file diff --git a/app/sdks/client-android/.gitignore b/app/sdks/client-android/.gitignore new file mode 100644 index 000000000..36fb93232 --- /dev/null +++ b/app/sdks/client-android/.gitignore @@ -0,0 +1,12 @@ +*.iml +.gradle +/local.properties +/.idea/* +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +.local.properties +.env +*/build \ No newline at end of file diff --git a/app/sdks/client-android/CHANGELOG.md b/app/sdks/client-android/CHANGELOG.md new file mode 100644 index 000000000..fa4d35e68 --- /dev/null +++ b/app/sdks/client-android/CHANGELOG.md @@ -0,0 +1 @@ +# Change Log \ No newline at end of file diff --git a/app/sdks/client-android/LICENSE.md b/app/sdks/client-android/LICENSE.md new file mode 100644 index 000000000..d73a6e982 --- /dev/null +++ b/app/sdks/client-android/LICENSE.md @@ -0,0 +1,12 @@ +Copyright (c) 2021 Appwrite (https://appwrite.io) and individual contributors. +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + + 3. Neither the name Appwrite nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/app/sdks/client-android/README.md b/app/sdks/client-android/README.md new file mode 100644 index 000000000..87260ade4 --- /dev/null +++ b/app/sdks/client-android/README.md @@ -0,0 +1,157 @@ +# Appwrite Android SDK + +![License](https://img.shields.io/github/license/appwrite/sdk-for-android.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-0.8.0-blue.svg?style=flat-square) +[![Twitter Account](https://img.shields.io/twitter/follow/appwrite_io?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite_io) +[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) + +**This SDK is compatible with Appwrite server version 0.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-android/releases).** + +Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Android SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) + +![Appwrite](https://appwrite.io/images/github.png) + +## Installation + +### Gradle + +Appwrite's Android SDK is hosted on Maven Central. In order to fetch the Appwrite SDK, add this to your root level `build.gradle(.kts)` file: + +```groovy +repositories { + mavenCentral() +} +``` + +If you would like to fetch our SNAPSHOT releases, you need to add the SNAPSHOT maven repository to your `build.gradle(.kts)`: + +```groovy +repositories { + maven { + url "https://s01.oss.sonatype.org/content/repositories/snapshots/" + } +} +``` + +Next, add the dependency to your project's `build.gradle(.kts)` file: + +```groovy +implementation("io.appwrite:sdk-for-android:0.0.0-SNAPSHOT") +``` + +### Maven +Add this to your project's `pom.xml` file: + +```xml + + + io.appwrite + sdk-for-android + 0.0.0-SNAPSHOT + + +``` + + +## Getting Started + +### Add your Android Platform +To initialize your SDK and start interacting with Appwrite services, you need to add a new Android platform to your project. To add a new platform, go to your Appwrite console, select your project (create one if you haven't already), and click the 'Add Platform' button on the project Dashboard. + +From the options, choose to add a new **Android** platform and add your app credentials. + +Add your app name and package name. Your package name is generally the applicationId in your app-level `build.gradle` file. By registering a new platform, you are allowing your app to communicate with the Appwrite API. + +### Registering additional activities +In order to capture the Appwrite OAuth callback url, the following activity needs to be added to your [AndroidManifest.xml](https://github.com/appwrite/playground-for-android/blob/master/app/src/main/AndroidManifest.xml). Be sure to replace the **[PROJECT_ID]** string with your actual Appwrite project ID. You can find your Appwrite project ID in your project settings screen in the console. + +```xml + + + + + + + + + + + + +``` + +### Init your SDK + +

Initialize your SDK with your Appwrite server API endpoint and project ID, which can be found in your project settings page. + +```kotlin +import io.appwrite.Client +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + .setSelfSigned(true) // Remove in production +``` + +Before starting to send any API calls to your new Appwrite instance, make sure your Android emulators has network access to the Appwrite server hostname or IP address. + +When trying to connect to Appwrite from an emulator or a mobile device, localhost is the hostname of the device or emulator and not your local Appwrite instance. You should replace localhost with your private IP. You can also use a service like [ngrok](https://ngrok.com/) to proxy the Appwrite API. + +### Make Your First Request + +

Once your SDK object is set, access any of the Appwrite services and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the [API References](https://appwrite.io/docs) section. + +```kotlin +// Register User +val account = Account(client) +val response = account.create( + "email@example.com", + "password" +) +``` + +### Full Example + +```kotlin +import io.appwrite.Client +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + .setSelfSigned(true) // Remove in production + +val account = Account(client) +val response = account.create( + "email@example.com", + "password" +) +``` + +### Error Handling +The Appwrite Android SDK raises an `AppwriteException` object with `message`, `code` and `response` properties. You can handle any errors by catching `AppwriteException` and present the `message` to the user or handle it yourself based on the provided error information. Below is an example. + +```kotlin +try { + var response = account.create("email@example.com", "password") + Log.d("Appwrite response", response.body?.string()) +} catch(e : AppwriteException) { + Log.e("AppwriteException",e.message.toString()) +} +``` + +### Learn more +You can use following resources to learn more and get help +- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-android) +- 📜 [Appwrite Docs](https://appwrite.io/docs) +- 💬 [Discord Community](https://appwrite.io/discord) +- 🚂 [Appwrite Android Playground](https://github.com/appwrite/playground-for-android) + +## Contribution + +This library is auto-generated by Appwrite custom [SDK Generator](https://github.com/appwrite/sdk-generator). To learn more about how you can help us improve this SDK, please check the [contribution guide](https://github.com/appwrite/sdk-generator/blob/master/CONTRIBUTING.md) before sending a pull-request. + +## License + +Please see the [BSD-3-Clause license](https://raw.githubusercontent.com/appwrite/appwrite/master/LICENSE) file for more information. \ No newline at end of file diff --git a/app/sdks/client-android/build.gradle b/app/sdks/client-android/build.gradle new file mode 100644 index 000000000..650350947 --- /dev/null +++ b/app/sdks/client-android/build.gradle @@ -0,0 +1,36 @@ +apply plugin: 'io.github.gradle-nexus.publish-plugin' + +// Top-level build file where you can add configuration options common to all sub-projects/modules. +buildscript { + ext.kotlin_version = "1.4.31" + version '0.0.0-SNAPSHOT' + repositories { + maven { url "https://plugins.gradle.org/m2/" } + google() + mavenCentral() + } + dependencies { + classpath "com.android.tools.build:gradle:4.2.0" + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath 'io.github.gradle-nexus:publish-plugin:1.1.0' + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + maven { url "https://jitpack.io" } + google() + mavenCentral() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} + + +apply from: "${rootDir}/scripts/publish-config.gradle" + diff --git a/app/sdks/client-android/docs/examples/account/create-anonymous-session.md b/app/sdks/client-android/docs/examples/account/create-anonymous-session.md new file mode 100644 index 000000000..9aa6d9002 --- /dev/null +++ b/app/sdks/client-android/docs/examples/account/create-anonymous-session.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val accountService = Account(client) +val response = accountService.createAnonymousSession() +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/account/create-j-w-t.md b/app/sdks/client-android/docs/examples/account/create-j-w-t.md new file mode 100644 index 000000000..50965da19 --- /dev/null +++ b/app/sdks/client-android/docs/examples/account/create-j-w-t.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val accountService = Account(client) +val response = accountService.createJWT() +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/account/create-o-auth2session.md b/app/sdks/client-android/docs/examples/account/create-o-auth2session.md new file mode 100644 index 000000000..8eaa4aff7 --- /dev/null +++ b/app/sdks/client-android/docs/examples/account/create-o-auth2session.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val accountService = Account(client) +val response = accountService.createOAuth2Session("amazon") +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/account/create-recovery.md b/app/sdks/client-android/docs/examples/account/create-recovery.md new file mode 100644 index 000000000..c43a0e3f7 --- /dev/null +++ b/app/sdks/client-android/docs/examples/account/create-recovery.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val accountService = Account(client) +val response = accountService.createRecovery("email@example.com", "https://example.com") +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/account/create-session.md b/app/sdks/client-android/docs/examples/account/create-session.md new file mode 100644 index 000000000..9940d99e4 --- /dev/null +++ b/app/sdks/client-android/docs/examples/account/create-session.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val accountService = Account(client) +val response = accountService.createSession("email@example.com", "password") +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/account/create-verification.md b/app/sdks/client-android/docs/examples/account/create-verification.md new file mode 100644 index 000000000..cf568233e --- /dev/null +++ b/app/sdks/client-android/docs/examples/account/create-verification.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val accountService = Account(client) +val response = accountService.createVerification("https://example.com") +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/account/create.md b/app/sdks/client-android/docs/examples/account/create.md new file mode 100644 index 000000000..0036d538b --- /dev/null +++ b/app/sdks/client-android/docs/examples/account/create.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val accountService = Account(client) +val response = accountService.create("email@example.com", "password") +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/account/delete-session.md b/app/sdks/client-android/docs/examples/account/delete-session.md new file mode 100644 index 000000000..5bb6aec0f --- /dev/null +++ b/app/sdks/client-android/docs/examples/account/delete-session.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val accountService = Account(client) +val response = accountService.deleteSession("[SESSION_ID]") +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/account/delete-sessions.md b/app/sdks/client-android/docs/examples/account/delete-sessions.md new file mode 100644 index 000000000..4f700bd92 --- /dev/null +++ b/app/sdks/client-android/docs/examples/account/delete-sessions.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val accountService = Account(client) +val response = accountService.deleteSessions() +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/account/delete.md b/app/sdks/client-android/docs/examples/account/delete.md new file mode 100644 index 000000000..c8e779011 --- /dev/null +++ b/app/sdks/client-android/docs/examples/account/delete.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val accountService = Account(client) +val response = accountService.delete() +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/account/get-logs.md b/app/sdks/client-android/docs/examples/account/get-logs.md new file mode 100644 index 000000000..65a7fdf44 --- /dev/null +++ b/app/sdks/client-android/docs/examples/account/get-logs.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val accountService = Account(client) +val response = accountService.getLogs() +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/account/get-prefs.md b/app/sdks/client-android/docs/examples/account/get-prefs.md new file mode 100644 index 000000000..355f89812 --- /dev/null +++ b/app/sdks/client-android/docs/examples/account/get-prefs.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val accountService = Account(client) +val response = accountService.getPrefs() +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/account/get-sessions.md b/app/sdks/client-android/docs/examples/account/get-sessions.md new file mode 100644 index 000000000..4da469aff --- /dev/null +++ b/app/sdks/client-android/docs/examples/account/get-sessions.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val accountService = Account(client) +val response = accountService.getSessions() +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/account/get.md b/app/sdks/client-android/docs/examples/account/get.md new file mode 100644 index 000000000..f5533f5ae --- /dev/null +++ b/app/sdks/client-android/docs/examples/account/get.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val accountService = Account(client) +val response = accountService.get() +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/account/update-email.md b/app/sdks/client-android/docs/examples/account/update-email.md new file mode 100644 index 000000000..d9d10afc2 --- /dev/null +++ b/app/sdks/client-android/docs/examples/account/update-email.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val accountService = Account(client) +val response = accountService.updateEmail("email@example.com", "password") +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/account/update-name.md b/app/sdks/client-android/docs/examples/account/update-name.md new file mode 100644 index 000000000..585416125 --- /dev/null +++ b/app/sdks/client-android/docs/examples/account/update-name.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val accountService = Account(client) +val response = accountService.updateName("[NAME]") +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/account/update-password.md b/app/sdks/client-android/docs/examples/account/update-password.md new file mode 100644 index 000000000..4f4fe7bd1 --- /dev/null +++ b/app/sdks/client-android/docs/examples/account/update-password.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val accountService = Account(client) +val response = accountService.updatePassword("password") +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/account/update-prefs.md b/app/sdks/client-android/docs/examples/account/update-prefs.md new file mode 100644 index 000000000..dcbf4b614 --- /dev/null +++ b/app/sdks/client-android/docs/examples/account/update-prefs.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val accountService = Account(client) +val response = accountService.updatePrefs({}) +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/account/update-recovery.md b/app/sdks/client-android/docs/examples/account/update-recovery.md new file mode 100644 index 000000000..05d04f5e8 --- /dev/null +++ b/app/sdks/client-android/docs/examples/account/update-recovery.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val accountService = Account(client) +val response = accountService.updateRecovery("[USER_ID]", "[SECRET]", "password", "password") +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/account/update-verification.md b/app/sdks/client-android/docs/examples/account/update-verification.md new file mode 100644 index 000000000..f924c3d7a --- /dev/null +++ b/app/sdks/client-android/docs/examples/account/update-verification.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val accountService = Account(client) +val response = accountService.updateVerification("[USER_ID]", "[SECRET]") +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/avatars/get-browser.md b/app/sdks/client-android/docs/examples/avatars/get-browser.md new file mode 100644 index 000000000..642ae8c16 --- /dev/null +++ b/app/sdks/client-android/docs/examples/avatars/get-browser.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Avatars + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val avatarsService = Avatars(client) +val response = avatarsService.getBrowser("aa") +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/avatars/get-credit-card.md b/app/sdks/client-android/docs/examples/avatars/get-credit-card.md new file mode 100644 index 000000000..4fba61f1f --- /dev/null +++ b/app/sdks/client-android/docs/examples/avatars/get-credit-card.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Avatars + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val avatarsService = Avatars(client) +val response = avatarsService.getCreditCard("amex") +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/avatars/get-favicon.md b/app/sdks/client-android/docs/examples/avatars/get-favicon.md new file mode 100644 index 000000000..bef7fd481 --- /dev/null +++ b/app/sdks/client-android/docs/examples/avatars/get-favicon.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Avatars + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val avatarsService = Avatars(client) +val response = avatarsService.getFavicon("https://example.com") +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/avatars/get-flag.md b/app/sdks/client-android/docs/examples/avatars/get-flag.md new file mode 100644 index 000000000..0c4ec2ddd --- /dev/null +++ b/app/sdks/client-android/docs/examples/avatars/get-flag.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Avatars + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val avatarsService = Avatars(client) +val response = avatarsService.getFlag("af") +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/avatars/get-image.md b/app/sdks/client-android/docs/examples/avatars/get-image.md new file mode 100644 index 000000000..8cec3e79a --- /dev/null +++ b/app/sdks/client-android/docs/examples/avatars/get-image.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Avatars + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val avatarsService = Avatars(client) +val response = avatarsService.getImage("https://example.com") +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/avatars/get-initials.md b/app/sdks/client-android/docs/examples/avatars/get-initials.md new file mode 100644 index 000000000..4ddc26332 --- /dev/null +++ b/app/sdks/client-android/docs/examples/avatars/get-initials.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Avatars + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val avatarsService = Avatars(client) +val response = avatarsService.getInitials() +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/avatars/get-q-r.md b/app/sdks/client-android/docs/examples/avatars/get-q-r.md new file mode 100644 index 000000000..57eb76573 --- /dev/null +++ b/app/sdks/client-android/docs/examples/avatars/get-q-r.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Avatars + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val avatarsService = Avatars(client) +val response = avatarsService.getQR("[TEXT]") +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/database/create-document.md b/app/sdks/client-android/docs/examples/database/create-document.md new file mode 100644 index 000000000..95959f567 --- /dev/null +++ b/app/sdks/client-android/docs/examples/database/create-document.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Database + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val databaseService = Database(client) +val response = databaseService.createDocument("[COLLECTION_ID]", {}) +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/database/delete-document.md b/app/sdks/client-android/docs/examples/database/delete-document.md new file mode 100644 index 000000000..6bcaab03d --- /dev/null +++ b/app/sdks/client-android/docs/examples/database/delete-document.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Database + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val databaseService = Database(client) +val response = databaseService.deleteDocument("[COLLECTION_ID]", "[DOCUMENT_ID]") +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/database/get-document.md b/app/sdks/client-android/docs/examples/database/get-document.md new file mode 100644 index 000000000..a71e71c57 --- /dev/null +++ b/app/sdks/client-android/docs/examples/database/get-document.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Database + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val databaseService = Database(client) +val response = databaseService.getDocument("[COLLECTION_ID]", "[DOCUMENT_ID]") +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/database/list-documents.md b/app/sdks/client-android/docs/examples/database/list-documents.md new file mode 100644 index 000000000..0c720e2a5 --- /dev/null +++ b/app/sdks/client-android/docs/examples/database/list-documents.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Database + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val databaseService = Database(client) +val response = databaseService.listDocuments("[COLLECTION_ID]") +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/database/update-document.md b/app/sdks/client-android/docs/examples/database/update-document.md new file mode 100644 index 000000000..cb0f8c9f6 --- /dev/null +++ b/app/sdks/client-android/docs/examples/database/update-document.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Database + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val databaseService = Database(client) +val response = databaseService.updateDocument("[COLLECTION_ID]", "[DOCUMENT_ID]", {}) +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/functions/create-execution.md b/app/sdks/client-android/docs/examples/functions/create-execution.md new file mode 100644 index 000000000..665c3ceb8 --- /dev/null +++ b/app/sdks/client-android/docs/examples/functions/create-execution.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Functions + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val functionsService = Functions(client) +val response = functionsService.createExecution("[FUNCTION_ID]") +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/functions/get-execution.md b/app/sdks/client-android/docs/examples/functions/get-execution.md new file mode 100644 index 000000000..79c365112 --- /dev/null +++ b/app/sdks/client-android/docs/examples/functions/get-execution.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Functions + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val functionsService = Functions(client) +val response = functionsService.getExecution("[FUNCTION_ID]", "[EXECUTION_ID]") +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/functions/list-executions.md b/app/sdks/client-android/docs/examples/functions/list-executions.md new file mode 100644 index 000000000..cfb4beddd --- /dev/null +++ b/app/sdks/client-android/docs/examples/functions/list-executions.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Functions + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val functionsService = Functions(client) +val response = functionsService.listExecutions("[FUNCTION_ID]") +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/locale/get-continents.md b/app/sdks/client-android/docs/examples/locale/get-continents.md new file mode 100644 index 000000000..39db74345 --- /dev/null +++ b/app/sdks/client-android/docs/examples/locale/get-continents.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Locale + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val localeService = Locale(client) +val response = localeService.getContinents() +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/locale/get-countries-e-u.md b/app/sdks/client-android/docs/examples/locale/get-countries-e-u.md new file mode 100644 index 000000000..32222b45c --- /dev/null +++ b/app/sdks/client-android/docs/examples/locale/get-countries-e-u.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Locale + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val localeService = Locale(client) +val response = localeService.getCountriesEU() +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/locale/get-countries-phones.md b/app/sdks/client-android/docs/examples/locale/get-countries-phones.md new file mode 100644 index 000000000..3dcdac19e --- /dev/null +++ b/app/sdks/client-android/docs/examples/locale/get-countries-phones.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Locale + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val localeService = Locale(client) +val response = localeService.getCountriesPhones() +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/locale/get-countries.md b/app/sdks/client-android/docs/examples/locale/get-countries.md new file mode 100644 index 000000000..437afe1bb --- /dev/null +++ b/app/sdks/client-android/docs/examples/locale/get-countries.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Locale + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val localeService = Locale(client) +val response = localeService.getCountries() +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/locale/get-currencies.md b/app/sdks/client-android/docs/examples/locale/get-currencies.md new file mode 100644 index 000000000..38879dab4 --- /dev/null +++ b/app/sdks/client-android/docs/examples/locale/get-currencies.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Locale + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val localeService = Locale(client) +val response = localeService.getCurrencies() +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/locale/get-languages.md b/app/sdks/client-android/docs/examples/locale/get-languages.md new file mode 100644 index 000000000..78c3bcaef --- /dev/null +++ b/app/sdks/client-android/docs/examples/locale/get-languages.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Locale + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val localeService = Locale(client) +val response = localeService.getLanguages() +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/locale/get.md b/app/sdks/client-android/docs/examples/locale/get.md new file mode 100644 index 000000000..6552b21de --- /dev/null +++ b/app/sdks/client-android/docs/examples/locale/get.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Locale + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val localeService = Locale(client) +val response = localeService.get() +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/storage/create-file.md b/app/sdks/client-android/docs/examples/storage/create-file.md new file mode 100644 index 000000000..9e2d8c53b --- /dev/null +++ b/app/sdks/client-android/docs/examples/storage/create-file.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Storage + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val storageService = Storage(client) +val response = storageService.createFile(new File("./path-to-files/image.jpg")) +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/storage/delete-file.md b/app/sdks/client-android/docs/examples/storage/delete-file.md new file mode 100644 index 000000000..87479bd08 --- /dev/null +++ b/app/sdks/client-android/docs/examples/storage/delete-file.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Storage + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val storageService = Storage(client) +val response = storageService.deleteFile("[FILE_ID]") +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/storage/get-file-download.md b/app/sdks/client-android/docs/examples/storage/get-file-download.md new file mode 100644 index 000000000..25681e1b0 --- /dev/null +++ b/app/sdks/client-android/docs/examples/storage/get-file-download.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Storage + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val storageService = Storage(client) +val response = storageService.getFileDownload("[FILE_ID]") +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/storage/get-file-preview.md b/app/sdks/client-android/docs/examples/storage/get-file-preview.md new file mode 100644 index 000000000..a3c317c31 --- /dev/null +++ b/app/sdks/client-android/docs/examples/storage/get-file-preview.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Storage + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val storageService = Storage(client) +val response = storageService.getFilePreview("[FILE_ID]") +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/storage/get-file-view.md b/app/sdks/client-android/docs/examples/storage/get-file-view.md new file mode 100644 index 000000000..d2d0f4534 --- /dev/null +++ b/app/sdks/client-android/docs/examples/storage/get-file-view.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Storage + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val storageService = Storage(client) +val response = storageService.getFileView("[FILE_ID]") +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/storage/get-file.md b/app/sdks/client-android/docs/examples/storage/get-file.md new file mode 100644 index 000000000..2d0f0d139 --- /dev/null +++ b/app/sdks/client-android/docs/examples/storage/get-file.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Storage + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val storageService = Storage(client) +val response = storageService.getFile("[FILE_ID]") +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/storage/list-files.md b/app/sdks/client-android/docs/examples/storage/list-files.md new file mode 100644 index 000000000..09327879f --- /dev/null +++ b/app/sdks/client-android/docs/examples/storage/list-files.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Storage + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val storageService = Storage(client) +val response = storageService.listFiles() +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/storage/update-file.md b/app/sdks/client-android/docs/examples/storage/update-file.md new file mode 100644 index 000000000..a9d61aabc --- /dev/null +++ b/app/sdks/client-android/docs/examples/storage/update-file.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Storage + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val storageService = Storage(client) +val response = storageService.updateFile("[FILE_ID]", List(), List()) +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/teams/create-membership.md b/app/sdks/client-android/docs/examples/teams/create-membership.md new file mode 100644 index 000000000..c1325b85b --- /dev/null +++ b/app/sdks/client-android/docs/examples/teams/create-membership.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Teams + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val teamsService = Teams(client) +val response = teamsService.createMembership("[TEAM_ID]", "email@example.com", List(), "https://example.com") +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/teams/create.md b/app/sdks/client-android/docs/examples/teams/create.md new file mode 100644 index 000000000..bd72a0584 --- /dev/null +++ b/app/sdks/client-android/docs/examples/teams/create.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Teams + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val teamsService = Teams(client) +val response = teamsService.create("[NAME]") +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/teams/delete-membership.md b/app/sdks/client-android/docs/examples/teams/delete-membership.md new file mode 100644 index 000000000..58e29e598 --- /dev/null +++ b/app/sdks/client-android/docs/examples/teams/delete-membership.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Teams + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val teamsService = Teams(client) +val response = teamsService.deleteMembership("[TEAM_ID]", "[MEMBERSHIP_ID]") +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/teams/delete.md b/app/sdks/client-android/docs/examples/teams/delete.md new file mode 100644 index 000000000..11db6a81b --- /dev/null +++ b/app/sdks/client-android/docs/examples/teams/delete.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Teams + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val teamsService = Teams(client) +val response = teamsService.delete("[TEAM_ID]") +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/teams/get-memberships.md b/app/sdks/client-android/docs/examples/teams/get-memberships.md new file mode 100644 index 000000000..32db0b880 --- /dev/null +++ b/app/sdks/client-android/docs/examples/teams/get-memberships.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Teams + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val teamsService = Teams(client) +val response = teamsService.getMemberships("[TEAM_ID]") +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/teams/get.md b/app/sdks/client-android/docs/examples/teams/get.md new file mode 100644 index 000000000..eb2451f66 --- /dev/null +++ b/app/sdks/client-android/docs/examples/teams/get.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Teams + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val teamsService = Teams(client) +val response = teamsService.get("[TEAM_ID]") +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/teams/list.md b/app/sdks/client-android/docs/examples/teams/list.md new file mode 100644 index 000000000..5da9925e4 --- /dev/null +++ b/app/sdks/client-android/docs/examples/teams/list.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Teams + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val teamsService = Teams(client) +val response = teamsService.list() +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/teams/update-membership-roles.md b/app/sdks/client-android/docs/examples/teams/update-membership-roles.md new file mode 100644 index 000000000..17904fa12 --- /dev/null +++ b/app/sdks/client-android/docs/examples/teams/update-membership-roles.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Teams + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val teamsService = Teams(client) +val response = teamsService.updateMembershipRoles("[TEAM_ID]", "[MEMBERSHIP_ID]", List()) +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/teams/update-membership-status.md b/app/sdks/client-android/docs/examples/teams/update-membership-status.md new file mode 100644 index 000000000..dca6a1ba1 --- /dev/null +++ b/app/sdks/client-android/docs/examples/teams/update-membership-status.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Teams + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val teamsService = Teams(client) +val response = teamsService.updateMembershipStatus("[TEAM_ID]", "[MEMBERSHIP_ID]", "[USER_ID]", "[SECRET]") +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/docs/examples/teams/update.md b/app/sdks/client-android/docs/examples/teams/update.md new file mode 100644 index 000000000..ab4cfcc39 --- /dev/null +++ b/app/sdks/client-android/docs/examples/teams/update.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Teams + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val teamsService = Teams(client) +val response = teamsService.update("[TEAM_ID]", "[NAME]") +val json = response.body?.string() \ No newline at end of file diff --git a/app/sdks/client-android/example/.gitignore b/app/sdks/client-android/example/.gitignore new file mode 100644 index 000000000..42afabfd2 --- /dev/null +++ b/app/sdks/client-android/example/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/app/sdks/client-android/example/build.gradle b/app/sdks/client-android/example/build.gradle new file mode 100644 index 000000000..6057427c4 --- /dev/null +++ b/app/sdks/client-android/example/build.gradle @@ -0,0 +1,59 @@ +plugins { + id 'com.android.application' + id 'kotlin-android' +} + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.3" + + defaultConfig { + applicationId "io.appwrite.android" + minSdkVersion 21 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildFeatures { + dataBinding true + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = '1.8' + } +} + +dependencies { + + implementation project(path: ':library') + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation 'androidx.core:core-ktx:1.5.0' + implementation 'androidx.appcompat:appcompat:1.3.0' + implementation 'com.google.android.material:material:1.3.0' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5' + implementation "androidx.fragment:fragment-ktx:1.3.2" + implementation 'androidx.navigation:navigation-ui-ktx:2.3.5' + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1' + implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5' + implementation 'androidx.navigation:navigation-ui-ktx:2.3.5' + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.3" + testImplementation 'junit:junit:4.+' + androidTestImplementation 'androidx.test.ext:junit:1.1.2' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' +} \ No newline at end of file diff --git a/app/sdks/client-android/example/src/main/AndroidManifest.xml b/app/sdks/client-android/example/src/main/AndroidManifest.xml new file mode 100644 index 000000000..4b65549de --- /dev/null +++ b/app/sdks/client-android/example/src/main/AndroidManifest.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/sdks/client-android/example/src/main/java/io/appwrite/android/MainActivity.kt b/app/sdks/client-android/example/src/main/java/io/appwrite/android/MainActivity.kt new file mode 100644 index 000000000..2fe5ae9ce --- /dev/null +++ b/app/sdks/client-android/example/src/main/java/io/appwrite/android/MainActivity.kt @@ -0,0 +1,23 @@ +package io.appwrite.android + +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import androidx.fragment.app.add +import androidx.fragment.app.commit +import io.appwrite.android.ui.accounts.AccountsFragment +import io.appwrite.android.utils.Client + +class MainActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + Client.create(applicationContext) + + if (savedInstanceState == null) { + supportFragmentManager.commit { + setReorderingAllowed(true) + add(R.id.fragment_container_view) + } + } + } +} \ No newline at end of file diff --git a/app/sdks/client-android/example/src/main/java/io/appwrite/android/ui/accounts/AccountsFragment.kt b/app/sdks/client-android/example/src/main/java/io/appwrite/android/ui/accounts/AccountsFragment.kt new file mode 100644 index 000000000..746cb7e8f --- /dev/null +++ b/app/sdks/client-android/example/src/main/java/io/appwrite/android/ui/accounts/AccountsFragment.kt @@ -0,0 +1,69 @@ +package io.appwrite.android.ui.accounts + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.Toast +import androidx.activity.ComponentActivity +import androidx.databinding.DataBindingUtil +import androidx.fragment.app.Fragment +import androidx.lifecycle.Observer +import androidx.lifecycle.ViewModelProvider +import io.appwrite.android.R +import io.appwrite.android.databinding.FragmentAccountBinding + + +class AccountsFragment : Fragment() { + + private lateinit var binding: FragmentAccountBinding + private lateinit var viewModel: AccountsViewModel + + override fun onCreateView( + inflater: LayoutInflater , + container: ViewGroup? , + savedInstanceState: Bundle? + ): View? { + viewModel = ViewModelProvider(this).get(AccountsViewModel::class.java) + binding = DataBindingUtil.inflate( + inflater, + R.layout.fragment_account, + container, + false + ) + binding.lifecycleOwner = viewLifecycleOwner + binding.login.setOnClickListener{ + viewModel.onLogin(binding.email.text, binding.password.text) + } + + binding.signup.setOnClickListener{ + viewModel.onSignup(binding.email.text, binding.password.text, binding.name.text) + } + + binding.getUser.setOnClickListener{ + viewModel.getUser() + } + + binding.oAuth.setOnClickListener{ + viewModel.oAuthLogin(activity as ComponentActivity) + } + + binding.logout.setOnClickListener{ + viewModel.logout() + } + + viewModel.error.observe(viewLifecycleOwner, Observer { event -> + event?.getContentIfNotHandled()?.let { // Only proceed if the event has never been handled + Toast.makeText(requireContext(), it.message , Toast.LENGTH_SHORT).show() + } + }) + + viewModel.response.observe(viewLifecycleOwner, Observer { event -> + event?.getContentIfNotHandled()?.let { + binding.responseTV.setText(it) + } + }) + + return binding.root + } +} \ No newline at end of file diff --git a/app/sdks/client-android/example/src/main/java/io/appwrite/android/ui/accounts/AccountsViewModel.kt b/app/sdks/client-android/example/src/main/java/io/appwrite/android/ui/accounts/AccountsViewModel.kt new file mode 100644 index 000000000..2d812e8c0 --- /dev/null +++ b/app/sdks/client-android/example/src/main/java/io/appwrite/android/ui/accounts/AccountsViewModel.kt @@ -0,0 +1,96 @@ +package io.appwrite.android.ui.accounts + +import android.text.Editable +import androidx.activity.ComponentActivity +import androidx.lifecycle.* +import io.appwrite.android.utils.Client.client +import io.appwrite.android.utils.Event +import io.appwrite.exceptions.AppwriteException +import io.appwrite.services.Account +import kotlinx.coroutines.launch +import org.json.JSONObject + + +class AccountsViewModel : ViewModel() { + + private val _error = MutableLiveData>().apply { + value = null + } + val error: LiveData> = _error + + private val _response = MutableLiveData>().apply { + value = null + } + val response: LiveData> = _response + + private val accountService by lazy { + Account(client) + } + + fun onLogin(email: Editable , password : Editable) { + viewModelScope.launch { + try { + var response = accountService.createSession(email.toString(), password.toString()) + var json = response.body?.string() ?: "" + json = JSONObject(json).toString(8) + _response.postValue(Event(json)) + } catch (e: AppwriteException) { + _error.postValue(Event(e)) + } + } + + } + + fun onSignup(email: Editable , password : Editable, name: Editable) { + viewModelScope.launch { + try { + var response = accountService.create(email.toString(), password.toString(), name.toString()) + var json = response.body?.string() ?: "" + json = JSONObject(json).toString(2) + _response.postValue(Event(json)) + } catch (e: AppwriteException) { + _error.postValue(Event(e)) + } + } + + } + + fun oAuthLogin(activity: ComponentActivity) { + viewModelScope.launch { + try { + accountService.createOAuth2Session(activity, "facebook", "appwrite-callback-6070749e6acd4://demo.appwrite.io/auth/oauth2/success", "appwrite-callback-6070749e6acd4://demo.appwrite.io/auth/oauth2/failure") + } catch (e: Exception) { + _error.postValue(Event(e)) + } catch (e: AppwriteException) { + _error.postValue(Event(e)) + } + } + } + + fun getUser() { + viewModelScope.launch { + try { + var response = accountService.get() + var json = response.body?.string() ?: "" + json = JSONObject(json).toString(2) + _response.postValue(Event(json)) + } catch (e: AppwriteException) { + _error.postValue(Event(e)) + } + } + } + + fun logout() { + viewModelScope.launch { + try { + var response = accountService.deleteSession("current") + var json = response.body?.string()?.ifEmpty { "{}" } + json = JSONObject(json).toString(4) + _response.postValue(Event(json)) + } catch (e: AppwriteException) { + _error.postValue(Event(e)) + } + } + } + +} \ No newline at end of file diff --git a/app/sdks/client-android/example/src/main/java/io/appwrite/android/utils/Client.kt b/app/sdks/client-android/example/src/main/java/io/appwrite/android/utils/Client.kt new file mode 100644 index 000000000..66ce68191 --- /dev/null +++ b/app/sdks/client-android/example/src/main/java/io/appwrite/android/utils/Client.kt @@ -0,0 +1,20 @@ +package io.appwrite.android.utils + +import android.content.Context +import io.appwrite.Client + +object Client { + lateinit var client : Client + + fun create(context: Context) { + client = Client(context) + .setEndpoint("https://demo.appwrite.io/v1") + .setProject("6070749e6acd4") + + /* Useful when testing locally */ +// client = Client(context) +// .setEndpoint("https://192.168.1.35/v1") +// .setProject("60bdbc911784e") +// .setSelfSigned(true) + } +} \ No newline at end of file diff --git a/app/sdks/client-android/example/src/main/java/io/appwrite/android/utils/Event.kt b/app/sdks/client-android/example/src/main/java/io/appwrite/android/utils/Event.kt new file mode 100644 index 000000000..a5224794e --- /dev/null +++ b/app/sdks/client-android/example/src/main/java/io/appwrite/android/utils/Event.kt @@ -0,0 +1,27 @@ +package io.appwrite.android.utils + +/** + * Used as a wrapper for data that is exposed via a LiveData that represents an event. + */ +open class Event(private val content: T) { + + var hasBeenHandled = false + private set // Allow external read but not write + + /** + * Returns the content and prevents its use again. + */ + fun getContentIfNotHandled(): T? { + return if (hasBeenHandled) { + null + } else { + hasBeenHandled = true + content + } + } + + /** + * Returns the content, even if it's already been handled. + */ + fun peekContent(): T = content +} diff --git a/app/sdks/client-android/example/src/main/res/drawable/ic_launcher_background.xml b/app/sdks/client-android/example/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 000000000..07d5da9cb --- /dev/null +++ b/app/sdks/client-android/example/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/sdks/client-android/example/src/main/res/drawable/ic_launcher_foreground.xml b/app/sdks/client-android/example/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 000000000..2b068d114 --- /dev/null +++ b/app/sdks/client-android/example/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/sdks/client-android/example/src/main/res/layout/activity_main.xml b/app/sdks/client-android/example/src/main/res/layout/activity_main.xml new file mode 100644 index 000000000..7aa7dd7f4 --- /dev/null +++ b/app/sdks/client-android/example/src/main/res/layout/activity_main.xml @@ -0,0 +1,15 @@ + + + + + + \ No newline at end of file diff --git a/app/sdks/client-android/example/src/main/res/layout/fragment_account.xml b/app/sdks/client-android/example/src/main/res/layout/fragment_account.xml new file mode 100644 index 000000000..2fb34c957 --- /dev/null +++ b/app/sdks/client-android/example/src/main/res/layout/fragment_account.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + +