From 556028114122cc195399f4b7f916c64b6a6c9fb0 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Fri, 16 Apr 2021 12:41:35 +0545 Subject: [PATCH 01/25] enabling android platform --- app/views/console/home/index.phtml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/console/home/index.phtml b/app/views/console/home/index.phtml index 1f3e95f1d..45b7dc5b7 100644 --- a/app/views/console/home/index.phtml +++ b/app/views/console/home/index.phtml @@ -231,8 +231,8 @@ $usageStatsEnabled = $this->getParam('usageStatsEnabled',true);
  • -
  • - +
  • +
  • From b7470da9d76ae9fc09a0a8d78d9744a4419220b2 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Fri, 16 Apr 2021 13:15:35 +0545 Subject: [PATCH 02/25] adding android platform --- app/views/console/home/index.phtml | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/app/views/console/home/index.phtml b/app/views/console/home/index.phtml index 45b7dc5b7..2491a0352 100644 --- a/app/views/console/home/index.phtml +++ b/app/views/console/home/index.phtml @@ -317,6 +317,42 @@ $usageStatsEnabled = $this->getParam('usageStatsEnabled',true); + +
  • -
  • - -
  • +
  • + +
  • From 46c6531f731d8a9e5aa67dfb894b026f2c70c2df Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Thu, 27 May 2021 15:13:40 +0200 Subject: [PATCH 05/25] feat(system): add env to configure telegraf --- app/views/install/compose.phtml | 3 +++ docker-compose.yml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index e35ea60d0..cadd619c1 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -377,6 +377,9 @@ services: restart: unless-stopped networks: - appwrite + environment: + - _APP_INFLUXDB_HOST + - _APP_INFLUXDB_PORT networks: gateway: diff --git a/docker-compose.yml b/docker-compose.yml index c9c278431..d57d87daa 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -435,6 +435,9 @@ services: container_name: appwrite-telegraf networks: - appwrite + environment: + - _APP_INFLUXDB_HOST + - _APP_INFLUXDB_PORT # Dev Tools Start ------------------------------------------------------------------------------------------ # From 75d3c39763aacc3eec8572a5e80cb69e2d2f203d Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 1 Jun 2021 16:02:50 +0545 Subject: [PATCH 06/25] android changelog and getting started --- docs/sdks/android/CHANGELOG.md | 1 + docs/sdks/android/GETTING_STARTED.md | 55 ++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 docs/sdks/android/CHANGELOG.md create mode 100644 docs/sdks/android/GETTING_STARTED.md diff --git a/docs/sdks/android/CHANGELOG.md b/docs/sdks/android/CHANGELOG.md new file mode 100644 index 000000000..fa4d35e68 --- /dev/null +++ b/docs/sdks/android/CHANGELOG.md @@ -0,0 +1 @@ +# Change Log \ No newline at end of file diff --git a/docs/sdks/android/GETTING_STARTED.md b/docs/sdks/android/GETTING_STARTED.md new file mode 100644 index 000000000..6bd618505 --- /dev/null +++ b/docs/sdks/android/GETTING_STARTED.md @@ -0,0 +1,55 @@ +## Getting Started + +### Init your SDK + +

    Initialize your SDK code with your project ID, which can be found in your project settings page. + +```kotlin +import io.appwrite.AppwriteClient +import io.appwrite.services.AccountService + +val client = AppwriteClient(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 for the device or emulator and not your local Appwrite instance. You should replace localhost with your private IP as the Appwrite endpoint's hostname. 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 section. + +```kotlin +// Register User +val accountService = AccountService(client) +val user = accountService.create( + "email@example.com", + "password" +) +``` + +### Full Example + +```kotlin +import io.appwrite.AppwriteClient +import io.appwrite.services.AccountService + +val client = AppwriteClient(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + .setSelfSigned(true) // Remove in production + +val accountService = AccountService(client) +val user = accountService.create( + "email@example.com", + "password" +) +``` + +### Learn more +You can use followng resources to learn more and get help +- 📜 [Appwrite Docs](https://appwrite.io/docs) +- 💬 [Discord Community](https://appwrite.io/discord) \ No newline at end of file From c2651d56af0cc44ee500aa1ac4a65dad883b52fc Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 1 Jun 2021 16:11:51 +0545 Subject: [PATCH 07/25] improvements --- docs/sdks/android/GETTING_STARTED.md | 36 +++++++++++++++++++--------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/docs/sdks/android/GETTING_STARTED.md b/docs/sdks/android/GETTING_STARTED.md index 6bd618505..801dcd290 100644 --- a/docs/sdks/android/GETTING_STARTED.md +++ b/docs/sdks/android/GETTING_STARTED.md @@ -5,10 +5,10 @@

    Initialize your SDK code with your project ID, which can be found in your project settings page. ```kotlin -import io.appwrite.AppwriteClient -import io.appwrite.services.AccountService +import io.appwrite.Client +import io.appwrite.services.Account -val client = AppwriteClient(context) +val client = Client(context) .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID .setSelfSigned(true) // Remove in production @@ -24,8 +24,8 @@ When trying to connect to Appwrite from an emulator or a mobile device, localhos ```kotlin // Register User -val accountService = AccountService(client) -val user = accountService.create( +val account = Account(client) +val user = account.create( "email@example.com", "password" ) @@ -34,22 +34,36 @@ val user = accountService.create( ### Full Example ```kotlin -import io.appwrite.AppwriteClient -import io.appwrite.services.AccountService +import io.appwrite.Client +import io.appwrite.services.Account -val client = AppwriteClient(context) +val client = Client(context) .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID .setSelfSigned(true) // Remove in production -val accountService = AccountService(client) -val user = accountService.create( +val account = Account(client) +val user = account.create( "email@example.com", "password" ) ``` +### Error Handling +The Apopwrite Android SDK raises `AppwriteException` object with `message`, `code` and `response` properties. You can handle any errors by catching `AppwriteException` and present the `message` to the user or handle it yourself based on 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 followng 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) \ No newline at end of file +- 💬 [Discord Community](https://appwrite.io/discord) +- - 🚂 [Appwrite Android Playground](https://github.com/appwrite/playground-for-android) \ No newline at end of file From 7dd342b66465b2745d9d641d3c898c81ecdb1193 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 1 Jun 2021 16:13:19 +0545 Subject: [PATCH 08/25] correction --- docs/sdks/android/GETTING_STARTED.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/sdks/android/GETTING_STARTED.md b/docs/sdks/android/GETTING_STARTED.md index 801dcd290..8d1992fa4 100644 --- a/docs/sdks/android/GETTING_STARTED.md +++ b/docs/sdks/android/GETTING_STARTED.md @@ -25,7 +25,7 @@ When trying to connect to Appwrite from an emulator or a mobile device, localhos ```kotlin // Register User val account = Account(client) -val user = account.create( +val response = account.create( "email@example.com", "password" ) @@ -43,7 +43,7 @@ val client = Client(context) .setSelfSigned(true) // Remove in production val account = Account(client) -val user = account.create( +val response = account.create( "email@example.com", "password" ) From 104f5e56855c09067083e113c709f081f007943d Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 1 Jun 2021 16:17:45 +0545 Subject: [PATCH 09/25] add platform and oauth details --- docs/sdks/android/GETTING_STARTED.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/docs/sdks/android/GETTING_STARTED.md b/docs/sdks/android/GETTING_STARTED.md index 8d1992fa4..23223d85d 100644 --- a/docs/sdks/android/GETTING_STARTED.md +++ b/docs/sdks/android/GETTING_STARTED.md @@ -1,5 +1,30 @@ ## Getting Started +### Add your Android Platform +To init your SDK and start interacting with Appwrite services, you need to add a new Flutter platform to your project. To add a new platform, go to your Appwrite console, choose the project you created in the step before, and click the 'Add Platform' button. + +From the options, choose to add a new **Flutter** platform and add your app credentials, ignoring iOS. + +Add your app name and package name, Your package name is generally the applicationId in your app-level build.gradle file. By registering your new app platform, you are allowing your app to communicate with the Appwrite API. + +### OAuth +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-flutter/blob/master/android/app/src/main/AndroidManifest.xml). Be sure to relpace the **[PROJECT_ID]** string with your actual Appwrite project ID. You can find your Appwrite project ID in you project settings screen in your Appwrite console. + +```xml + + + + + + + + + + + + +``` + ### Init your SDK

    Initialize your SDK code with your project ID, which can be found in your project settings page. From c71920e56f7982a1dc2625a9fa93fb417b3a618a Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Thu, 3 Jun 2021 14:31:58 +0200 Subject: [PATCH 10/25] update appwrite/telegraf to 1.2.0 --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index d57d87daa..ec4a74a25 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -431,7 +431,7 @@ services: - appwrite-influxdb:/var/lib/influxdb:rw telegraf: - image: appwrite/telegraf:1.1.0 + image: appwrite/telegraf:1.2.0 container_name: appwrite-telegraf networks: - appwrite From 3c03b5f997511d68c7c39ca4427c4f142095cb64 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Thu, 3 Jun 2021 14:57:17 +0200 Subject: [PATCH 11/25] fix(install): update to new telegraf version --- app/views/install/compose.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index cadd619c1..1acc35066 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -372,7 +372,7 @@ services: - appwrite-influxdb:/var/lib/influxdb:rw telegraf: - image: appwrite/telegraf:1.0.0 + image: appwrite/telegraf:1.2.0 container_name: appwrite-telegraf restart: unless-stopped networks: From 53e9c84bab8f3ae183030d7ba1dc2392dbb33e11 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Thu, 3 Jun 2021 15:36:11 +0200 Subject: [PATCH 12/25] chore(changelog): add telegraf env changes --- CHANGES.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 0dd92eeff..0f24324ee 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,7 +8,10 @@ - Renamed *Devices* to *Sessions* - Add Provider Icon to each Session - Add Anonymous Account Placeholder -- Upgraded telegraf docker image version to v1.1.0 +- Upgraded telegraf docker image version to v1.2.0 +- Added new environment variables to the `telegraf` service: + - _APP_INFLUXDB_HOST + - _APP_INFLUXDB_PORT ## Bugs From 25888151fb029ff4fe0669c033d8ac71a2ecd3d2 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Wed, 9 Jun 2021 18:15:38 +0530 Subject: [PATCH 13/25] feat: add android platform config --- app/config/platforms.php | 19 ++++++++++--------- app/tasks/sdks.php | 12 +++++------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/app/config/platforms.php b/app/config/platforms.php index cfb21f3d8..40da048b2 100644 --- a/app/config/platforms.php +++ b/app/config/platforms.php @@ -109,19 +109,20 @@ return [ 'gitUserName' => 'appwrite', ], [ - 'key' => 'kotlin', - 'name' => 'Kotlin', - 'url' => '', - 'package' => '', - 'enabled' => false, - 'beta' => false, + 'key' => 'android', + 'name' => 'Android', + 'version' => '0.0.0-SNAPSHOT', + 'url' => 'https://github.com/appwrite/sdk-for-android', + 'package' => 'https://pub.dev/packages/appwrite', + 'enabled' => true, + 'beta' => true, 'dev' => false, 'hidden' => false, 'family' => APP_PLATFORM_CLIENT, 'prism' => 'kotlin', - 'source' => false, - 'gitUrl' => 'git@github.com:appwrite/sdk-for-kotlin.git', - 'gitRepoName' => 'sdk-for-kotlin', + 'source' => \realpath(__DIR__ . '/../sdks/client-android'), + 'gitUrl' => 'git@github.com:appwrite/sdk-for-android.git', + 'gitRepoName' => 'sdk-for-android', 'gitUserName' => 'appwrite', ], // [ diff --git a/app/tasks/sdks.php b/app/tasks/sdks.php index 108ce7a48..adc50392c 100644 --- a/app/tasks/sdks.php +++ b/app/tasks/sdks.php @@ -15,7 +15,7 @@ use Appwrite\SDK\Language\Deno; use Appwrite\SDK\Language\DotNet; use Appwrite\SDK\Language\Flutter; use Appwrite\SDK\Language\Go; -use Appwrite\SDK\Language\Java; +use Appwrite\SDK\Language\Kotlin; use Appwrite\SDK\Language\Swift; $cli @@ -134,9 +134,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND case 'go': $config = new Go(); break; - case 'java': - $config = new Java(); - break; case 'swift': $config = new Swift(); break; @@ -144,6 +141,9 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND $cover = ''; $config = new DotNet(); break; + case 'android': + $config = new Kotlin(); + break; default: throw new Exception('Language "'.$language['key'].'" not supported'); break; @@ -155,9 +155,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND $sdk ->setName($language['name']) - ->setDescription("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 {$language['name']} 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)") + ->setDescription("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 {$language['name']} 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)") ->setShortDescription('Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API') ->setLicense($license) ->setLicenseContent($licenseContent) From 0cbbcd38295d4eedbefbba27b1793a17f2f1e6d8 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Wed, 9 Jun 2021 18:31:35 +0530 Subject: [PATCH 14/25] feat: update package link --- app/config/platforms.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/config/platforms.php b/app/config/platforms.php index 40da048b2..1409cf2cc 100644 --- a/app/config/platforms.php +++ b/app/config/platforms.php @@ -113,7 +113,7 @@ return [ 'name' => 'Android', 'version' => '0.0.0-SNAPSHOT', 'url' => 'https://github.com/appwrite/sdk-for-android', - 'package' => 'https://pub.dev/packages/appwrite', + 'package' => 'https://repo1.maven.org/maven2/io/appwrite/sdk-for-android/', 'enabled' => true, 'beta' => true, 'dev' => false, From 3425fe351a81740fe9c89dfe1f2dd6f7bc33253b Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Wed, 9 Jun 2021 18:59:31 +0530 Subject: [PATCH 15/25] feat: fixed some issues with the guide --- docs/sdks/android/GETTING_STARTED.md | 16 ++++++++-------- docs/sdks/flutter/GETTING_STARTED.md | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/sdks/android/GETTING_STARTED.md b/docs/sdks/android/GETTING_STARTED.md index 23223d85d..8a38e86fe 100644 --- a/docs/sdks/android/GETTING_STARTED.md +++ b/docs/sdks/android/GETTING_STARTED.md @@ -1,14 +1,14 @@ ## Getting Started ### Add your Android Platform -To init your SDK and start interacting with Appwrite services, you need to add a new Flutter platform to your project. To add a new platform, go to your Appwrite console, choose the project you created in the step before, and click the 'Add Platform' button. +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, choose the project you created in the step before, and click the 'Add Platform' button. -From the options, choose to add a new **Flutter** platform and add your app credentials, ignoring iOS. +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 your new app platform, you are allowing your app to communicate with the Appwrite API. +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. ### OAuth -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-flutter/blob/master/android/app/src/main/AndroidManifest.xml). Be sure to relpace the **[PROJECT_ID]** string with your actual Appwrite project ID. You can find your Appwrite project ID in you project settings screen in your Appwrite console. +In order to capture the Appwrite OAuth callback url, the following activity needs to be added to your [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 @@ -41,7 +41,7 @@ val client = Client(context) 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 for the device or emulator and not your local Appwrite instance. You should replace localhost with your private IP as the Appwrite endpoint's hostname. You can also use a service like [ngrok](https://ngrok.com/) to proxy the Appwrite API. +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 @@ -75,7 +75,7 @@ val response = account.create( ``` ### Error Handling -The Apopwrite Android SDK raises `AppwriteException` object with `message`, `code` and `response` properties. You can handle any errors by catching `AppwriteException` and present the `message` to the user or handle it yourself based on provided error information. Below is an example. +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 { @@ -87,8 +87,8 @@ try { ``` ### Learn more -You can use followng resources to learn more and get help +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) \ No newline at end of file +- 🚂 [Appwrite Android Playground](https://github.com/appwrite/playground-for-android) \ No newline at end of file diff --git a/docs/sdks/flutter/GETTING_STARTED.md b/docs/sdks/flutter/GETTING_STARTED.md index 9af9720d8..bf2d613c7 100644 --- a/docs/sdks/flutter/GETTING_STARTED.md +++ b/docs/sdks/flutter/GETTING_STARTED.md @@ -23,7 +23,7 @@ The Appwrite SDK uses ASWebAuthenticationSession on iOS 12+ and SFAuthentication 4. In Deployment Info, 'Target' select iOS 11.0 ### Android -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-flutter/blob/master/android/app/src/main/AndroidManifest.xml). Be sure to relpace the **[PROJECT_ID]** string with your actual Appwrite project ID. You can find your Appwrite project ID in you project settings screen in your Appwrite console. +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-flutter/blob/master/android/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 From 0492ccadd58dbfd3db339832a57a5db55335ccb7 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Wed, 9 Jun 2021 20:56:08 +0530 Subject: [PATCH 16/25] feat: update getting started guides --- docs/sdks/android/GETTING_STARTED.md | 10 +++++----- docs/sdks/deno/GETTING_STARTED.md | 4 ++-- docs/sdks/flutter/GETTING_STARTED.md | 4 ++-- docs/sdks/nodejs/GETTING_STARTED.md | 4 ++-- docs/sdks/php/GETTING_STARTED.md | 4 ++-- docs/sdks/python/GETTING_STARTED.md | 4 ++-- docs/sdks/ruby/GETTING_STARTED.md | 4 ++-- docs/sdks/web/GETTING_STARTED.md | 4 ++-- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/docs/sdks/android/GETTING_STARTED.md b/docs/sdks/android/GETTING_STARTED.md index 8a38e86fe..c0bba2505 100644 --- a/docs/sdks/android/GETTING_STARTED.md +++ b/docs/sdks/android/GETTING_STARTED.md @@ -1,14 +1,14 @@ ## 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, choose the project you created in the step before, and click the 'Add Platform' button. +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. -### OAuth -In order to capture the Appwrite OAuth callback url, the following activity needs to be added to your [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. +### 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 @@ -27,7 +27,7 @@ In order to capture the Appwrite OAuth callback url, the following activity need ### Init your SDK -

    Initialize your SDK code with your project ID, which can be found in your project settings page. +

    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 @@ -45,7 +45,7 @@ When trying to connect to Appwrite from an emulator or a mobile device, localhos ### 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 section. +

    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 diff --git a/docs/sdks/deno/GETTING_STARTED.md b/docs/sdks/deno/GETTING_STARTED.md index b8f851a4b..3a239003f 100644 --- a/docs/sdks/deno/GETTING_STARTED.md +++ b/docs/sdks/deno/GETTING_STARTED.md @@ -1,7 +1,7 @@ ## Getting Started ### Init your SDK -Initialize your SDK code with your project ID which can be found in your project settings page and your new API secret Key from project's API keys section. +Initialize your SDK with your Appwrite server API endpoint and project ID which can be found in your project settings page and your new API secret Key from project's API keys section. ```typescript let client = new sdk.Client(); @@ -17,7 +17,7 @@ client ### Make your first request -Once your SDK object is set, create any of the Appwrite service objects 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 section. +Once your SDK object is set, create any of the Appwrite service objects 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. ```typescript let users = new sdk.Users(client); diff --git a/docs/sdks/flutter/GETTING_STARTED.md b/docs/sdks/flutter/GETTING_STARTED.md index bf2d613c7..0a7244b19 100644 --- a/docs/sdks/flutter/GETTING_STARTED.md +++ b/docs/sdks/flutter/GETTING_STARTED.md @@ -48,7 +48,7 @@ While running Flutter Web, make sure your Appwrite server and your Flutter clien ### Init your SDK -

    Initialize your SDK code with your project ID, which can be found in your project settings page. +

    Initialize your SDK with your Appwrite server API endpoint and project ID, which can be found in your project settings page. ```dart import 'package:appwrite/appwrite.dart'; @@ -68,7 +68,7 @@ When trying to connect to Appwrite from an emulator or a mobile device, localhos ### 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 section. +

    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. ```dart // Register User diff --git a/docs/sdks/nodejs/GETTING_STARTED.md b/docs/sdks/nodejs/GETTING_STARTED.md index b2ce5f091..ee19ca3c3 100644 --- a/docs/sdks/nodejs/GETTING_STARTED.md +++ b/docs/sdks/nodejs/GETTING_STARTED.md @@ -1,7 +1,7 @@ ## Getting Started ### Init your SDK -Initialize your SDK code with your project ID which can be found in your project settings page and your new API secret Key project API keys section. +Initialize your SDK with your Appwrite server API endpoint and project ID which can be found in your project settings page and your new API secret Key project API keys section. ```js const sdk = require('node-appwrite'); @@ -17,7 +17,7 @@ client ``` ### Make Your First Request -Once your SDK object is set, create any of the Appwrite service objects 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 section. +Once your SDK object is set, create any of the Appwrite service objects 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. ```js let users = new sdk.Users(client); diff --git a/docs/sdks/php/GETTING_STARTED.md b/docs/sdks/php/GETTING_STARTED.md index a7ceb6137..7aef8cdcc 100644 --- a/docs/sdks/php/GETTING_STARTED.md +++ b/docs/sdks/php/GETTING_STARTED.md @@ -1,7 +1,7 @@ ## Getting Started ### Init your SDK -Initialize your SDK code with your project ID which can be found in your project settings page and your new API secret Key from project's API keys section. +Initialize your SDK with your Appwrite server API endpoint and project ID which can be found in your project settings page and your new API secret Key from project's API keys section. ```php $client = new Client(); @@ -15,7 +15,7 @@ $client ``` ### Make Your First Request -Once your SDK object is set, create any of the Appwrite service objects 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 section. +Once your SDK object is set, create any of the Appwrite service objects 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. ```php $users = new Users($client); diff --git a/docs/sdks/python/GETTING_STARTED.md b/docs/sdks/python/GETTING_STARTED.md index 81c795450..b68f51aff 100644 --- a/docs/sdks/python/GETTING_STARTED.md +++ b/docs/sdks/python/GETTING_STARTED.md @@ -1,7 +1,7 @@ ## Getting Started ### Init your SDK -Initialize your SDK code with your project ID which can be found in your project settings page and your new API secret Key from project's API keys section. +Initialize your SDK with your Appwrite server API endpoint and project ID which can be found in your project settings page and your new API secret Key from project's API keys section. ```python from appwrite.client import Client @@ -18,7 +18,7 @@ client = Client() ``` ### Make Your First Request -Once your SDK object is set, create any of the Appwrite service objects 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 section. +Once your SDK object is set, create any of the Appwrite service objects 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. ```python users = Users(client) diff --git a/docs/sdks/ruby/GETTING_STARTED.md b/docs/sdks/ruby/GETTING_STARTED.md index acabf1c0a..820f1669e 100644 --- a/docs/sdks/ruby/GETTING_STARTED.md +++ b/docs/sdks/ruby/GETTING_STARTED.md @@ -1,7 +1,7 @@ ## Getting Started ### Init your SDK -Initialize your SDK code with your project ID which can be found in your project settings page and your new API secret Key from project's API keys section. +Initialize your SDK with your Appwrite server API endpoint and project ID which can be found in your project settings page and your new API secret Key from project's API keys section. ```ruby require 'appwrite' @@ -17,7 +17,7 @@ client ``` ### Make Your First Request -Once your SDK object is set, create any of the Appwrite service objects 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 section. +Once your SDK object is set, create any of the Appwrite service objects 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. ```ruby users = Appwrite::Users.new(client); diff --git a/docs/sdks/web/GETTING_STARTED.md b/docs/sdks/web/GETTING_STARTED.md index ba337b178..1fe6250d2 100644 --- a/docs/sdks/web/GETTING_STARTED.md +++ b/docs/sdks/web/GETTING_STARTED.md @@ -6,7 +6,7 @@ For you to init your SDK and interact with Appwrite services you need to add a w From the options, choose to add a **Web** platform and add your client app hostname. By adding your hostname to your project platform you are allowing cross-domain communication between your project and the Appwrite API. ### Init your SDK -Initialize your SDK code with your project ID which can be found in your project settings page. +Initialize your SDK with your Appwrite server API endpoint and project ID which can be found in your project settings page. ```js // Init your Web SDK @@ -19,7 +19,7 @@ sdk ``` ### 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 section. +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. ```js // Register User From bdb4e98123b114f1bc39c15e137ef68a18c5ee44 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Wed, 9 Jun 2021 21:00:52 +0530 Subject: [PATCH 17/25] feat: added namespace --- app/tasks/sdks.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/tasks/sdks.php b/app/tasks/sdks.php index adc50392c..96f874229 100644 --- a/app/tasks/sdks.php +++ b/app/tasks/sdks.php @@ -155,6 +155,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND $sdk ->setName($language['name']) + ->setNamespace('io appwrite') ->setDescription("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 {$language['name']} 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)") ->setShortDescription('Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API') ->setLicense($license) From da1ecfaffefd184aadc8c2a70ba08e1ccb88c1a3 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 10 Jun 2021 15:05:16 +0530 Subject: [PATCH 18/25] feat: added android origin check --- src/Appwrite/Network/Validator/Origin.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Appwrite/Network/Validator/Origin.php b/src/Appwrite/Network/Validator/Origin.php index 8101d9a30..aa9294f65 100644 --- a/src/Appwrite/Network/Validator/Origin.php +++ b/src/Appwrite/Network/Validator/Origin.php @@ -13,6 +13,8 @@ class Origin extends Validator const CLIENT_TYPE_FLUTTER_MACOS = 'flutter-macos'; const CLIENT_TYPE_FLUTTER_WINDOWS = 'flutter-windows'; const CLIENT_TYPE_FLUTTER_LINUX = 'flutter-linux'; + const CLIENT_TYPE_ANDROID = 'android'; + const SCHEME_TYPE_HTTP = 'http'; const SCHEME_TYPE_HTTPS = 'https'; @@ -69,6 +71,7 @@ class Origin extends Validator case self::CLIENT_TYPE_FLUTTER_MACOS: case self::CLIENT_TYPE_FLUTTER_WINDOWS: case self::CLIENT_TYPE_FLUTTER_LINUX: + case self::CLIENT_TYPE_ANDROID: $this->clients[] = (isset($platform['key'])) ? $platform['key'] : ''; break; @@ -90,7 +93,7 @@ class Origin extends Validator } /** - * Check if Origin has been whiltlisted + * Check if Origin has been whitelisted * for access to the API * * @param mixed $origin From c3d4897d36215d82ce8860a1363d30f69c344d37 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 10 Jun 2021 15:13:32 +0530 Subject: [PATCH 19/25] feat: changed terminology --- src/Appwrite/Network/Validator/Origin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Network/Validator/Origin.php b/src/Appwrite/Network/Validator/Origin.php index aa9294f65..38e37e60b 100644 --- a/src/Appwrite/Network/Validator/Origin.php +++ b/src/Appwrite/Network/Validator/Origin.php @@ -93,7 +93,7 @@ class Origin extends Validator } /** - * Check if Origin has been whitelisted + * Check if Origin has been allowed * for access to the API * * @param mixed $origin From c981ff39c0ca5e2a450d4a2d1060cf1f2f1be7d3 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 10 Jun 2021 17:04:14 +0530 Subject: [PATCH 20/25] feat: added error models to response model --- src/Appwrite/Utopia/Response/Filters/V07.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Appwrite/Utopia/Response/Filters/V07.php b/src/Appwrite/Utopia/Response/Filters/V07.php index 6001450b9..36831b473 100644 --- a/src/Appwrite/Utopia/Response/Filters/V07.php +++ b/src/Appwrite/Utopia/Response/Filters/V07.php @@ -55,6 +55,8 @@ class V07 extends Filter { case Response::MODEL_ANY: case Response::MODEL_PREFERENCES: /** ANY was replaced by PREFERENCES in 0.8.x but this is backward compatible with 0.7.x */ case Response::MODEL_NONE: + case Response::MODEL_ERROR: + case Response::MODEL_ERROR_DEV: $parsedResponse = $content; break; default: From 43d9c416a352e547911e96d7966b08570742ceb8 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Fri, 11 Jun 2021 12:44:30 +0530 Subject: [PATCH 21/25] 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 @@ + + + + + + + + + + + + + + + + +