diff --git a/LICENSE.md b/LICENSE.md index b0761cc..90528c4 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -7,6 +7,6 @@ Redistribution and use in source and binary forms, with or without modification, 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. + 3. Neither the name of the copyright holder 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/README.md b/README.md index 83edb8a..35f4e57 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,12 @@ ![Maven Central](https://img.shields.io/maven-central/v/io.appwrite/sdk-for-android.svg?color=green&style=flat-square) ![License](https://img.shields.io/github/license/appwrite/sdk-for-android.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.0.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.2.0-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK is compatible with Appwrite server version 1.0.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-android/releases).** +**This SDK is compatible with Appwrite server version 1.2.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) @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:1.1.0") +implementation("io.appwrite:sdk-for-android:1.2.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 1.1.0 + 1.2.0 ``` diff --git a/build.gradle b/build.gradle index 79f6b0b..d475d54 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ 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.5.31" + ext.kotlin_version = "1.7.10" version System.getenv("SDK_VERSION") repositories { maven { url "https://plugins.gradle.org/m2/" } @@ -10,7 +10,7 @@ buildscript { mavenCentral() } dependencies { - classpath "com.android.tools.build:gradle:4.2.0" + classpath "com.android.tools.build:gradle:4.2.2" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'io.github.gradle-nexus:publish-plugin:1.1.0' diff --git a/docs/examples/java/account/create-anonymous-session.md b/docs/examples/java/account/create-anonymous-session.md index b1a2a25..7d2123b 100644 --- a/docs/examples/java/account/create-anonymous-session.md +++ b/docs/examples/java/account/create-anonymous-session.md @@ -1,46 +1,18 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Account +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Account account = new Account(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - - Account account = new Account(client); - - account.createAnonymousSession(new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - }); +account.createAnonymousSession(new CoroutineCallback<>((result, error) -> { + if (error != null) + error.printStackTrace(); + return; } -} \ No newline at end of file + + Log.d("Appwrite", result.toString()); +})); diff --git a/docs/examples/java/account/create-email-session.md b/docs/examples/java/account/create-email-session.md index 055b828..384dbaf 100644 --- a/docs/examples/java/account/create-email-session.md +++ b/docs/examples/java/account/create-email-session.md @@ -1,49 +1,22 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Account +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Account account = new Account(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +account.createEmailSession( + "email@example.com", + "password" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Account account = new Account(client); - - account.createEmailSession( - "email@example.com", - "password" - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/account/create-j-w-t.md b/docs/examples/java/account/create-j-w-t.md index 3a97c33..86ad905 100644 --- a/docs/examples/java/account/create-j-w-t.md +++ b/docs/examples/java/account/create-j-w-t.md @@ -1,46 +1,18 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Account +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Account account = new Account(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - - Account account = new Account(client); - - account.createJWT(new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - }); +account.createJWT(new CoroutineCallback<>((result, error) -> { + if (error != null) + error.printStackTrace(); + return; } -} \ No newline at end of file + + Log.d("Appwrite", result.toString()); +})); diff --git a/docs/examples/java/account/create-magic-u-r-l-session.md b/docs/examples/java/account/create-magic-u-r-l-session.md index 6c9fa7c..1789eec 100644 --- a/docs/examples/java/account/create-magic-u-r-l-session.md +++ b/docs/examples/java/account/create-magic-u-r-l-session.md @@ -1,49 +1,22 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Account +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Account account = new Account(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +account.createMagicURLSession( + "[USER_ID]", + "email@example.com", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Account account = new Account(client); - - account.createMagicURLSession( - "[USER_ID]", - "email@example.com", - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/account/create-o-auth2session.md b/docs/examples/java/account/create-o-auth2session.md index e4cfb8d..a2f5d02 100644 --- a/docs/examples/java/account/create-o-auth2session.md +++ b/docs/examples/java/account/create-o-auth2session.md @@ -1,46 +1,21 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Account +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Account account = new Account(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +account.createOAuth2Session( + "amazon", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Account account = new Account(client); - - account.createOAuth2Session( - this, - "amazon", - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/account/create-phone-session.md b/docs/examples/java/account/create-phone-session.md index 78be922..7c54dbd 100644 --- a/docs/examples/java/account/create-phone-session.md +++ b/docs/examples/java/account/create-phone-session.md @@ -1,49 +1,22 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Account +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Account account = new Account(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +account.createPhoneSession( + "[USER_ID]", + "+12065550100" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Account account = new Account(client); - - account.createPhoneSession( - "[USER_ID]", - "" - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/account/create-phone-verification.md b/docs/examples/java/account/create-phone-verification.md index 401b942..f3e9526 100644 --- a/docs/examples/java/account/create-phone-verification.md +++ b/docs/examples/java/account/create-phone-verification.md @@ -1,46 +1,18 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Account +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Account account = new Account(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - - Account account = new Account(client); - - account.createPhoneVerification(new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - }); +account.createPhoneVerification(new CoroutineCallback<>((result, error) -> { + if (error != null) + error.printStackTrace(); + return; } -} \ No newline at end of file + + Log.d("Appwrite", result.toString()); +})); diff --git a/docs/examples/java/account/create-recovery.md b/docs/examples/java/account/create-recovery.md index 459213b..44773dd 100644 --- a/docs/examples/java/account/create-recovery.md +++ b/docs/examples/java/account/create-recovery.md @@ -1,49 +1,22 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Account +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Account account = new Account(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +account.createRecovery( + "email@example.com", + "https://example.com" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Account account = new Account(client); - - account.createRecovery( - "email@example.com", - "https://example.com" - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/account/create-verification.md b/docs/examples/java/account/create-verification.md index b8b1c20..02d2934 100644 --- a/docs/examples/java/account/create-verification.md +++ b/docs/examples/java/account/create-verification.md @@ -1,48 +1,21 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Account +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Account account = new Account(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +account.createVerification( + "https://example.com" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Account account = new Account(client); - - account.createVerification( - "https://example.com" - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/account/create.md b/docs/examples/java/account/create.md index 11a5168..af0965e 100644 --- a/docs/examples/java/account/create.md +++ b/docs/examples/java/account/create.md @@ -1,50 +1,23 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Account +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Account account = new Account(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +account.create( + "[USER_ID]", + "email@example.com", + "password", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Account account = new Account(client); - - account.create( - "[USER_ID]", - "email@example.com", - "password", - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/account/delete-session.md b/docs/examples/java/account/delete-session.md index b3549c7..b42b841 100644 --- a/docs/examples/java/account/delete-session.md +++ b/docs/examples/java/account/delete-session.md @@ -1,48 +1,21 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Account +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Account account = new Account(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +account.deleteSession( + "[SESSION_ID]" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Account account = new Account(client); - - account.deleteSession( - "[SESSION_ID]" - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/account/delete-sessions.md b/docs/examples/java/account/delete-sessions.md index 153c323..847c5c1 100644 --- a/docs/examples/java/account/delete-sessions.md +++ b/docs/examples/java/account/delete-sessions.md @@ -1,46 +1,18 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Account +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Account account = new Account(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - - Account account = new Account(client); - - account.deleteSessions(new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - }); +account.deleteSessions(new CoroutineCallback<>((result, error) -> { + if (error != null) + error.printStackTrace(); + return; } -} \ No newline at end of file + + Log.d("Appwrite", result.toString()); +})); diff --git a/docs/examples/java/account/get-logs.md b/docs/examples/java/account/get-logs.md deleted file mode 100644 index fb83c5d..0000000 --- a/docs/examples/java/account/get-logs.md +++ /dev/null @@ -1,47 +0,0 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Account - -public class MainActivity extends AppCompatActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - - Account account = new Account(client); - - account.getLogs( - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file diff --git a/docs/examples/java/account/get-prefs.md b/docs/examples/java/account/get-prefs.md index 25ab6c3..d7777d8 100644 --- a/docs/examples/java/account/get-prefs.md +++ b/docs/examples/java/account/get-prefs.md @@ -1,46 +1,18 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Account +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Account account = new Account(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - - Account account = new Account(client); - - account.getPrefs(new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - }); +account.getPrefs(new CoroutineCallback<>((result, error) -> { + if (error != null) + error.printStackTrace(); + return; } -} \ No newline at end of file + + Log.d("Appwrite", result.toString()); +})); diff --git a/docs/examples/java/account/get-session.md b/docs/examples/java/account/get-session.md index 8d4c95a..b7861b2 100644 --- a/docs/examples/java/account/get-session.md +++ b/docs/examples/java/account/get-session.md @@ -1,48 +1,21 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Account +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Account account = new Account(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +account.getSession( + "[SESSION_ID]" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Account account = new Account(client); - - account.getSession( - "[SESSION_ID]" - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/account/get-sessions.md b/docs/examples/java/account/get-sessions.md deleted file mode 100644 index 7afe852..0000000 --- a/docs/examples/java/account/get-sessions.md +++ /dev/null @@ -1,46 +0,0 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Account - -public class MainActivity extends AppCompatActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - - Account account = new Account(client); - - account.getSessions(new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - }); - } -} \ No newline at end of file diff --git a/docs/examples/java/account/get.md b/docs/examples/java/account/get.md index 146a5e5..1351652 100644 --- a/docs/examples/java/account/get.md +++ b/docs/examples/java/account/get.md @@ -1,46 +1,18 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Account +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Account account = new Account(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - - Account account = new Account(client); - - account.get(new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - }); +account.get(new CoroutineCallback<>((result, error) -> { + if (error != null) + error.printStackTrace(); + return; } -} \ No newline at end of file + + Log.d("Appwrite", result.toString()); +})); diff --git a/docs/examples/java/account/list-logs.md b/docs/examples/java/account/list-logs.md index f33c413..d073d4e 100644 --- a/docs/examples/java/account/list-logs.md +++ b/docs/examples/java/account/list-logs.md @@ -1,47 +1,20 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Account +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Account account = new Account(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +account.listLogs( + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Account account = new Account(client); - - account.listLogs( - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/account/list-sessions.md b/docs/examples/java/account/list-sessions.md index 5933f03..91888bc 100644 --- a/docs/examples/java/account/list-sessions.md +++ b/docs/examples/java/account/list-sessions.md @@ -1,46 +1,18 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Account +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Account account = new Account(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - - Account account = new Account(client); - - account.listSessions(new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - }); +account.listSessions(new CoroutineCallback<>((result, error) -> { + if (error != null) + error.printStackTrace(); + return; } -} \ No newline at end of file + + Log.d("Appwrite", result.toString()); +})); diff --git a/docs/examples/java/account/update-email.md b/docs/examples/java/account/update-email.md index 56a1bc0..53dd0bd 100644 --- a/docs/examples/java/account/update-email.md +++ b/docs/examples/java/account/update-email.md @@ -1,49 +1,22 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Account +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Account account = new Account(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +account.updateEmail( + "email@example.com", + "password" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Account account = new Account(client); - - account.updateEmail( - "email@example.com", - "password" - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/account/update-magic-u-r-l-session.md b/docs/examples/java/account/update-magic-u-r-l-session.md index d0734e1..e56da73 100644 --- a/docs/examples/java/account/update-magic-u-r-l-session.md +++ b/docs/examples/java/account/update-magic-u-r-l-session.md @@ -1,49 +1,22 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Account +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Account account = new Account(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +account.updateMagicURLSession( + "[USER_ID]", + "[SECRET]" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Account account = new Account(client); - - account.updateMagicURLSession( - "[USER_ID]", - "[SECRET]" - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/account/update-name.md b/docs/examples/java/account/update-name.md index 9842a22..c722c85 100644 --- a/docs/examples/java/account/update-name.md +++ b/docs/examples/java/account/update-name.md @@ -1,48 +1,21 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Account +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Account account = new Account(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +account.updateName( + "[NAME]" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Account account = new Account(client); - - account.updateName( - "[NAME]" - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/account/update-password.md b/docs/examples/java/account/update-password.md index 468bdc2..e16aac5 100644 --- a/docs/examples/java/account/update-password.md +++ b/docs/examples/java/account/update-password.md @@ -1,48 +1,21 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Account +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Account account = new Account(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +account.updatePassword( + "password", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Account account = new Account(client); - - account.updatePassword( - "password", - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/account/update-phone-session.md b/docs/examples/java/account/update-phone-session.md index f8d35c7..952c7e0 100644 --- a/docs/examples/java/account/update-phone-session.md +++ b/docs/examples/java/account/update-phone-session.md @@ -1,49 +1,22 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Account +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Account account = new Account(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +account.updatePhoneSession( + "[USER_ID]", + "[SECRET]" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Account account = new Account(client); - - account.updatePhoneSession( - "[USER_ID]", - "[SECRET]" - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/account/update-phone-verification.md b/docs/examples/java/account/update-phone-verification.md index 7aec064..ec5ddf1 100644 --- a/docs/examples/java/account/update-phone-verification.md +++ b/docs/examples/java/account/update-phone-verification.md @@ -1,49 +1,22 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Account +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Account account = new Account(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +account.updatePhoneVerification( + "[USER_ID]", + "[SECRET]" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Account account = new Account(client); - - account.updatePhoneVerification( - "[USER_ID]", - "[SECRET]" - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/account/update-phone.md b/docs/examples/java/account/update-phone.md index 37c54c8..61cff45 100644 --- a/docs/examples/java/account/update-phone.md +++ b/docs/examples/java/account/update-phone.md @@ -1,49 +1,22 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Account +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Account account = new Account(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +account.updatePhone( + "+12065550100", + "password" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Account account = new Account(client); - - account.updatePhone( - "", - "password" - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/account/update-prefs.md b/docs/examples/java/account/update-prefs.md index 9f94b8f..a004b45 100644 --- a/docs/examples/java/account/update-prefs.md +++ b/docs/examples/java/account/update-prefs.md @@ -1,48 +1,21 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Account +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Account account = new Account(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +account.updatePrefs( + mapOf( "a" to "b" ) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Account account = new Account(client); - - account.updatePrefs( - mapOf( "a" to "b" ) - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/account/update-recovery.md b/docs/examples/java/account/update-recovery.md index bfcc89e..e565a6b 100644 --- a/docs/examples/java/account/update-recovery.md +++ b/docs/examples/java/account/update-recovery.md @@ -1,51 +1,24 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Account +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Account account = new Account(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +account.updateRecovery( + "[USER_ID]", + "[SECRET]", + "password", + "password" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Account account = new Account(client); - - account.updateRecovery( - "[USER_ID]", - "[SECRET]", - "password", - "password" - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/account/update-session.md b/docs/examples/java/account/update-session.md index 80aff11..4c5d975 100644 --- a/docs/examples/java/account/update-session.md +++ b/docs/examples/java/account/update-session.md @@ -1,48 +1,21 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Account +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Account account = new Account(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +account.updateSession( + "[SESSION_ID]" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Account account = new Account(client); - - account.updateSession( - "[SESSION_ID]" - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/account/update-status.md b/docs/examples/java/account/update-status.md index 0ef6a6e..739469a 100644 --- a/docs/examples/java/account/update-status.md +++ b/docs/examples/java/account/update-status.md @@ -1,46 +1,18 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Account +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Account account = new Account(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - - Account account = new Account(client); - - account.updateStatus(new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - }); +account.updateStatus(new CoroutineCallback<>((result, error) -> { + if (error != null) + error.printStackTrace(); + return; } -} \ No newline at end of file + + Log.d("Appwrite", result.toString()); +})); diff --git a/docs/examples/java/account/update-verification.md b/docs/examples/java/account/update-verification.md index 8cf8d67..b05dbc2 100644 --- a/docs/examples/java/account/update-verification.md +++ b/docs/examples/java/account/update-verification.md @@ -1,49 +1,22 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Account +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Account account = new Account(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +account.updateVerification( + "[USER_ID]", + "[SECRET]" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Account account = new Account(client); - - account.updateVerification( - "[USER_ID]", - "[SECRET]" - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/avatars/get-browser.md b/docs/examples/java/avatars/get-browser.md index fa88749..8ad3f18 100644 --- a/docs/examples/java/avatars/get-browser.md +++ b/docs/examples/java/avatars/get-browser.md @@ -1,48 +1,21 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Avatars +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Avatars; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Avatars avatars = new Avatars(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +avatars.getBrowser( + "aa", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Avatars avatars = new Avatars(client); - - avatars.getBrowser( - "aa", - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/avatars/get-credit-card.md b/docs/examples/java/avatars/get-credit-card.md index 2ddda86..453718b 100644 --- a/docs/examples/java/avatars/get-credit-card.md +++ b/docs/examples/java/avatars/get-credit-card.md @@ -1,48 +1,21 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Avatars +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Avatars; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Avatars avatars = new Avatars(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +avatars.getCreditCard( + "amex", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Avatars avatars = new Avatars(client); - - avatars.getCreditCard( - "amex", - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/avatars/get-favicon.md b/docs/examples/java/avatars/get-favicon.md index 39c1432..a5b9fa6 100644 --- a/docs/examples/java/avatars/get-favicon.md +++ b/docs/examples/java/avatars/get-favicon.md @@ -1,48 +1,21 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Avatars +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Avatars; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Avatars avatars = new Avatars(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +avatars.getFavicon( + "https://example.com" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Avatars avatars = new Avatars(client); - - avatars.getFavicon( - "https://example.com" - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/avatars/get-flag.md b/docs/examples/java/avatars/get-flag.md index 77bf3b1..0bc4896 100644 --- a/docs/examples/java/avatars/get-flag.md +++ b/docs/examples/java/avatars/get-flag.md @@ -1,48 +1,21 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Avatars +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Avatars; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Avatars avatars = new Avatars(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +avatars.getFlag( + "af", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Avatars avatars = new Avatars(client); - - avatars.getFlag( - "af", - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/avatars/get-image.md b/docs/examples/java/avatars/get-image.md index 69371da..d77d79c 100644 --- a/docs/examples/java/avatars/get-image.md +++ b/docs/examples/java/avatars/get-image.md @@ -1,48 +1,21 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Avatars +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Avatars; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Avatars avatars = new Avatars(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +avatars.getImage( + "https://example.com", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Avatars avatars = new Avatars(client); - - avatars.getImage( - "https://example.com", - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/avatars/get-initials.md b/docs/examples/java/avatars/get-initials.md index eea5669..491724f 100644 --- a/docs/examples/java/avatars/get-initials.md +++ b/docs/examples/java/avatars/get-initials.md @@ -1,47 +1,20 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Avatars +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Avatars; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Avatars avatars = new Avatars(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +avatars.getInitials( + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Avatars avatars = new Avatars(client); - - avatars.getInitials( - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/avatars/get-q-r.md b/docs/examples/java/avatars/get-q-r.md index e2c48cd..ae1a11d 100644 --- a/docs/examples/java/avatars/get-q-r.md +++ b/docs/examples/java/avatars/get-q-r.md @@ -1,48 +1,21 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Avatars +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Avatars; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Avatars avatars = new Avatars(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +avatars.getQR( + "[TEXT]", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Avatars avatars = new Avatars(client); - - avatars.getQR( - "[TEXT]", - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/databases/create-document.md b/docs/examples/java/databases/create-document.md index 7fc322b..d4412ce 100644 --- a/docs/examples/java/databases/create-document.md +++ b/docs/examples/java/databases/create-document.md @@ -1,51 +1,24 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Databases +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Databases databases = new Databases(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +databases.createDocument( + "[DATABASE_ID]", + "[COLLECTION_ID]", + "[DOCUMENT_ID]", + mapOf( "a" to "b" ), + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Databases databases = new Databases(client); - - databases.createDocument( - "[DATABASE_ID]", - "[COLLECTION_ID]", - "[DOCUMENT_ID]", - mapOf( "a" to "b" ), - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/databases/delete-document.md b/docs/examples/java/databases/delete-document.md index f42a09b..90ad1ce 100644 --- a/docs/examples/java/databases/delete-document.md +++ b/docs/examples/java/databases/delete-document.md @@ -1,50 +1,23 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Databases +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Databases databases = new Databases(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +databases.deleteDocument( + "[DATABASE_ID]", + "[COLLECTION_ID]", + "[DOCUMENT_ID]" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Databases databases = new Databases(client); - - databases.deleteDocument( - "[DATABASE_ID]", - "[COLLECTION_ID]", - "[DOCUMENT_ID]" - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/databases/get-document.md b/docs/examples/java/databases/get-document.md index f1a4d44..f4e7dc6 100644 --- a/docs/examples/java/databases/get-document.md +++ b/docs/examples/java/databases/get-document.md @@ -1,50 +1,23 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Databases +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Databases databases = new Databases(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +databases.getDocument( + "[DATABASE_ID]", + "[COLLECTION_ID]", + "[DOCUMENT_ID]" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Databases databases = new Databases(client); - - databases.getDocument( - "[DATABASE_ID]", - "[COLLECTION_ID]", - "[DOCUMENT_ID]" - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/databases/list-documents.md b/docs/examples/java/databases/list-documents.md index 93d7333..6b897df 100644 --- a/docs/examples/java/databases/list-documents.md +++ b/docs/examples/java/databases/list-documents.md @@ -1,49 +1,22 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Databases +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Databases databases = new Databases(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +databases.listDocuments( + "[DATABASE_ID]", + "[COLLECTION_ID]", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Databases databases = new Databases(client); - - databases.listDocuments( - "[DATABASE_ID]", - "[COLLECTION_ID]", - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/databases/update-document.md b/docs/examples/java/databases/update-document.md index 81e55d4..7f04c8e 100644 --- a/docs/examples/java/databases/update-document.md +++ b/docs/examples/java/databases/update-document.md @@ -1,50 +1,23 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Databases +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Databases databases = new Databases(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +databases.updateDocument( + "[DATABASE_ID]", + "[COLLECTION_ID]", + "[DOCUMENT_ID]", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Databases databases = new Databases(client); - - databases.updateDocument( - "[DATABASE_ID]", - "[COLLECTION_ID]", - "[DOCUMENT_ID]", - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/functions/create-execution.md b/docs/examples/java/functions/create-execution.md index ea30fad..ee4eaf5 100644 --- a/docs/examples/java/functions/create-execution.md +++ b/docs/examples/java/functions/create-execution.md @@ -1,48 +1,21 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Functions +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Functions; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Functions functions = new Functions(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +functions.createExecution( + "[FUNCTION_ID]", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Functions functions = new Functions(client); - - functions.createExecution( - "[FUNCTION_ID]", - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/functions/get-execution.md b/docs/examples/java/functions/get-execution.md index 2f4e57e..90153f5 100644 --- a/docs/examples/java/functions/get-execution.md +++ b/docs/examples/java/functions/get-execution.md @@ -1,49 +1,22 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Functions +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Functions; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Functions functions = new Functions(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +functions.getExecution( + "[FUNCTION_ID]", + "[EXECUTION_ID]" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Functions functions = new Functions(client); - - functions.getExecution( - "[FUNCTION_ID]", - "[EXECUTION_ID]" - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/functions/list-executions.md b/docs/examples/java/functions/list-executions.md index 68f767d..fca903b 100644 --- a/docs/examples/java/functions/list-executions.md +++ b/docs/examples/java/functions/list-executions.md @@ -1,48 +1,21 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Functions +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Functions; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Functions functions = new Functions(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +functions.listExecutions( + "[FUNCTION_ID]", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Functions functions = new Functions(client); - - functions.listExecutions( - "[FUNCTION_ID]", - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/functions/retry-build.md b/docs/examples/java/functions/retry-build.md deleted file mode 100644 index 96501a0..0000000 --- a/docs/examples/java/functions/retry-build.md +++ /dev/null @@ -1,50 +0,0 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Functions - -public class MainActivity extends AppCompatActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - - Functions functions = new Functions(client); - - functions.retryBuild( - "[FUNCTION_ID]", - "[DEPLOYMENT_ID]", - "[BUILD_ID]" - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file diff --git a/docs/examples/java/graphql/mutation.md b/docs/examples/java/graphql/mutation.md new file mode 100644 index 0000000..e6ced40 --- /dev/null +++ b/docs/examples/java/graphql/mutation.md @@ -0,0 +1,21 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Graphql; + +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Graphql graphql = new Graphql(client); + +graphql.mutation( + mapOf( "a" to "b" ) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/graphql/query.md b/docs/examples/java/graphql/query.md new file mode 100644 index 0000000..f0b8a86 --- /dev/null +++ b/docs/examples/java/graphql/query.md @@ -0,0 +1,21 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Graphql; + +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Graphql graphql = new Graphql(client); + +graphql.query( + mapOf( "a" to "b" ) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/locale/get-continents.md b/docs/examples/java/locale/get-continents.md deleted file mode 100644 index e96a9fe..0000000 --- a/docs/examples/java/locale/get-continents.md +++ /dev/null @@ -1,46 +0,0 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Locale - -public class MainActivity extends AppCompatActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - - Locale locale = new Locale(client); - - locale.getContinents(new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - }); - } -} \ No newline at end of file diff --git a/docs/examples/java/locale/get-countries-e-u.md b/docs/examples/java/locale/get-countries-e-u.md deleted file mode 100644 index ec478bc..0000000 --- a/docs/examples/java/locale/get-countries-e-u.md +++ /dev/null @@ -1,46 +0,0 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Locale - -public class MainActivity extends AppCompatActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - - Locale locale = new Locale(client); - - locale.getCountriesEU(new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - }); - } -} \ No newline at end of file diff --git a/docs/examples/java/locale/get-countries-phones.md b/docs/examples/java/locale/get-countries-phones.md deleted file mode 100644 index 34368d2..0000000 --- a/docs/examples/java/locale/get-countries-phones.md +++ /dev/null @@ -1,46 +0,0 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Locale - -public class MainActivity extends AppCompatActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - - Locale locale = new Locale(client); - - locale.getCountriesPhones(new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - }); - } -} \ No newline at end of file diff --git a/docs/examples/java/locale/get-countries.md b/docs/examples/java/locale/get-countries.md deleted file mode 100644 index f1c50fc..0000000 --- a/docs/examples/java/locale/get-countries.md +++ /dev/null @@ -1,46 +0,0 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Locale - -public class MainActivity extends AppCompatActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - - Locale locale = new Locale(client); - - locale.getCountries(new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - }); - } -} \ No newline at end of file diff --git a/docs/examples/java/locale/get-currencies.md b/docs/examples/java/locale/get-currencies.md deleted file mode 100644 index 63af14b..0000000 --- a/docs/examples/java/locale/get-currencies.md +++ /dev/null @@ -1,46 +0,0 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Locale - -public class MainActivity extends AppCompatActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - - Locale locale = new Locale(client); - - locale.getCurrencies(new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - }); - } -} \ No newline at end of file diff --git a/docs/examples/java/locale/get-languages.md b/docs/examples/java/locale/get-languages.md deleted file mode 100644 index 5952daa..0000000 --- a/docs/examples/java/locale/get-languages.md +++ /dev/null @@ -1,46 +0,0 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Locale - -public class MainActivity extends AppCompatActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - - Locale locale = new Locale(client); - - locale.getLanguages(new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - }); - } -} \ No newline at end of file diff --git a/docs/examples/java/locale/get.md b/docs/examples/java/locale/get.md index 417fc16..89de369 100644 --- a/docs/examples/java/locale/get.md +++ b/docs/examples/java/locale/get.md @@ -1,46 +1,18 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Locale +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Locale; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Locale locale = new Locale(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - - Locale locale = new Locale(client); - - locale.get(new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - }); +locale.get(new CoroutineCallback<>((result, error) -> { + if (error != null) + error.printStackTrace(); + return; } -} \ No newline at end of file + + Log.d("Appwrite", result.toString()); +})); diff --git a/docs/examples/java/locale/list-continents.md b/docs/examples/java/locale/list-continents.md index 970f066..7205ad6 100644 --- a/docs/examples/java/locale/list-continents.md +++ b/docs/examples/java/locale/list-continents.md @@ -1,46 +1,18 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Locale +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Locale; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Locale locale = new Locale(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - - Locale locale = new Locale(client); - - locale.listContinents(new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - }); +locale.listContinents(new CoroutineCallback<>((result, error) -> { + if (error != null) + error.printStackTrace(); + return; } -} \ No newline at end of file + + Log.d("Appwrite", result.toString()); +})); diff --git a/docs/examples/java/locale/list-countries-e-u.md b/docs/examples/java/locale/list-countries-e-u.md index b2d0b29..d6f37be 100644 --- a/docs/examples/java/locale/list-countries-e-u.md +++ b/docs/examples/java/locale/list-countries-e-u.md @@ -1,46 +1,18 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Locale +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Locale; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Locale locale = new Locale(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - - Locale locale = new Locale(client); - - locale.listCountriesEU(new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - }); +locale.listCountriesEU(new CoroutineCallback<>((result, error) -> { + if (error != null) + error.printStackTrace(); + return; } -} \ No newline at end of file + + Log.d("Appwrite", result.toString()); +})); diff --git a/docs/examples/java/locale/list-countries-phones.md b/docs/examples/java/locale/list-countries-phones.md index ed4d1f4..1f947fe 100644 --- a/docs/examples/java/locale/list-countries-phones.md +++ b/docs/examples/java/locale/list-countries-phones.md @@ -1,46 +1,18 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Locale +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Locale; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Locale locale = new Locale(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - - Locale locale = new Locale(client); - - locale.listCountriesPhones(new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - }); +locale.listCountriesPhones(new CoroutineCallback<>((result, error) -> { + if (error != null) + error.printStackTrace(); + return; } -} \ No newline at end of file + + Log.d("Appwrite", result.toString()); +})); diff --git a/docs/examples/java/locale/list-countries.md b/docs/examples/java/locale/list-countries.md index cb4000f..5b8c0ba 100644 --- a/docs/examples/java/locale/list-countries.md +++ b/docs/examples/java/locale/list-countries.md @@ -1,46 +1,18 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Locale +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Locale; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Locale locale = new Locale(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - - Locale locale = new Locale(client); - - locale.listCountries(new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - }); +locale.listCountries(new CoroutineCallback<>((result, error) -> { + if (error != null) + error.printStackTrace(); + return; } -} \ No newline at end of file + + Log.d("Appwrite", result.toString()); +})); diff --git a/docs/examples/java/locale/list-currencies.md b/docs/examples/java/locale/list-currencies.md index 5423698..880e1b2 100644 --- a/docs/examples/java/locale/list-currencies.md +++ b/docs/examples/java/locale/list-currencies.md @@ -1,46 +1,18 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Locale +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Locale; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Locale locale = new Locale(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - - Locale locale = new Locale(client); - - locale.listCurrencies(new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - }); +locale.listCurrencies(new CoroutineCallback<>((result, error) -> { + if (error != null) + error.printStackTrace(); + return; } -} \ No newline at end of file + + Log.d("Appwrite", result.toString()); +})); diff --git a/docs/examples/java/locale/list-languages.md b/docs/examples/java/locale/list-languages.md index 158c0e5..318c6dc 100644 --- a/docs/examples/java/locale/list-languages.md +++ b/docs/examples/java/locale/list-languages.md @@ -1,46 +1,18 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Locale +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Locale; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Locale locale = new Locale(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - - Locale locale = new Locale(client); - - locale.listLanguages(new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - }); +locale.listLanguages(new CoroutineCallback<>((result, error) -> { + if (error != null) + error.printStackTrace(); + return; } -} \ No newline at end of file + + Log.d("Appwrite", result.toString()); +})); diff --git a/docs/examples/java/storage/create-file.md b/docs/examples/java/storage/create-file.md index 32e0fd0..161f882 100644 --- a/docs/examples/java/storage/create-file.md +++ b/docs/examples/java/storage/create-file.md @@ -1,51 +1,24 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.models.InputFile -import io.appwrite.services.Storage +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.models.InputFile; +import io.appwrite.services.Storage; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Storage storage = new Storage(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +storage.createFile( + "[BUCKET_ID]", + "[FILE_ID]", + InputFile.fromPath("file.png"), + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Storage storage = new Storage(client); - - storage.createFile( - "[BUCKET_ID]", - "[FILE_ID]", - InputFile.fromPath("file.png"), - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/storage/delete-file.md b/docs/examples/java/storage/delete-file.md index 585593a..654c127 100644 --- a/docs/examples/java/storage/delete-file.md +++ b/docs/examples/java/storage/delete-file.md @@ -1,49 +1,22 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Storage +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Storage; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Storage storage = new Storage(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +storage.deleteFile( + "[BUCKET_ID]", + "[FILE_ID]" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Storage storage = new Storage(client); - - storage.deleteFile( - "[BUCKET_ID]", - "[FILE_ID]" - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/storage/get-file-download.md b/docs/examples/java/storage/get-file-download.md index b162248..f12302a 100644 --- a/docs/examples/java/storage/get-file-download.md +++ b/docs/examples/java/storage/get-file-download.md @@ -1,49 +1,22 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Storage +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Storage; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Storage storage = new Storage(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +storage.getFileDownload( + "[BUCKET_ID]", + "[FILE_ID]" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Storage storage = new Storage(client); - - storage.getFileDownload( - "[BUCKET_ID]", - "[FILE_ID]" - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/storage/get-file-preview.md b/docs/examples/java/storage/get-file-preview.md index 583c1a0..8487922 100644 --- a/docs/examples/java/storage/get-file-preview.md +++ b/docs/examples/java/storage/get-file-preview.md @@ -1,49 +1,22 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Storage +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Storage; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Storage storage = new Storage(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +storage.getFilePreview( + "[BUCKET_ID]", + "[FILE_ID]", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Storage storage = new Storage(client); - - storage.getFilePreview( - "[BUCKET_ID]", - "[FILE_ID]", - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/storage/get-file-view.md b/docs/examples/java/storage/get-file-view.md index 21a5074..825b538 100644 --- a/docs/examples/java/storage/get-file-view.md +++ b/docs/examples/java/storage/get-file-view.md @@ -1,49 +1,22 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Storage +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Storage; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Storage storage = new Storage(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +storage.getFileView( + "[BUCKET_ID]", + "[FILE_ID]" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Storage storage = new Storage(client); - - storage.getFileView( - "[BUCKET_ID]", - "[FILE_ID]" - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/storage/get-file.md b/docs/examples/java/storage/get-file.md index 61740a9..bf97922 100644 --- a/docs/examples/java/storage/get-file.md +++ b/docs/examples/java/storage/get-file.md @@ -1,49 +1,22 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Storage +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Storage; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Storage storage = new Storage(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +storage.getFile( + "[BUCKET_ID]", + "[FILE_ID]" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Storage storage = new Storage(client); - - storage.getFile( - "[BUCKET_ID]", - "[FILE_ID]" - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/storage/list-files.md b/docs/examples/java/storage/list-files.md index a7ea06e..fdf3e4f 100644 --- a/docs/examples/java/storage/list-files.md +++ b/docs/examples/java/storage/list-files.md @@ -1,48 +1,21 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Storage +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Storage; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Storage storage = new Storage(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +storage.listFiles( + "[BUCKET_ID]", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Storage storage = new Storage(client); - - storage.listFiles( - "[BUCKET_ID]", - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/storage/update-file.md b/docs/examples/java/storage/update-file.md index b3e8e90..9d9f192 100644 --- a/docs/examples/java/storage/update-file.md +++ b/docs/examples/java/storage/update-file.md @@ -1,49 +1,22 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Storage +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Storage; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Storage storage = new Storage(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +storage.updateFile( + "[BUCKET_ID]", + "[FILE_ID]", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Storage storage = new Storage(client); - - storage.updateFile( - "[BUCKET_ID]", - "[FILE_ID]", - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/teams/create-membership.md b/docs/examples/java/teams/create-membership.md index f4d96de..9d567d6 100644 --- a/docs/examples/java/teams/create-membership.md +++ b/docs/examples/java/teams/create-membership.md @@ -1,51 +1,24 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Teams +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Teams; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Teams teams = new Teams(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +teams.createMembership( + "[TEAM_ID]", + "email@example.com", + listOf(), + "https://example.com", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Teams teams = new Teams(client); - - teams.createMembership( - "[TEAM_ID]", - "email@example.com", - listOf(), - "https://example.com", - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/teams/create.md b/docs/examples/java/teams/create.md index 3723b30..52207c6 100644 --- a/docs/examples/java/teams/create.md +++ b/docs/examples/java/teams/create.md @@ -1,49 +1,22 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Teams +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Teams; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Teams teams = new Teams(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +teams.create( + "[TEAM_ID]", + "[NAME]", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Teams teams = new Teams(client); - - teams.create( - "[TEAM_ID]", - "[NAME]", - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/teams/delete-membership.md b/docs/examples/java/teams/delete-membership.md index 98cb29a..92d6d37 100644 --- a/docs/examples/java/teams/delete-membership.md +++ b/docs/examples/java/teams/delete-membership.md @@ -1,49 +1,22 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Teams +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Teams; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Teams teams = new Teams(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +teams.deleteMembership( + "[TEAM_ID]", + "[MEMBERSHIP_ID]" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Teams teams = new Teams(client); - - teams.deleteMembership( - "[TEAM_ID]", - "[MEMBERSHIP_ID]" - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/teams/delete.md b/docs/examples/java/teams/delete.md index 828b457..ed81195 100644 --- a/docs/examples/java/teams/delete.md +++ b/docs/examples/java/teams/delete.md @@ -1,48 +1,21 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Teams +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Teams; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Teams teams = new Teams(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +teams.delete( + "[TEAM_ID]" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Teams teams = new Teams(client); - - teams.delete( - "[TEAM_ID]" - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/teams/get-membership.md b/docs/examples/java/teams/get-membership.md index 87c0160..7e29171 100644 --- a/docs/examples/java/teams/get-membership.md +++ b/docs/examples/java/teams/get-membership.md @@ -1,49 +1,22 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Teams +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Teams; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Teams teams = new Teams(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +teams.getMembership( + "[TEAM_ID]", + "[MEMBERSHIP_ID]" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Teams teams = new Teams(client); - - teams.getMembership( - "[TEAM_ID]", - "[MEMBERSHIP_ID]" - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/teams/get-memberships.md b/docs/examples/java/teams/get-memberships.md deleted file mode 100644 index d8a4100..0000000 --- a/docs/examples/java/teams/get-memberships.md +++ /dev/null @@ -1,48 +0,0 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Teams - -public class MainActivity extends AppCompatActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - - Teams teams = new Teams(client); - - teams.getMemberships( - "[TEAM_ID]", - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file diff --git a/docs/examples/java/teams/get.md b/docs/examples/java/teams/get.md index 53ba33c..36063c5 100644 --- a/docs/examples/java/teams/get.md +++ b/docs/examples/java/teams/get.md @@ -1,48 +1,21 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Teams +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Teams; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Teams teams = new Teams(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +teams.get( + "[TEAM_ID]" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Teams teams = new Teams(client); - - teams.get( - "[TEAM_ID]" - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/teams/list-memberships.md b/docs/examples/java/teams/list-memberships.md index c53493d..d195978 100644 --- a/docs/examples/java/teams/list-memberships.md +++ b/docs/examples/java/teams/list-memberships.md @@ -1,48 +1,21 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Teams +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Teams; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Teams teams = new Teams(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +teams.listMemberships( + "[TEAM_ID]", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Teams teams = new Teams(client); - - teams.listMemberships( - "[TEAM_ID]", - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/teams/list.md b/docs/examples/java/teams/list.md index 61c2aa3..b4998ff 100644 --- a/docs/examples/java/teams/list.md +++ b/docs/examples/java/teams/list.md @@ -1,47 +1,20 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Teams +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Teams; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Teams teams = new Teams(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +teams.list( + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Teams teams = new Teams(client); - - teams.list( - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/teams/update-membership-roles.md b/docs/examples/java/teams/update-membership-roles.md index ef6c673..680c9a3 100644 --- a/docs/examples/java/teams/update-membership-roles.md +++ b/docs/examples/java/teams/update-membership-roles.md @@ -1,50 +1,23 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Teams +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Teams; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Teams teams = new Teams(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +teams.updateMembershipRoles( + "[TEAM_ID]", + "[MEMBERSHIP_ID]", + listOf() + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Teams teams = new Teams(client); - - teams.updateMembershipRoles( - "[TEAM_ID]", - "[MEMBERSHIP_ID]", - listOf() - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/teams/update-membership-status.md b/docs/examples/java/teams/update-membership-status.md index 447d0da..1015b2e 100644 --- a/docs/examples/java/teams/update-membership-status.md +++ b/docs/examples/java/teams/update-membership-status.md @@ -1,51 +1,24 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Teams +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Teams; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Teams teams = new Teams(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +teams.updateMembershipStatus( + "[TEAM_ID]", + "[MEMBERSHIP_ID]", + "[USER_ID]", + "[SECRET]" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Teams teams = new Teams(client); - - teams.updateMembershipStatus( - "[TEAM_ID]", - "[MEMBERSHIP_ID]", - "[USER_ID]", - "[SECRET]" - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/teams/update.md b/docs/examples/java/teams/update.md index b4df429..86d6a3f 100644 --- a/docs/examples/java/teams/update.md +++ b/docs/examples/java/teams/update.md @@ -1,49 +1,22 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Teams +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Teams; -public class MainActivity extends AppCompatActivity { +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); +Teams teams = new Teams(client); - Client client = new Client(getApplicationContext()) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID +teams.update( + "[TEAM_ID]", + "[NAME]" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } - Teams teams = new Teams(client); - - teams.update( - "[TEAM_ID]", - "[NAME]" - new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - String json = ""; - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Response response = (Response) o; - json = response.body().string(); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - } - ); - } -} \ No newline at end of file + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/kotlin/account/create-anonymous-session.md b/docs/examples/kotlin/account/create-anonymous-session.md index 5fa0699..ccefc0a 100644 --- a/docs/examples/kotlin/account/create-anonymous-session.md +++ b/docs/examples/kotlin/account/create-anonymous-session.md @@ -1,24 +1,10 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Account -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val account = Account(client) - val account = Account(client) - - GlobalScope.launch { - val response = account.createAnonymousSession() - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = account.createAnonymousSession() diff --git a/docs/examples/kotlin/account/create-email-session.md b/docs/examples/kotlin/account/create-email-session.md index 5dcec23..c58799c 100644 --- a/docs/examples/kotlin/account/create-email-session.md +++ b/docs/examples/kotlin/account/create-email-session.md @@ -1,27 +1,13 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Account -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val account = Account(client) - val account = Account(client) - - GlobalScope.launch { - val response = account.createEmailSession( - email = "email@example.com", - password = "password" - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = account.createEmailSession( + email = "email@example.com", + password = "password" +) diff --git a/docs/examples/kotlin/account/create-j-w-t.md b/docs/examples/kotlin/account/create-j-w-t.md index 212838b..59b7398 100644 --- a/docs/examples/kotlin/account/create-j-w-t.md +++ b/docs/examples/kotlin/account/create-j-w-t.md @@ -1,24 +1,10 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Account -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val account = Account(client) - val account = Account(client) - - GlobalScope.launch { - val response = account.createJWT() - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = account.createJWT() diff --git a/docs/examples/kotlin/account/create-magic-u-r-l-session.md b/docs/examples/kotlin/account/create-magic-u-r-l-session.md index 15fa1c7..5f36940 100644 --- a/docs/examples/kotlin/account/create-magic-u-r-l-session.md +++ b/docs/examples/kotlin/account/create-magic-u-r-l-session.md @@ -1,27 +1,13 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Account -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val account = Account(client) - val account = Account(client) - - GlobalScope.launch { - val response = account.createMagicURLSession( - userId = "[USER_ID]", - email = "email@example.com", - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = account.createMagicURLSession( + userId = "[USER_ID]", + email = "email@example.com", +) diff --git a/docs/examples/kotlin/account/create-o-auth2session.md b/docs/examples/kotlin/account/create-o-auth2session.md index baf9930..f909b59 100644 --- a/docs/examples/kotlin/account/create-o-auth2session.md +++ b/docs/examples/kotlin/account/create-o-auth2session.md @@ -1,27 +1,12 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Account -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val account = Account(client) - val account = Account(client) - - GlobalScope.launch { - account.createOAuth2Session( - activity = this@MainActivity, - provider = "amazon", - ) - - } - } -} \ No newline at end of file +account.createOAuth2Session( + provider = "amazon", +) diff --git a/docs/examples/kotlin/account/create-phone-session.md b/docs/examples/kotlin/account/create-phone-session.md index 2df83ad..8f63c64 100644 --- a/docs/examples/kotlin/account/create-phone-session.md +++ b/docs/examples/kotlin/account/create-phone-session.md @@ -1,27 +1,13 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Account -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val account = Account(client) - val account = Account(client) - - GlobalScope.launch { - val response = account.createPhoneSession( - userId = "[USER_ID]", - phone = "" - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = account.createPhoneSession( + userId = "[USER_ID]", + phone = "+12065550100" +) diff --git a/docs/examples/kotlin/account/create-phone-verification.md b/docs/examples/kotlin/account/create-phone-verification.md index ab0eccf..af36502 100644 --- a/docs/examples/kotlin/account/create-phone-verification.md +++ b/docs/examples/kotlin/account/create-phone-verification.md @@ -1,24 +1,10 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Account -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val account = Account(client) - val account = Account(client) - - GlobalScope.launch { - val response = account.createPhoneVerification() - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = account.createPhoneVerification() diff --git a/docs/examples/kotlin/account/create-recovery.md b/docs/examples/kotlin/account/create-recovery.md index 2c1e759..23a3424 100644 --- a/docs/examples/kotlin/account/create-recovery.md +++ b/docs/examples/kotlin/account/create-recovery.md @@ -1,27 +1,13 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Account -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val account = Account(client) - val account = Account(client) - - GlobalScope.launch { - val response = account.createRecovery( - email = "email@example.com", - url = "https://example.com" - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = account.createRecovery( + email = "email@example.com", + url = "https://example.com" +) diff --git a/docs/examples/kotlin/account/create-verification.md b/docs/examples/kotlin/account/create-verification.md index 1ebddee..3fed01b 100644 --- a/docs/examples/kotlin/account/create-verification.md +++ b/docs/examples/kotlin/account/create-verification.md @@ -1,26 +1,12 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Account -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val account = Account(client) - val account = Account(client) - - GlobalScope.launch { - val response = account.createVerification( - url = "https://example.com" - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = account.createVerification( + url = "https://example.com" +) diff --git a/docs/examples/kotlin/account/create.md b/docs/examples/kotlin/account/create.md index ab2534f..2a55fb1 100644 --- a/docs/examples/kotlin/account/create.md +++ b/docs/examples/kotlin/account/create.md @@ -1,28 +1,14 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Account -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val account = Account(client) - val account = Account(client) - - GlobalScope.launch { - val response = account.create( - userId = "[USER_ID]", - email = "email@example.com", - password = "password", - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = account.create( + userId = "[USER_ID]", + email = "email@example.com", + password = "password", +) diff --git a/docs/examples/kotlin/account/delete-session.md b/docs/examples/kotlin/account/delete-session.md index e670623..5c8988f 100644 --- a/docs/examples/kotlin/account/delete-session.md +++ b/docs/examples/kotlin/account/delete-session.md @@ -1,26 +1,12 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Account -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val account = Account(client) - val account = Account(client) - - GlobalScope.launch { - val response = account.deleteSession( - sessionId = "[SESSION_ID]" - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = account.deleteSession( + sessionId = "[SESSION_ID]" +) diff --git a/docs/examples/kotlin/account/delete-sessions.md b/docs/examples/kotlin/account/delete-sessions.md index ec30efd..86c9bc9 100644 --- a/docs/examples/kotlin/account/delete-sessions.md +++ b/docs/examples/kotlin/account/delete-sessions.md @@ -1,24 +1,10 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Account -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val account = Account(client) - val account = Account(client) - - GlobalScope.launch { - val response = account.deleteSessions() - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = account.deleteSessions() diff --git a/docs/examples/kotlin/account/get-logs.md b/docs/examples/kotlin/account/get-logs.md deleted file mode 100644 index b8c89f4..0000000 --- a/docs/examples/kotlin/account/get-logs.md +++ /dev/null @@ -1,25 +0,0 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Account - -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) - - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID - - val account = Account(client) - - GlobalScope.launch { - val response = account.getLogs( - ) - val json = response.body?.string() - } - } -} \ No newline at end of file diff --git a/docs/examples/kotlin/account/get-prefs.md b/docs/examples/kotlin/account/get-prefs.md index 9378cd2..70fa291 100644 --- a/docs/examples/kotlin/account/get-prefs.md +++ b/docs/examples/kotlin/account/get-prefs.md @@ -1,24 +1,10 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Account -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val account = Account(client) - val account = Account(client) - - GlobalScope.launch { - val response = account.getPrefs() - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = account.getPrefs() diff --git a/docs/examples/kotlin/account/get-session.md b/docs/examples/kotlin/account/get-session.md index 45f00b6..58248ae 100644 --- a/docs/examples/kotlin/account/get-session.md +++ b/docs/examples/kotlin/account/get-session.md @@ -1,26 +1,12 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Account -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val account = Account(client) - val account = Account(client) - - GlobalScope.launch { - val response = account.getSession( - sessionId = "[SESSION_ID]" - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = account.getSession( + sessionId = "[SESSION_ID]" +) diff --git a/docs/examples/kotlin/account/get-sessions.md b/docs/examples/kotlin/account/get-sessions.md deleted file mode 100644 index 4f939cc..0000000 --- a/docs/examples/kotlin/account/get-sessions.md +++ /dev/null @@ -1,24 +0,0 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Account - -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) - - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID - - val account = Account(client) - - GlobalScope.launch { - val response = account.getSessions() - val json = response.body?.string() - } - } -} \ No newline at end of file diff --git a/docs/examples/kotlin/account/get.md b/docs/examples/kotlin/account/get.md index c4c81a2..09b0a17 100644 --- a/docs/examples/kotlin/account/get.md +++ b/docs/examples/kotlin/account/get.md @@ -1,24 +1,10 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Account -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val account = Account(client) - val account = Account(client) - - GlobalScope.launch { - val response = account.get() - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = account.get() diff --git a/docs/examples/kotlin/account/list-logs.md b/docs/examples/kotlin/account/list-logs.md index 397906b..dda9c72 100644 --- a/docs/examples/kotlin/account/list-logs.md +++ b/docs/examples/kotlin/account/list-logs.md @@ -1,25 +1,11 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Account -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val account = Account(client) - val account = Account(client) - - GlobalScope.launch { - val response = account.listLogs( - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = account.listLogs( +) diff --git a/docs/examples/kotlin/account/list-sessions.md b/docs/examples/kotlin/account/list-sessions.md index 0a0bc73..b7bb447 100644 --- a/docs/examples/kotlin/account/list-sessions.md +++ b/docs/examples/kotlin/account/list-sessions.md @@ -1,24 +1,10 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Account -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val account = Account(client) - val account = Account(client) - - GlobalScope.launch { - val response = account.listSessions() - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = account.listSessions() diff --git a/docs/examples/kotlin/account/update-email.md b/docs/examples/kotlin/account/update-email.md index a9ec88b..2d1b66b 100644 --- a/docs/examples/kotlin/account/update-email.md +++ b/docs/examples/kotlin/account/update-email.md @@ -1,27 +1,13 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Account -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val account = Account(client) - val account = Account(client) - - GlobalScope.launch { - val response = account.updateEmail( - email = "email@example.com", - password = "password" - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = account.updateEmail( + email = "email@example.com", + password = "password" +) diff --git a/docs/examples/kotlin/account/update-magic-u-r-l-session.md b/docs/examples/kotlin/account/update-magic-u-r-l-session.md index 3fe1b7c..49af217 100644 --- a/docs/examples/kotlin/account/update-magic-u-r-l-session.md +++ b/docs/examples/kotlin/account/update-magic-u-r-l-session.md @@ -1,27 +1,13 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Account -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val account = Account(client) - val account = Account(client) - - GlobalScope.launch { - val response = account.updateMagicURLSession( - userId = "[USER_ID]", - secret = "[SECRET]" - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = account.updateMagicURLSession( + userId = "[USER_ID]", + secret = "[SECRET]" +) diff --git a/docs/examples/kotlin/account/update-name.md b/docs/examples/kotlin/account/update-name.md index ce9d8a3..5799344 100644 --- a/docs/examples/kotlin/account/update-name.md +++ b/docs/examples/kotlin/account/update-name.md @@ -1,26 +1,12 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Account -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val account = Account(client) - val account = Account(client) - - GlobalScope.launch { - val response = account.updateName( - name = "[NAME]" - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = account.updateName( + name = "[NAME]" +) diff --git a/docs/examples/kotlin/account/update-password.md b/docs/examples/kotlin/account/update-password.md index edee78e..cdf8178 100644 --- a/docs/examples/kotlin/account/update-password.md +++ b/docs/examples/kotlin/account/update-password.md @@ -1,26 +1,12 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Account -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val account = Account(client) - val account = Account(client) - - GlobalScope.launch { - val response = account.updatePassword( - password = "password", - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = account.updatePassword( + password = "password", +) diff --git a/docs/examples/kotlin/account/update-phone-session.md b/docs/examples/kotlin/account/update-phone-session.md index c981991..6efa2a4 100644 --- a/docs/examples/kotlin/account/update-phone-session.md +++ b/docs/examples/kotlin/account/update-phone-session.md @@ -1,27 +1,13 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Account -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val account = Account(client) - val account = Account(client) - - GlobalScope.launch { - val response = account.updatePhoneSession( - userId = "[USER_ID]", - secret = "[SECRET]" - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = account.updatePhoneSession( + userId = "[USER_ID]", + secret = "[SECRET]" +) diff --git a/docs/examples/kotlin/account/update-phone-verification.md b/docs/examples/kotlin/account/update-phone-verification.md index aa5eea3..1b90372 100644 --- a/docs/examples/kotlin/account/update-phone-verification.md +++ b/docs/examples/kotlin/account/update-phone-verification.md @@ -1,27 +1,13 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Account -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val account = Account(client) - val account = Account(client) - - GlobalScope.launch { - val response = account.updatePhoneVerification( - userId = "[USER_ID]", - secret = "[SECRET]" - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = account.updatePhoneVerification( + userId = "[USER_ID]", + secret = "[SECRET]" +) diff --git a/docs/examples/kotlin/account/update-phone.md b/docs/examples/kotlin/account/update-phone.md index 8ffef51..0534220 100644 --- a/docs/examples/kotlin/account/update-phone.md +++ b/docs/examples/kotlin/account/update-phone.md @@ -1,27 +1,13 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Account -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val account = Account(client) - val account = Account(client) - - GlobalScope.launch { - val response = account.updatePhone( - phone = "", - password = "password" - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = account.updatePhone( + phone = "+12065550100", + password = "password" +) diff --git a/docs/examples/kotlin/account/update-prefs.md b/docs/examples/kotlin/account/update-prefs.md index 3059bc8..408988b 100644 --- a/docs/examples/kotlin/account/update-prefs.md +++ b/docs/examples/kotlin/account/update-prefs.md @@ -1,26 +1,12 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Account -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val account = Account(client) - val account = Account(client) - - GlobalScope.launch { - val response = account.updatePrefs( - prefs = mapOf( "a" to "b" ) - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = account.updatePrefs( + prefs = mapOf( "a" to "b" ) +) diff --git a/docs/examples/kotlin/account/update-recovery.md b/docs/examples/kotlin/account/update-recovery.md index 81c00b4..fd28f6e 100644 --- a/docs/examples/kotlin/account/update-recovery.md +++ b/docs/examples/kotlin/account/update-recovery.md @@ -1,29 +1,15 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Account -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val account = Account(client) - val account = Account(client) - - GlobalScope.launch { - val response = account.updateRecovery( - userId = "[USER_ID]", - secret = "[SECRET]", - password = "password", - passwordAgain = "password" - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = account.updateRecovery( + userId = "[USER_ID]", + secret = "[SECRET]", + password = "password", + passwordAgain = "password" +) diff --git a/docs/examples/kotlin/account/update-session.md b/docs/examples/kotlin/account/update-session.md index 465320d..67d900e 100644 --- a/docs/examples/kotlin/account/update-session.md +++ b/docs/examples/kotlin/account/update-session.md @@ -1,26 +1,12 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Account -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val account = Account(client) - val account = Account(client) - - GlobalScope.launch { - val response = account.updateSession( - sessionId = "[SESSION_ID]" - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = account.updateSession( + sessionId = "[SESSION_ID]" +) diff --git a/docs/examples/kotlin/account/update-status.md b/docs/examples/kotlin/account/update-status.md index e138751..35a4027 100644 --- a/docs/examples/kotlin/account/update-status.md +++ b/docs/examples/kotlin/account/update-status.md @@ -1,24 +1,10 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Account -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val account = Account(client) - val account = Account(client) - - GlobalScope.launch { - val response = account.updateStatus() - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = account.updateStatus() diff --git a/docs/examples/kotlin/account/update-verification.md b/docs/examples/kotlin/account/update-verification.md index cea2592..f87192e 100644 --- a/docs/examples/kotlin/account/update-verification.md +++ b/docs/examples/kotlin/account/update-verification.md @@ -1,27 +1,13 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Account -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val account = Account(client) - val account = Account(client) - - GlobalScope.launch { - val response = account.updateVerification( - userId = "[USER_ID]", - secret = "[SECRET]" - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = account.updateVerification( + userId = "[USER_ID]", + secret = "[SECRET]" +) diff --git a/docs/examples/kotlin/avatars/get-browser.md b/docs/examples/kotlin/avatars/get-browser.md index 95a2201..9ea6739 100644 --- a/docs/examples/kotlin/avatars/get-browser.md +++ b/docs/examples/kotlin/avatars/get-browser.md @@ -1,26 +1,12 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Avatars -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val avatars = Avatars(client) - val avatars = Avatars(client) - - GlobalScope.launch { - val result = avatars.getBrowser( - code = "aa", - ) - println(result); // Resource URL - } - } -} \ No newline at end of file +val result = avatars.getBrowser( + code = "aa", +) diff --git a/docs/examples/kotlin/avatars/get-credit-card.md b/docs/examples/kotlin/avatars/get-credit-card.md index 7507c40..cf82474 100644 --- a/docs/examples/kotlin/avatars/get-credit-card.md +++ b/docs/examples/kotlin/avatars/get-credit-card.md @@ -1,26 +1,12 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Avatars -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val avatars = Avatars(client) - val avatars = Avatars(client) - - GlobalScope.launch { - val result = avatars.getCreditCard( - code = "amex", - ) - println(result); // Resource URL - } - } -} \ No newline at end of file +val result = avatars.getCreditCard( + code = "amex", +) diff --git a/docs/examples/kotlin/avatars/get-favicon.md b/docs/examples/kotlin/avatars/get-favicon.md index f8e2b40..102d773 100644 --- a/docs/examples/kotlin/avatars/get-favicon.md +++ b/docs/examples/kotlin/avatars/get-favicon.md @@ -1,26 +1,12 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Avatars -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val avatars = Avatars(client) - val avatars = Avatars(client) - - GlobalScope.launch { - val result = avatars.getFavicon( - url = "https://example.com" - ) - println(result); // Resource URL - } - } -} \ No newline at end of file +val result = avatars.getFavicon( + url = "https://example.com" +) diff --git a/docs/examples/kotlin/avatars/get-flag.md b/docs/examples/kotlin/avatars/get-flag.md index 738ec8a..7a618a7 100644 --- a/docs/examples/kotlin/avatars/get-flag.md +++ b/docs/examples/kotlin/avatars/get-flag.md @@ -1,26 +1,12 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Avatars -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val avatars = Avatars(client) - val avatars = Avatars(client) - - GlobalScope.launch { - val result = avatars.getFlag( - code = "af", - ) - println(result); // Resource URL - } - } -} \ No newline at end of file +val result = avatars.getFlag( + code = "af", +) diff --git a/docs/examples/kotlin/avatars/get-image.md b/docs/examples/kotlin/avatars/get-image.md index 25171b1..fc1fe1d 100644 --- a/docs/examples/kotlin/avatars/get-image.md +++ b/docs/examples/kotlin/avatars/get-image.md @@ -1,26 +1,12 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Avatars -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val avatars = Avatars(client) - val avatars = Avatars(client) - - GlobalScope.launch { - val result = avatars.getImage( - url = "https://example.com", - ) - println(result); // Resource URL - } - } -} \ No newline at end of file +val result = avatars.getImage( + url = "https://example.com", +) diff --git a/docs/examples/kotlin/avatars/get-initials.md b/docs/examples/kotlin/avatars/get-initials.md index e53a647..448467e 100644 --- a/docs/examples/kotlin/avatars/get-initials.md +++ b/docs/examples/kotlin/avatars/get-initials.md @@ -1,25 +1,11 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Avatars -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val avatars = Avatars(client) - val avatars = Avatars(client) - - GlobalScope.launch { - val result = avatars.getInitials( - ) - println(result); // Resource URL - } - } -} \ No newline at end of file +val result = avatars.getInitials( +) diff --git a/docs/examples/kotlin/avatars/get-q-r.md b/docs/examples/kotlin/avatars/get-q-r.md index c9d60ea..8d24934 100644 --- a/docs/examples/kotlin/avatars/get-q-r.md +++ b/docs/examples/kotlin/avatars/get-q-r.md @@ -1,26 +1,12 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Avatars -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val avatars = Avatars(client) - val avatars = Avatars(client) - - GlobalScope.launch { - val result = avatars.getQR( - text = "[TEXT]", - ) - println(result); // Resource URL - } - } -} \ No newline at end of file +val result = avatars.getQR( + text = "[TEXT]", +) diff --git a/docs/examples/kotlin/databases/create-document.md b/docs/examples/kotlin/databases/create-document.md index 8a755a2..da4d1eb 100644 --- a/docs/examples/kotlin/databases/create-document.md +++ b/docs/examples/kotlin/databases/create-document.md @@ -1,29 +1,15 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Databases -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val databases = Databases(client) - val databases = Databases(client) - - GlobalScope.launch { - val response = databases.createDocument( - databaseId = "[DATABASE_ID]", - collectionId = "[COLLECTION_ID]", - documentId = "[DOCUMENT_ID]", - data = mapOf( "a" to "b" ), - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = databases.createDocument( + databaseId = "[DATABASE_ID]", + collectionId = "[COLLECTION_ID]", + documentId = "[DOCUMENT_ID]", + data = mapOf( "a" to "b" ), +) diff --git a/docs/examples/kotlin/databases/delete-document.md b/docs/examples/kotlin/databases/delete-document.md index f56293b..bb2193e 100644 --- a/docs/examples/kotlin/databases/delete-document.md +++ b/docs/examples/kotlin/databases/delete-document.md @@ -1,28 +1,14 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Databases -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val databases = Databases(client) - val databases = Databases(client) - - GlobalScope.launch { - val response = databases.deleteDocument( - databaseId = "[DATABASE_ID]", - collectionId = "[COLLECTION_ID]", - documentId = "[DOCUMENT_ID]" - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = databases.deleteDocument( + databaseId = "[DATABASE_ID]", + collectionId = "[COLLECTION_ID]", + documentId = "[DOCUMENT_ID]" +) diff --git a/docs/examples/kotlin/databases/get-document.md b/docs/examples/kotlin/databases/get-document.md index 1f5bf29..b81f340 100644 --- a/docs/examples/kotlin/databases/get-document.md +++ b/docs/examples/kotlin/databases/get-document.md @@ -1,28 +1,14 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Databases -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val databases = Databases(client) - val databases = Databases(client) - - GlobalScope.launch { - val response = databases.getDocument( - databaseId = "[DATABASE_ID]", - collectionId = "[COLLECTION_ID]", - documentId = "[DOCUMENT_ID]" - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = databases.getDocument( + databaseId = "[DATABASE_ID]", + collectionId = "[COLLECTION_ID]", + documentId = "[DOCUMENT_ID]" +) diff --git a/docs/examples/kotlin/databases/list-documents.md b/docs/examples/kotlin/databases/list-documents.md index 5277b46..0c2be1a 100644 --- a/docs/examples/kotlin/databases/list-documents.md +++ b/docs/examples/kotlin/databases/list-documents.md @@ -1,27 +1,13 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Databases -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val databases = Databases(client) - val databases = Databases(client) - - GlobalScope.launch { - val response = databases.listDocuments( - databaseId = "[DATABASE_ID]", - collectionId = "[COLLECTION_ID]", - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = databases.listDocuments( + databaseId = "[DATABASE_ID]", + collectionId = "[COLLECTION_ID]", +) diff --git a/docs/examples/kotlin/databases/update-document.md b/docs/examples/kotlin/databases/update-document.md index 7807f52..68cc42e 100644 --- a/docs/examples/kotlin/databases/update-document.md +++ b/docs/examples/kotlin/databases/update-document.md @@ -1,28 +1,14 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Databases -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val databases = Databases(client) - val databases = Databases(client) - - GlobalScope.launch { - val response = databases.updateDocument( - databaseId = "[DATABASE_ID]", - collectionId = "[COLLECTION_ID]", - documentId = "[DOCUMENT_ID]", - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = databases.updateDocument( + databaseId = "[DATABASE_ID]", + collectionId = "[COLLECTION_ID]", + documentId = "[DOCUMENT_ID]", +) diff --git a/docs/examples/kotlin/functions/create-execution.md b/docs/examples/kotlin/functions/create-execution.md index 3a7e599..b064201 100644 --- a/docs/examples/kotlin/functions/create-execution.md +++ b/docs/examples/kotlin/functions/create-execution.md @@ -1,26 +1,12 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Functions -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val functions = Functions(client) - val functions = Functions(client) - - GlobalScope.launch { - val response = functions.createExecution( - functionId = "[FUNCTION_ID]", - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = functions.createExecution( + functionId = "[FUNCTION_ID]", +) diff --git a/docs/examples/kotlin/functions/get-execution.md b/docs/examples/kotlin/functions/get-execution.md index 781f26c..2f9d5ef 100644 --- a/docs/examples/kotlin/functions/get-execution.md +++ b/docs/examples/kotlin/functions/get-execution.md @@ -1,27 +1,13 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Functions -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val functions = Functions(client) - val functions = Functions(client) - - GlobalScope.launch { - val response = functions.getExecution( - functionId = "[FUNCTION_ID]", - executionId = "[EXECUTION_ID]" - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = functions.getExecution( + functionId = "[FUNCTION_ID]", + executionId = "[EXECUTION_ID]" +) diff --git a/docs/examples/kotlin/functions/list-executions.md b/docs/examples/kotlin/functions/list-executions.md index 4f11574..d8a1aa1 100644 --- a/docs/examples/kotlin/functions/list-executions.md +++ b/docs/examples/kotlin/functions/list-executions.md @@ -1,26 +1,12 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Functions -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val functions = Functions(client) - val functions = Functions(client) - - GlobalScope.launch { - val response = functions.listExecutions( - functionId = "[FUNCTION_ID]", - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = functions.listExecutions( + functionId = "[FUNCTION_ID]", +) diff --git a/docs/examples/kotlin/functions/retry-build.md b/docs/examples/kotlin/functions/retry-build.md deleted file mode 100644 index 597421c..0000000 --- a/docs/examples/kotlin/functions/retry-build.md +++ /dev/null @@ -1,28 +0,0 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Functions - -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) - - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID - - val functions = Functions(client) - - GlobalScope.launch { - val response = functions.retryBuild( - functionId = "[FUNCTION_ID]", - deploymentId = "[DEPLOYMENT_ID]", - buildId = "[BUILD_ID]" - ) - val json = response.body?.string() - } - } -} \ No newline at end of file diff --git a/docs/examples/kotlin/graphql/mutation.md b/docs/examples/kotlin/graphql/mutation.md new file mode 100644 index 0000000..7222301 --- /dev/null +++ b/docs/examples/kotlin/graphql/mutation.md @@ -0,0 +1,12 @@ +import io.appwrite.Client +import io.appwrite.services.Graphql + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val graphql = Graphql(client) + +val response = graphql.mutation( + query = mapOf( "a" to "b" ) +) diff --git a/docs/examples/kotlin/graphql/query.md b/docs/examples/kotlin/graphql/query.md new file mode 100644 index 0000000..db0f571 --- /dev/null +++ b/docs/examples/kotlin/graphql/query.md @@ -0,0 +1,12 @@ +import io.appwrite.Client +import io.appwrite.services.Graphql + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val graphql = Graphql(client) + +val response = graphql.query( + query = mapOf( "a" to "b" ) +) diff --git a/docs/examples/kotlin/locale/get-continents.md b/docs/examples/kotlin/locale/get-continents.md deleted file mode 100644 index faf1448..0000000 --- a/docs/examples/kotlin/locale/get-continents.md +++ /dev/null @@ -1,24 +0,0 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Locale - -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) - - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID - - val locale = Locale(client) - - GlobalScope.launch { - val response = locale.getContinents() - val json = response.body?.string() - } - } -} \ No newline at end of file diff --git a/docs/examples/kotlin/locale/get-countries-e-u.md b/docs/examples/kotlin/locale/get-countries-e-u.md deleted file mode 100644 index 5a3552f..0000000 --- a/docs/examples/kotlin/locale/get-countries-e-u.md +++ /dev/null @@ -1,24 +0,0 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Locale - -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) - - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID - - val locale = Locale(client) - - GlobalScope.launch { - val response = locale.getCountriesEU() - val json = response.body?.string() - } - } -} \ No newline at end of file diff --git a/docs/examples/kotlin/locale/get-countries-phones.md b/docs/examples/kotlin/locale/get-countries-phones.md deleted file mode 100644 index 565097e..0000000 --- a/docs/examples/kotlin/locale/get-countries-phones.md +++ /dev/null @@ -1,24 +0,0 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Locale - -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) - - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID - - val locale = Locale(client) - - GlobalScope.launch { - val response = locale.getCountriesPhones() - val json = response.body?.string() - } - } -} \ No newline at end of file diff --git a/docs/examples/kotlin/locale/get-countries.md b/docs/examples/kotlin/locale/get-countries.md deleted file mode 100644 index e327c14..0000000 --- a/docs/examples/kotlin/locale/get-countries.md +++ /dev/null @@ -1,24 +0,0 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Locale - -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) - - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID - - val locale = Locale(client) - - GlobalScope.launch { - val response = locale.getCountries() - val json = response.body?.string() - } - } -} \ No newline at end of file diff --git a/docs/examples/kotlin/locale/get-currencies.md b/docs/examples/kotlin/locale/get-currencies.md deleted file mode 100644 index 00e1199..0000000 --- a/docs/examples/kotlin/locale/get-currencies.md +++ /dev/null @@ -1,24 +0,0 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Locale - -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) - - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID - - val locale = Locale(client) - - GlobalScope.launch { - val response = locale.getCurrencies() - val json = response.body?.string() - } - } -} \ No newline at end of file diff --git a/docs/examples/kotlin/locale/get-languages.md b/docs/examples/kotlin/locale/get-languages.md deleted file mode 100644 index 796747a..0000000 --- a/docs/examples/kotlin/locale/get-languages.md +++ /dev/null @@ -1,24 +0,0 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Locale - -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) - - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID - - val locale = Locale(client) - - GlobalScope.launch { - val response = locale.getLanguages() - val json = response.body?.string() - } - } -} \ No newline at end of file diff --git a/docs/examples/kotlin/locale/get.md b/docs/examples/kotlin/locale/get.md index f89c66a..da6b040 100644 --- a/docs/examples/kotlin/locale/get.md +++ b/docs/examples/kotlin/locale/get.md @@ -1,24 +1,10 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Locale -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val locale = Locale(client) - val locale = Locale(client) - - GlobalScope.launch { - val response = locale.get() - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = locale.get() diff --git a/docs/examples/kotlin/locale/list-continents.md b/docs/examples/kotlin/locale/list-continents.md index b582b40..8836a6c 100644 --- a/docs/examples/kotlin/locale/list-continents.md +++ b/docs/examples/kotlin/locale/list-continents.md @@ -1,24 +1,10 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Locale -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val locale = Locale(client) - val locale = Locale(client) - - GlobalScope.launch { - val response = locale.listContinents() - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = locale.listContinents() diff --git a/docs/examples/kotlin/locale/list-countries-e-u.md b/docs/examples/kotlin/locale/list-countries-e-u.md index 133da97..051c191 100644 --- a/docs/examples/kotlin/locale/list-countries-e-u.md +++ b/docs/examples/kotlin/locale/list-countries-e-u.md @@ -1,24 +1,10 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Locale -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val locale = Locale(client) - val locale = Locale(client) - - GlobalScope.launch { - val response = locale.listCountriesEU() - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = locale.listCountriesEU() diff --git a/docs/examples/kotlin/locale/list-countries-phones.md b/docs/examples/kotlin/locale/list-countries-phones.md index 7f17f47..c6efaae 100644 --- a/docs/examples/kotlin/locale/list-countries-phones.md +++ b/docs/examples/kotlin/locale/list-countries-phones.md @@ -1,24 +1,10 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Locale -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val locale = Locale(client) - val locale = Locale(client) - - GlobalScope.launch { - val response = locale.listCountriesPhones() - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = locale.listCountriesPhones() diff --git a/docs/examples/kotlin/locale/list-countries.md b/docs/examples/kotlin/locale/list-countries.md index 1d83452..4e2eeef 100644 --- a/docs/examples/kotlin/locale/list-countries.md +++ b/docs/examples/kotlin/locale/list-countries.md @@ -1,24 +1,10 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Locale -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val locale = Locale(client) - val locale = Locale(client) - - GlobalScope.launch { - val response = locale.listCountries() - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = locale.listCountries() diff --git a/docs/examples/kotlin/locale/list-currencies.md b/docs/examples/kotlin/locale/list-currencies.md index 657652f..f565be6 100644 --- a/docs/examples/kotlin/locale/list-currencies.md +++ b/docs/examples/kotlin/locale/list-currencies.md @@ -1,24 +1,10 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Locale -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val locale = Locale(client) - val locale = Locale(client) - - GlobalScope.launch { - val response = locale.listCurrencies() - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = locale.listCurrencies() diff --git a/docs/examples/kotlin/locale/list-languages.md b/docs/examples/kotlin/locale/list-languages.md index bdf023e..284f5ba 100644 --- a/docs/examples/kotlin/locale/list-languages.md +++ b/docs/examples/kotlin/locale/list-languages.md @@ -1,24 +1,10 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Locale -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val locale = Locale(client) - val locale = Locale(client) - - GlobalScope.launch { - val response = locale.listLanguages() - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = locale.listLanguages() diff --git a/docs/examples/kotlin/storage/create-file.md b/docs/examples/kotlin/storage/create-file.md index d3d7c60..fd52716 100644 --- a/docs/examples/kotlin/storage/create-file.md +++ b/docs/examples/kotlin/storage/create-file.md @@ -1,29 +1,15 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.models.InputFile import io.appwrite.services.Storage -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val storage = Storage(client) - val storage = Storage(client) - - GlobalScope.launch { - val response = storage.createFile( - bucketId = "[BUCKET_ID]", - fileId = "[FILE_ID]", - file = InputFile.fromPath("file.png"), - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = storage.createFile( + bucketId = "[BUCKET_ID]", + fileId = "[FILE_ID]", + file = InputFile.fromPath("file.png"), +) diff --git a/docs/examples/kotlin/storage/delete-file.md b/docs/examples/kotlin/storage/delete-file.md index 1a4a5b9..945e1b9 100644 --- a/docs/examples/kotlin/storage/delete-file.md +++ b/docs/examples/kotlin/storage/delete-file.md @@ -1,27 +1,13 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Storage -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val storage = Storage(client) - val storage = Storage(client) - - GlobalScope.launch { - val response = storage.deleteFile( - bucketId = "[BUCKET_ID]", - fileId = "[FILE_ID]" - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = storage.deleteFile( + bucketId = "[BUCKET_ID]", + fileId = "[FILE_ID]" +) diff --git a/docs/examples/kotlin/storage/get-file-download.md b/docs/examples/kotlin/storage/get-file-download.md index 3970fb8..b5fde87 100644 --- a/docs/examples/kotlin/storage/get-file-download.md +++ b/docs/examples/kotlin/storage/get-file-download.md @@ -1,27 +1,13 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Storage -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val storage = Storage(client) - val storage = Storage(client) - - GlobalScope.launch { - val result = storage.getFileDownload( - bucketId = "[BUCKET_ID]", - fileId = "[FILE_ID]" - ) - println(result); // Resource URL - } - } -} \ No newline at end of file +val result = storage.getFileDownload( + bucketId = "[BUCKET_ID]", + fileId = "[FILE_ID]" +) diff --git a/docs/examples/kotlin/storage/get-file-preview.md b/docs/examples/kotlin/storage/get-file-preview.md index 7804527..ea7d8d4 100644 --- a/docs/examples/kotlin/storage/get-file-preview.md +++ b/docs/examples/kotlin/storage/get-file-preview.md @@ -1,27 +1,13 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Storage -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val storage = Storage(client) - val storage = Storage(client) - - GlobalScope.launch { - val result = storage.getFilePreview( - bucketId = "[BUCKET_ID]", - fileId = "[FILE_ID]", - ) - println(result); // Resource URL - } - } -} \ No newline at end of file +val result = storage.getFilePreview( + bucketId = "[BUCKET_ID]", + fileId = "[FILE_ID]", +) diff --git a/docs/examples/kotlin/storage/get-file-view.md b/docs/examples/kotlin/storage/get-file-view.md index 107ad45..c266fca 100644 --- a/docs/examples/kotlin/storage/get-file-view.md +++ b/docs/examples/kotlin/storage/get-file-view.md @@ -1,27 +1,13 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Storage -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val storage = Storage(client) - val storage = Storage(client) - - GlobalScope.launch { - val result = storage.getFileView( - bucketId = "[BUCKET_ID]", - fileId = "[FILE_ID]" - ) - println(result); // Resource URL - } - } -} \ No newline at end of file +val result = storage.getFileView( + bucketId = "[BUCKET_ID]", + fileId = "[FILE_ID]" +) diff --git a/docs/examples/kotlin/storage/get-file.md b/docs/examples/kotlin/storage/get-file.md index 30f640b..73fd9a8 100644 --- a/docs/examples/kotlin/storage/get-file.md +++ b/docs/examples/kotlin/storage/get-file.md @@ -1,27 +1,13 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Storage -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val storage = Storage(client) - val storage = Storage(client) - - GlobalScope.launch { - val response = storage.getFile( - bucketId = "[BUCKET_ID]", - fileId = "[FILE_ID]" - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = storage.getFile( + bucketId = "[BUCKET_ID]", + fileId = "[FILE_ID]" +) diff --git a/docs/examples/kotlin/storage/list-files.md b/docs/examples/kotlin/storage/list-files.md index 20a253a..f915e5a 100644 --- a/docs/examples/kotlin/storage/list-files.md +++ b/docs/examples/kotlin/storage/list-files.md @@ -1,26 +1,12 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Storage -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val storage = Storage(client) - val storage = Storage(client) - - GlobalScope.launch { - val response = storage.listFiles( - bucketId = "[BUCKET_ID]", - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = storage.listFiles( + bucketId = "[BUCKET_ID]", +) diff --git a/docs/examples/kotlin/storage/update-file.md b/docs/examples/kotlin/storage/update-file.md index 35b1afb..23ce52a 100644 --- a/docs/examples/kotlin/storage/update-file.md +++ b/docs/examples/kotlin/storage/update-file.md @@ -1,27 +1,13 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Storage -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val storage = Storage(client) - val storage = Storage(client) - - GlobalScope.launch { - val response = storage.updateFile( - bucketId = "[BUCKET_ID]", - fileId = "[FILE_ID]", - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = storage.updateFile( + bucketId = "[BUCKET_ID]", + fileId = "[FILE_ID]", +) diff --git a/docs/examples/kotlin/teams/create-membership.md b/docs/examples/kotlin/teams/create-membership.md index e2b7d16..60d39c0 100644 --- a/docs/examples/kotlin/teams/create-membership.md +++ b/docs/examples/kotlin/teams/create-membership.md @@ -1,29 +1,15 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Teams -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val teams = Teams(client) - val teams = Teams(client) - - GlobalScope.launch { - val response = teams.createMembership( - teamId = "[TEAM_ID]", - email = "email@example.com", - roles = listOf(), - url = "https://example.com", - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = teams.createMembership( + teamId = "[TEAM_ID]", + email = "email@example.com", + roles = listOf(), + url = "https://example.com", +) diff --git a/docs/examples/kotlin/teams/create.md b/docs/examples/kotlin/teams/create.md index 73857b8..26bef65 100644 --- a/docs/examples/kotlin/teams/create.md +++ b/docs/examples/kotlin/teams/create.md @@ -1,27 +1,13 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Teams -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val teams = Teams(client) - val teams = Teams(client) - - GlobalScope.launch { - val response = teams.create( - teamId = "[TEAM_ID]", - name = "[NAME]", - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = teams.create( + teamId = "[TEAM_ID]", + name = "[NAME]", +) diff --git a/docs/examples/kotlin/teams/delete-membership.md b/docs/examples/kotlin/teams/delete-membership.md index 6545af5..ac1b37a 100644 --- a/docs/examples/kotlin/teams/delete-membership.md +++ b/docs/examples/kotlin/teams/delete-membership.md @@ -1,27 +1,13 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Teams -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val teams = Teams(client) - val teams = Teams(client) - - GlobalScope.launch { - val response = teams.deleteMembership( - teamId = "[TEAM_ID]", - membershipId = "[MEMBERSHIP_ID]" - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = teams.deleteMembership( + teamId = "[TEAM_ID]", + membershipId = "[MEMBERSHIP_ID]" +) diff --git a/docs/examples/kotlin/teams/delete.md b/docs/examples/kotlin/teams/delete.md index de12449..c5bcd37 100644 --- a/docs/examples/kotlin/teams/delete.md +++ b/docs/examples/kotlin/teams/delete.md @@ -1,26 +1,12 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Teams -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val teams = Teams(client) - val teams = Teams(client) - - GlobalScope.launch { - val response = teams.delete( - teamId = "[TEAM_ID]" - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = teams.delete( + teamId = "[TEAM_ID]" +) diff --git a/docs/examples/kotlin/teams/get-membership.md b/docs/examples/kotlin/teams/get-membership.md index aa3f29e..1ee6ec0 100644 --- a/docs/examples/kotlin/teams/get-membership.md +++ b/docs/examples/kotlin/teams/get-membership.md @@ -1,27 +1,13 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Teams -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val teams = Teams(client) - val teams = Teams(client) - - GlobalScope.launch { - val response = teams.getMembership( - teamId = "[TEAM_ID]", - membershipId = "[MEMBERSHIP_ID]" - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = teams.getMembership( + teamId = "[TEAM_ID]", + membershipId = "[MEMBERSHIP_ID]" +) diff --git a/docs/examples/kotlin/teams/get-memberships.md b/docs/examples/kotlin/teams/get-memberships.md deleted file mode 100644 index 89b4f54..0000000 --- a/docs/examples/kotlin/teams/get-memberships.md +++ /dev/null @@ -1,26 +0,0 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch -import io.appwrite.Client -import io.appwrite.services.Teams - -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) - - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID - - val teams = Teams(client) - - GlobalScope.launch { - val response = teams.getMemberships( - teamId = "[TEAM_ID]", - ) - val json = response.body?.string() - } - } -} \ No newline at end of file diff --git a/docs/examples/kotlin/teams/get.md b/docs/examples/kotlin/teams/get.md index 54550b3..557e998 100644 --- a/docs/examples/kotlin/teams/get.md +++ b/docs/examples/kotlin/teams/get.md @@ -1,26 +1,12 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Teams -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val teams = Teams(client) - val teams = Teams(client) - - GlobalScope.launch { - val response = teams.get( - teamId = "[TEAM_ID]" - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = teams.get( + teamId = "[TEAM_ID]" +) diff --git a/docs/examples/kotlin/teams/list-memberships.md b/docs/examples/kotlin/teams/list-memberships.md index 32ef3bd..d7f2920 100644 --- a/docs/examples/kotlin/teams/list-memberships.md +++ b/docs/examples/kotlin/teams/list-memberships.md @@ -1,26 +1,12 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Teams -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val teams = Teams(client) - val teams = Teams(client) - - GlobalScope.launch { - val response = teams.listMemberships( - teamId = "[TEAM_ID]", - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = teams.listMemberships( + teamId = "[TEAM_ID]", +) diff --git a/docs/examples/kotlin/teams/list.md b/docs/examples/kotlin/teams/list.md index 6444205..f056d33 100644 --- a/docs/examples/kotlin/teams/list.md +++ b/docs/examples/kotlin/teams/list.md @@ -1,25 +1,11 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Teams -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val teams = Teams(client) - val teams = Teams(client) - - GlobalScope.launch { - val response = teams.list( - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = teams.list( +) diff --git a/docs/examples/kotlin/teams/update-membership-roles.md b/docs/examples/kotlin/teams/update-membership-roles.md index d9a8a41..5727e11 100644 --- a/docs/examples/kotlin/teams/update-membership-roles.md +++ b/docs/examples/kotlin/teams/update-membership-roles.md @@ -1,28 +1,14 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Teams -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val teams = Teams(client) - val teams = Teams(client) - - GlobalScope.launch { - val response = teams.updateMembershipRoles( - teamId = "[TEAM_ID]", - membershipId = "[MEMBERSHIP_ID]", - roles = listOf() - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = teams.updateMembershipRoles( + teamId = "[TEAM_ID]", + membershipId = "[MEMBERSHIP_ID]", + roles = listOf() +) diff --git a/docs/examples/kotlin/teams/update-membership-status.md b/docs/examples/kotlin/teams/update-membership-status.md index f8e10fd..a36b710 100644 --- a/docs/examples/kotlin/teams/update-membership-status.md +++ b/docs/examples/kotlin/teams/update-membership-status.md @@ -1,29 +1,15 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Teams -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val teams = Teams(client) - val teams = Teams(client) - - GlobalScope.launch { - val response = teams.updateMembershipStatus( - teamId = "[TEAM_ID]", - membershipId = "[MEMBERSHIP_ID]", - userId = "[USER_ID]", - secret = "[SECRET]" - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = teams.updateMembershipStatus( + teamId = "[TEAM_ID]", + membershipId = "[MEMBERSHIP_ID]", + userId = "[USER_ID]", + secret = "[SECRET]" +) diff --git a/docs/examples/kotlin/teams/update.md b/docs/examples/kotlin/teams/update.md index 59dd69f..1a54434 100644 --- a/docs/examples/kotlin/teams/update.md +++ b/docs/examples/kotlin/teams/update.md @@ -1,27 +1,13 @@ -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch import io.appwrite.Client import io.appwrite.services.Teams -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID - val client = Client(applicationContext) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID +val teams = Teams(client) - val teams = Teams(client) - - GlobalScope.launch { - val response = teams.update( - teamId = "[TEAM_ID]", - name = "[NAME]" - ) - val json = response.body?.string() - } - } -} \ No newline at end of file +val response = teams.update( + teamId = "[TEAM_ID]", + name = "[NAME]" +) diff --git a/example-java/src/main/java/io/appwrite/example_java/MainActivity.java b/example-java/src/main/java/io/appwrite/example_java/MainActivity.java index 28e3222..04f46b3 100644 --- a/example-java/src/main/java/io/appwrite/example_java/MainActivity.java +++ b/example-java/src/main/java/io/appwrite/example_java/MainActivity.java @@ -1,18 +1,13 @@ package io.appwrite.example_java; -import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; -import org.jetbrains.annotations.NotNull; + +import androidx.appcompat.app.AppCompatActivity; + import io.appwrite.Client; -import io.appwrite.exceptions.AppwriteException; -import io.appwrite.extensions.JsonExtensionsKt; -import io.appwrite.models.Session; +import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; -import kotlin.Result; -import kotlin.coroutines.Continuation; -import kotlin.coroutines.CoroutineContext; -import kotlin.coroutines.EmptyCoroutineContext; public class MainActivity extends AppCompatActivity { @@ -27,31 +22,13 @@ protected void onCreate(Bundle savedInstanceState) { Account account = new Account(client); - try { - account.createSession("test7@test.com","password", new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } - - @Override - public void resumeWith(@NotNull Object o) { - try { - if (o instanceof Result.Failure) { - Result.Failure failure = (Result.Failure) o; - throw failure.exception; - } else { - Session session = (Session) o; - Log.d("RESPONSE", JsonExtensionsKt.toJson(session)); - } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); - } - } - }); - } catch (AppwriteException e) { - e.printStackTrace(); - } + account.createEmailSession("test7@test.com", "password", new CoroutineCallback<>((session, error) -> { + if (error != null) { + Log.e("Appwrite", error.getMessage()); + return; + } + + Log.d("Appwrite", session.toMap().toString()); + })); } } \ No newline at end of file diff --git a/example/src/main/java/io/appwrite/android/ui/accounts/AccountsViewModel.kt b/example/src/main/java/io/appwrite/android/ui/accounts/AccountsViewModel.kt index 1e7b084..ede86d3 100644 --- a/example/src/main/java/io/appwrite/android/ui/accounts/AccountsViewModel.kt +++ b/example/src/main/java/io/appwrite/android/ui/accounts/AccountsViewModel.kt @@ -29,7 +29,7 @@ class AccountsViewModel : ViewModel() { fun onLogin(email: Editable, password: Editable) { viewModelScope.launch { try { - val session = accountService.createSession(email.toString(), password.toString()) + val session = accountService.createEmailSession(email.toString(), password.toString()) _response.postValue(Event(session.toJson())) } catch (e: AppwriteException) { _error.postValue(Event(e)) diff --git a/library/build.gradle b/library/build.gradle index 7045591..6be6a48 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -22,11 +22,11 @@ ext { version PUBLISH_VERSION android { - compileSdkVersion(31) + compileSdkVersion(33) defaultConfig { minSdkVersion(21) - targetSdkVersion(31) + targetSdkVersion(33) versionCode = 1 versionName = "1.0" buildConfigField "String", "SDK_VERSION", "\"${PUBLISH_VERSION}\"" @@ -54,27 +54,27 @@ android { dependencies { implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION}") - api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2") - api("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2") + api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1") + api("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1") - api(platform("com.squareup.okhttp3:okhttp-bom:4.9.0")) + api(platform("com.squareup.okhttp3:okhttp-bom:4.10.0")) api("com.squareup.okhttp3:okhttp") implementation("com.squareup.okhttp3:okhttp-urlconnection") implementation("com.squareup.okhttp3:logging-interceptor") - implementation("com.google.code.gson:gson:2.8.7") + implementation("com.google.code.gson:gson:2.9.0") - implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.3.1") - implementation("androidx.lifecycle:lifecycle-common-java8:2.3.1") - implementation("androidx.appcompat:appcompat:1.3.1") - implementation("androidx.fragment:fragment-ktx:1.3.6") - implementation("androidx.activity:activity-ktx:1.3.1") - implementation("androidx.browser:browser:1.3.0") + implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.5.1") + implementation("androidx.lifecycle:lifecycle-common-java8:2.5.1") + implementation("androidx.appcompat:appcompat:1.5.1") + implementation("androidx.fragment:fragment-ktx:1.5.3") + implementation("androidx.activity:activity-ktx:1.6.0") + implementation("androidx.browser:browser:1.4.0") testImplementation 'junit:junit:4.+' testImplementation "androidx.test.ext:junit-ktx:1.1.3" testImplementation "androidx.test:core-ktx:1.4.0" testImplementation "org.robolectric:robolectric:4.5.1" - testApi("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.5.1") + testApi("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.1") } apply from: "${rootProject.projectDir}/scripts/publish-module.gradle" \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index 7faa46d..0d87b5b 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -88,7 +88,7 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "1.1.0", + "x-sdk-version" to "1.2.0", "x-appwrite-response-format" to "1.0.0" ) config = mutableMapOf() @@ -250,7 +250,7 @@ class Client @JvmOverloads constructor( headers: Map = mapOf(), params: Map = mapOf(), responseType: Class, - converter: ((Map) -> T)? = null + converter: ((Any) -> T)? = null ): T { val filteredParams = params.filterValues { it != null } @@ -341,7 +341,7 @@ class Client @JvmOverloads constructor( headers: MutableMap, params: MutableMap, responseType: Class, - converter: ((Map) -> T), + converter: ((Any) -> T), paramName: String, idParamName: String? = null, onProgress: ((UploadProgress) -> Unit)? = null, @@ -464,7 +464,7 @@ class Client @JvmOverloads constructor( private suspend fun awaitResponse( request: Request, responseType: Class, - converter: ((Map) -> T)? = null + converter: ((Any) -> T)? = null ) = suspendCancellableCoroutine { http.newCall(request).enqueue(object : Callback { override fun onFailure(call: Call, e: IOException) { @@ -525,9 +525,9 @@ class Client @JvmOverloads constructor( it.resume(true as T) return } - val map = gson.fromJson>( + val map = gson.fromJson( body, - object : TypeToken>(){}.type + object : TypeToken(){}.type ) it.resume( converter?.invoke(map) ?: map as T diff --git a/library/src/main/java/io/appwrite/coroutines/Callback.kt b/library/src/main/java/io/appwrite/coroutines/Callback.kt new file mode 100644 index 0000000..baa30fe --- /dev/null +++ b/library/src/main/java/io/appwrite/coroutines/Callback.kt @@ -0,0 +1,18 @@ +package io.appwrite.coroutines + +import kotlinx.coroutines.Dispatchers +import kotlin.coroutines.Continuation +import kotlin.coroutines.CoroutineContext + +interface Callback { + fun onComplete(result: T?, error: Throwable?) +} + +class CoroutineCallback @JvmOverloads constructor( + private val callback: Callback, + override val context: CoroutineContext = Dispatchers.Default +) : Continuation { + override fun resumeWith(result: Result) { + callback.onComplete(result.getOrNull(), result.exceptionOrNull()) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/extensions/TypeExtensions.kt b/library/src/main/java/io/appwrite/extensions/TypeExtensions.kt new file mode 100644 index 0000000..2674b99 --- /dev/null +++ b/library/src/main/java/io/appwrite/extensions/TypeExtensions.kt @@ -0,0 +1,8 @@ +package io.appwrite.extensions + +import kotlin.reflect.KClass +import kotlin.reflect.typeOf + +inline fun classOf(): Class { + return (typeOf().classifier!! as KClass).java +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Account.kt b/library/src/main/java/io/appwrite/models/Account.kt index 1450b82..1b87beb 100644 --- a/library/src/main/java/io/appwrite/models/Account.kt +++ b/library/src/main/java/io/appwrite/models/Account.kt @@ -1,98 +1,134 @@ package io.appwrite.models import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast /** * Account */ -data class Account( +data class Account( /** * User ID. - * */ @SerializedName("\$id") val id: String, /** * User creation date in ISO 8601 format. - * */ @SerializedName("\$createdAt") val createdAt: String, /** * User update date in ISO 8601 format. - * */ @SerializedName("\$updatedAt") val updatedAt: String, /** * User name. - * */ @SerializedName("name") val name: String, /** * User registration date in ISO 8601 format. - * */ @SerializedName("registration") val registration: String, /** * User status. Pass `true` for enabled and `false` for disabled. - * */ @SerializedName("status") val status: Boolean, /** * Password update time in ISO 8601 format. - * */ @SerializedName("passwordUpdate") val passwordUpdate: String, /** * User email address. - * */ @SerializedName("email") val email: String, /** * User phone number in E.164 format. - * */ @SerializedName("phone") val phone: String, /** * Email verification status. - * */ @SerializedName("emailVerification") val emailVerification: Boolean, /** * Phone verification status. - * */ @SerializedName("phoneVerification") val phoneVerification: Boolean, /** * User preferences as a key-value object - * */ @SerializedName("prefs") - val prefs: Preferences + val prefs: Preferences, + ) { + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "\$createdAt" to createdAt as Any, + "\$updatedAt" to updatedAt as Any, + "name" to name as Any, + "registration" to registration as Any, + "status" to status as Any, + "passwordUpdate" to passwordUpdate as Any, + "email" to email as Any, + "phone" to phone as Any, + "emailVerification" to emailVerification as Any, + "phoneVerification" to phoneVerification as Any, + "prefs" to prefs.toMap() as Any, + ) + companion object { + operator fun invoke( + id: String, + createdAt: String, + updatedAt: String, + name: String, + registration: String, + status: Boolean, + passwordUpdate: String, + email: String, + phone: String, + emailVerification: Boolean, + phoneVerification: Boolean, + prefs: Preferences>, + ) = Account>( + id, + createdAt, + updatedAt, + name, + registration, + status, + passwordUpdate, + email, + phone, + emailVerification, + phoneVerification, + prefs, + ) + @Suppress("UNCHECKED_CAST") - fun from(map: Map) = Account( + fun from( + map: Map, + nestedType: Class + ) = Account( id = map["\$id"] as String, createdAt = map["\$createdAt"] as String, updatedAt = map["\$updatedAt"] as String, @@ -104,22 +140,7 @@ data class Account( phone = map["phone"] as String, emailVerification = map["emailVerification"] as Boolean, phoneVerification = map["phoneVerification"] as Boolean, - prefs = Preferences.from(map = map["prefs"] as Map) + prefs = Preferences.from(map = map["prefs"] as Map, nestedType), ) } - - fun toMap(): Map = mapOf( - "\$id" to id as Any, - "\$createdAt" to createdAt as Any, - "\$updatedAt" to updatedAt as Any, - "name" to name as Any, - "registration" to registration as Any, - "status" to status as Any, - "passwordUpdate" to passwordUpdate as Any, - "email" to email as Any, - "phone" to phone as Any, - "emailVerification" to emailVerification as Any, - "phoneVerification" to phoneVerification as Any, - "prefs" to prefs.toMap() as Any - ) } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Continent.kt b/library/src/main/java/io/appwrite/models/Continent.kt index ba8b5ae..818c15b 100644 --- a/library/src/main/java/io/appwrite/models/Continent.kt +++ b/library/src/main/java/io/appwrite/models/Continent.kt @@ -1,6 +1,7 @@ package io.appwrite.models import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast /** * Continent @@ -8,28 +9,30 @@ import com.google.gson.annotations.SerializedName data class Continent( /** * Continent name. - * */ @SerializedName("name") val name: String, /** * Continent two letter code. - * */ @SerializedName("code") - val code: String + val code: String, + ) { + fun toMap(): Map = mapOf( + "name" to name as Any, + "code" to code as Any, + ) + companion object { + @Suppress("UNCHECKED_CAST") - fun from(map: Map) = Continent( + fun from( + map: Map, + ) = Continent( name = map["name"] as String, - code = map["code"] as String + code = map["code"] as String, ) } - - fun toMap(): Map = mapOf( - "name" to name as Any, - "code" to code as Any - ) } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/ContinentList.kt b/library/src/main/java/io/appwrite/models/ContinentList.kt index 6a09c92..fdd490a 100644 --- a/library/src/main/java/io/appwrite/models/ContinentList.kt +++ b/library/src/main/java/io/appwrite/models/ContinentList.kt @@ -1,6 +1,7 @@ package io.appwrite.models import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast /** * Continents List @@ -8,28 +9,30 @@ import com.google.gson.annotations.SerializedName data class ContinentList( /** * Total number of continents documents that matched your query. - * */ @SerializedName("total") val total: Long, /** * List of continents. - * */ @SerializedName("continents") - val continents: List + val continents: List, + ) { + fun toMap(): Map = mapOf( + "total" to total as Any, + "continents" to continents.map { it.toMap() } as Any, + ) + companion object { + @Suppress("UNCHECKED_CAST") - fun from(map: Map) = ContinentList( + fun from( + map: Map, + ) = ContinentList( total = (map["total"] as Number).toLong(), - continents = (map["continents"] as List>).map { Continent.from(map = it) } + continents = (map["continents"] as List>).map { Continent.from(map = it) }, ) } - - fun toMap(): Map = mapOf( - "total" to total as Any, - "continents" to continents.map { it.toMap() } as Any - ) } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Country.kt b/library/src/main/java/io/appwrite/models/Country.kt index 51fee8f..92ab89a 100644 --- a/library/src/main/java/io/appwrite/models/Country.kt +++ b/library/src/main/java/io/appwrite/models/Country.kt @@ -1,6 +1,7 @@ package io.appwrite.models import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast /** * Country @@ -8,28 +9,30 @@ import com.google.gson.annotations.SerializedName data class Country( /** * Country name. - * */ @SerializedName("name") val name: String, /** * Country two-character ISO 3166-1 alpha code. - * */ @SerializedName("code") - val code: String + val code: String, + ) { + fun toMap(): Map = mapOf( + "name" to name as Any, + "code" to code as Any, + ) + companion object { + @Suppress("UNCHECKED_CAST") - fun from(map: Map) = Country( + fun from( + map: Map, + ) = Country( name = map["name"] as String, - code = map["code"] as String + code = map["code"] as String, ) } - - fun toMap(): Map = mapOf( - "name" to name as Any, - "code" to code as Any - ) } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/CountryList.kt b/library/src/main/java/io/appwrite/models/CountryList.kt index 98dbfcd..350a894 100644 --- a/library/src/main/java/io/appwrite/models/CountryList.kt +++ b/library/src/main/java/io/appwrite/models/CountryList.kt @@ -1,6 +1,7 @@ package io.appwrite.models import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast /** * Countries List @@ -8,28 +9,30 @@ import com.google.gson.annotations.SerializedName data class CountryList( /** * Total number of countries documents that matched your query. - * */ @SerializedName("total") val total: Long, /** * List of countries. - * */ @SerializedName("countries") - val countries: List + val countries: List, + ) { + fun toMap(): Map = mapOf( + "total" to total as Any, + "countries" to countries.map { it.toMap() } as Any, + ) + companion object { + @Suppress("UNCHECKED_CAST") - fun from(map: Map) = CountryList( + fun from( + map: Map, + ) = CountryList( total = (map["total"] as Number).toLong(), - countries = (map["countries"] as List>).map { Country.from(map = it) } + countries = (map["countries"] as List>).map { Country.from(map = it) }, ) } - - fun toMap(): Map = mapOf( - "total" to total as Any, - "countries" to countries.map { it.toMap() } as Any - ) } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Currency.kt b/library/src/main/java/io/appwrite/models/Currency.kt index df6e230..96b65d0 100644 --- a/library/src/main/java/io/appwrite/models/Currency.kt +++ b/library/src/main/java/io/appwrite/models/Currency.kt @@ -1,6 +1,7 @@ package io.appwrite.models import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast /** * Currency @@ -8,73 +9,70 @@ import com.google.gson.annotations.SerializedName data class Currency( /** * Currency symbol. - * */ @SerializedName("symbol") val symbol: String, /** * Currency name. - * */ @SerializedName("name") val name: String, /** * Currency native symbol. - * */ @SerializedName("symbolNative") val symbolNative: String, /** * Number of decimal digits. - * */ @SerializedName("decimalDigits") val decimalDigits: Long, /** * Currency digit rounding. - * */ @SerializedName("rounding") val rounding: Double, /** * Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format. - * */ @SerializedName("code") val code: String, /** * Currency plural name - * */ @SerializedName("namePlural") - val namePlural: String + val namePlural: String, + ) { + fun toMap(): Map = mapOf( + "symbol" to symbol as Any, + "name" to name as Any, + "symbolNative" to symbolNative as Any, + "decimalDigits" to decimalDigits as Any, + "rounding" to rounding as Any, + "code" to code as Any, + "namePlural" to namePlural as Any, + ) + companion object { + @Suppress("UNCHECKED_CAST") - fun from(map: Map) = Currency( + fun from( + map: Map, + ) = Currency( symbol = map["symbol"] as String, name = map["name"] as String, symbolNative = map["symbolNative"] as String, decimalDigits = (map["decimalDigits"] as Number).toLong(), rounding = (map["rounding"] as Number).toDouble(), code = map["code"] as String, - namePlural = map["namePlural"] as String + namePlural = map["namePlural"] as String, ) } - - fun toMap(): Map = mapOf( - "symbol" to symbol as Any, - "name" to name as Any, - "symbolNative" to symbolNative as Any, - "decimalDigits" to decimalDigits as Any, - "rounding" to rounding as Any, - "code" to code as Any, - "namePlural" to namePlural as Any - ) } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/CurrencyList.kt b/library/src/main/java/io/appwrite/models/CurrencyList.kt index abc719d..fe1e001 100644 --- a/library/src/main/java/io/appwrite/models/CurrencyList.kt +++ b/library/src/main/java/io/appwrite/models/CurrencyList.kt @@ -1,6 +1,7 @@ package io.appwrite.models import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast /** * Currencies List @@ -8,28 +9,30 @@ import com.google.gson.annotations.SerializedName data class CurrencyList( /** * Total number of currencies documents that matched your query. - * */ @SerializedName("total") val total: Long, /** * List of currencies. - * */ @SerializedName("currencies") - val currencies: List + val currencies: List, + ) { + fun toMap(): Map = mapOf( + "total" to total as Any, + "currencies" to currencies.map { it.toMap() } as Any, + ) + companion object { + @Suppress("UNCHECKED_CAST") - fun from(map: Map) = CurrencyList( + fun from( + map: Map, + ) = CurrencyList( total = (map["total"] as Number).toLong(), - currencies = (map["currencies"] as List>).map { Currency.from(map = it) } + currencies = (map["currencies"] as List>).map { Currency.from(map = it) }, ) } - - fun toMap(): Map = mapOf( - "total" to total as Any, - "currencies" to currencies.map { it.toMap() } as Any - ) } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Document.kt b/library/src/main/java/io/appwrite/models/Document.kt index a57214e..27830d4 100644 --- a/library/src/main/java/io/appwrite/models/Document.kt +++ b/library/src/main/java/io/appwrite/models/Document.kt @@ -1,68 +1,54 @@ package io.appwrite.models import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast /** * Document */ -data class Document( +data class Document( /** * Document ID. - * */ @SerializedName("\$id") val id: String, /** * Collection ID. - * */ @SerializedName("\$collectionId") val collectionId: String, /** * Database ID. - * */ @SerializedName("\$databaseId") val databaseId: String, /** * Document creation date in ISO 8601 format. - * */ @SerializedName("\$createdAt") val createdAt: String, /** * Document update date in ISO 8601 format. - * */ @SerializedName("\$updatedAt") val updatedAt: String, /** * Document permissions. [Learn more about permissions](/docs/permissions). - * */ @SerializedName("\$permissions") val permissions: List, - val data: Map + /** + * Additional properties + */ + @SerializedName("data") + val data: T ) { - companion object { - @Suppress("UNCHECKED_CAST") - fun from(map: Map) = Document( - id = map["\$id"] as String, - collectionId = map["\$collectionId"] as String, - databaseId = map["\$databaseId"] as String, - createdAt = map["\$createdAt"] as String, - updatedAt = map["\$updatedAt"] as String, - permissions = map["\$permissions"] as List, - data = map - ) - } - fun toMap(): Map = mapOf( "\$id" to id as Any, "\$collectionId" to collectionId as Any, @@ -70,10 +56,40 @@ data class Document( "\$createdAt" to createdAt as Any, "\$updatedAt" to updatedAt as Any, "\$permissions" to permissions as Any, - "data" to data + "data" to data!!.jsonCast(to = Map::class.java) ) - fun convertTo(fromJson: (Map) -> T): T { - return fromJson(data) + companion object { + operator fun invoke( + id: String, + collectionId: String, + databaseId: String, + createdAt: String, + updatedAt: String, + permissions: List, + data: Map + ) = Document>( + id, + collectionId, + databaseId, + createdAt, + updatedAt, + permissions, + data + ) + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + nestedType: Class + ) = Document( + id = map["\$id"] as String, + collectionId = map["\$collectionId"] as String, + databaseId = map["\$databaseId"] as String, + createdAt = map["\$createdAt"] as String, + updatedAt = map["\$updatedAt"] as String, + permissions = map["\$permissions"] as List, + data = map.jsonCast(to = nestedType) + ) } } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/DocumentList.kt b/library/src/main/java/io/appwrite/models/DocumentList.kt index f8e41b5..fa3dd20 100644 --- a/library/src/main/java/io/appwrite/models/DocumentList.kt +++ b/library/src/main/java/io/appwrite/models/DocumentList.kt @@ -1,38 +1,46 @@ package io.appwrite.models import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast /** * Documents List */ -data class DocumentList( +data class DocumentList( /** * Total number of documents documents that matched your query. - * */ @SerializedName("total") val total: Long, /** * List of documents. - * */ @SerializedName("documents") - val documents: List + val documents: List>, + ) { + fun toMap(): Map = mapOf( + "total" to total as Any, + "documents" to documents.map { it.toMap() } as Any, + ) + companion object { + operator fun invoke( + total: Long, + documents: List>>, + ) = DocumentList>( + total, + documents, + ) + @Suppress("UNCHECKED_CAST") - fun from(map: Map) = DocumentList( + fun from( + map: Map, + nestedType: Class + ) = DocumentList( total = (map["total"] as Number).toLong(), - documents = (map["documents"] as List>).map { Document.from(map = it) } + documents = (map["documents"] as List>).map { Document.from(map = it, nestedType) }, ) } - - fun toMap(): Map = mapOf( - "total" to total as Any, - "documents" to documents.map { it.toMap() } as Any - ) - - fun convertTo(fromJson: (Map) -> T) = - documents.map { it.convertTo(fromJson = fromJson) } } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Execution.kt b/library/src/main/java/io/appwrite/models/Execution.kt index b1179f5..a573562 100644 --- a/library/src/main/java/io/appwrite/models/Execution.kt +++ b/library/src/main/java/io/appwrite/models/Execution.kt @@ -1,6 +1,7 @@ package io.appwrite.models import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast /** * Execution @@ -8,91 +9,98 @@ import com.google.gson.annotations.SerializedName data class Execution( /** * Execution ID. - * */ @SerializedName("\$id") val id: String, /** * Execution creation date in ISO 8601 format. - * */ @SerializedName("\$createdAt") val createdAt: String, /** * Execution upate date in ISO 8601 format. - * */ @SerializedName("\$updatedAt") val updatedAt: String, /** * Execution roles. - * */ @SerializedName("\$permissions") val permissions: List, /** * Function ID. - * */ @SerializedName("functionId") val functionId: String, /** * The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. - * */ @SerializedName("trigger") val trigger: String, /** * The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`. - * */ @SerializedName("status") val status: String, /** * The script status code. - * */ @SerializedName("statusCode") val statusCode: Long, /** * The script response output string. Logs the last 4,000 characters of the execution response output. - * */ @SerializedName("response") val response: String, /** * The script stdout output string. Logs the last 4,000 characters of the execution stdout output. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. - * */ @SerializedName("stdout") val stdout: String, /** * The script stderr output string. Logs the last 4,000 characters of the execution stderr output. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. - * */ @SerializedName("stderr") val stderr: String, /** * The script execution duration in seconds. - * */ @SerializedName("duration") - val duration: Double + val duration: Double, + ) { + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "\$createdAt" to createdAt as Any, + "\$updatedAt" to updatedAt as Any, + "\$permissions" to permissions as Any, + "functionId" to functionId as Any, + "trigger" to trigger as Any, + "status" to status as Any, + "statusCode" to statusCode as Any, + "response" to response as Any, + "stdout" to stdout as Any, + "stderr" to stderr as Any, + "duration" to duration as Any, + ) + companion object { + @Suppress("UNCHECKED_CAST") - fun from(map: Map) = Execution( + fun from( + map: Map, + ) = Execution( id = map["\$id"] as String, createdAt = map["\$createdAt"] as String, updatedAt = map["\$updatedAt"] as String, @@ -104,22 +112,7 @@ data class Execution( response = map["response"] as String, stdout = map["stdout"] as String, stderr = map["stderr"] as String, - duration = (map["duration"] as Number).toDouble() + duration = (map["duration"] as Number).toDouble(), ) } - - fun toMap(): Map = mapOf( - "\$id" to id as Any, - "\$createdAt" to createdAt as Any, - "\$updatedAt" to updatedAt as Any, - "\$permissions" to permissions as Any, - "functionId" to functionId as Any, - "trigger" to trigger as Any, - "status" to status as Any, - "statusCode" to statusCode as Any, - "response" to response as Any, - "stdout" to stdout as Any, - "stderr" to stderr as Any, - "duration" to duration as Any - ) } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/ExecutionList.kt b/library/src/main/java/io/appwrite/models/ExecutionList.kt index 2131ffc..322aeee 100644 --- a/library/src/main/java/io/appwrite/models/ExecutionList.kt +++ b/library/src/main/java/io/appwrite/models/ExecutionList.kt @@ -1,6 +1,7 @@ package io.appwrite.models import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast /** * Executions List @@ -8,28 +9,30 @@ import com.google.gson.annotations.SerializedName data class ExecutionList( /** * Total number of executions documents that matched your query. - * */ @SerializedName("total") val total: Long, /** * List of executions. - * */ @SerializedName("executions") - val executions: List + val executions: List, + ) { + fun toMap(): Map = mapOf( + "total" to total as Any, + "executions" to executions.map { it.toMap() } as Any, + ) + companion object { + @Suppress("UNCHECKED_CAST") - fun from(map: Map) = ExecutionList( + fun from( + map: Map, + ) = ExecutionList( total = (map["total"] as Number).toLong(), - executions = (map["executions"] as List>).map { Execution.from(map = it) } + executions = (map["executions"] as List>).map { Execution.from(map = it) }, ) } - - fun toMap(): Map = mapOf( - "total" to total as Any, - "executions" to executions.map { it.toMap() } as Any - ) } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/File.kt b/library/src/main/java/io/appwrite/models/File.kt index 3f1a296..bd35d42 100644 --- a/library/src/main/java/io/appwrite/models/File.kt +++ b/library/src/main/java/io/appwrite/models/File.kt @@ -1,6 +1,7 @@ package io.appwrite.models import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast /** * File @@ -8,84 +9,91 @@ import com.google.gson.annotations.SerializedName data class File( /** * File ID. - * */ @SerializedName("\$id") val id: String, /** * Bucket ID. - * */ @SerializedName("bucketId") val bucketId: String, /** * File creation date in ISO 8601 format. - * */ @SerializedName("\$createdAt") val createdAt: String, /** * File update date in ISO 8601 format. - * */ @SerializedName("\$updatedAt") val updatedAt: String, /** * File permissions. [Learn more about permissions](/docs/permissions). - * */ @SerializedName("\$permissions") val permissions: List, /** * File name. - * */ @SerializedName("name") val name: String, /** * File MD5 signature. - * */ @SerializedName("signature") val signature: String, /** * File mime type. - * */ @SerializedName("mimeType") val mimeType: String, /** * File original size in bytes. - * */ @SerializedName("sizeOriginal") val sizeOriginal: Long, /** * Total number of chunks available - * */ @SerializedName("chunksTotal") val chunksTotal: Long, /** * Total number of chunks uploaded - * */ @SerializedName("chunksUploaded") - val chunksUploaded: Long + val chunksUploaded: Long, + ) { + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "bucketId" to bucketId as Any, + "\$createdAt" to createdAt as Any, + "\$updatedAt" to updatedAt as Any, + "\$permissions" to permissions as Any, + "name" to name as Any, + "signature" to signature as Any, + "mimeType" to mimeType as Any, + "sizeOriginal" to sizeOriginal as Any, + "chunksTotal" to chunksTotal as Any, + "chunksUploaded" to chunksUploaded as Any, + ) + companion object { + @Suppress("UNCHECKED_CAST") - fun from(map: Map) = File( + fun from( + map: Map, + ) = File( id = map["\$id"] as String, bucketId = map["bucketId"] as String, createdAt = map["\$createdAt"] as String, @@ -96,21 +104,7 @@ data class File( mimeType = map["mimeType"] as String, sizeOriginal = (map["sizeOriginal"] as Number).toLong(), chunksTotal = (map["chunksTotal"] as Number).toLong(), - chunksUploaded = (map["chunksUploaded"] as Number).toLong() + chunksUploaded = (map["chunksUploaded"] as Number).toLong(), ) } - - fun toMap(): Map = mapOf( - "\$id" to id as Any, - "bucketId" to bucketId as Any, - "\$createdAt" to createdAt as Any, - "\$updatedAt" to updatedAt as Any, - "\$permissions" to permissions as Any, - "name" to name as Any, - "signature" to signature as Any, - "mimeType" to mimeType as Any, - "sizeOriginal" to sizeOriginal as Any, - "chunksTotal" to chunksTotal as Any, - "chunksUploaded" to chunksUploaded as Any - ) } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/FileList.kt b/library/src/main/java/io/appwrite/models/FileList.kt index 477bad2..5af18f1 100644 --- a/library/src/main/java/io/appwrite/models/FileList.kt +++ b/library/src/main/java/io/appwrite/models/FileList.kt @@ -1,6 +1,7 @@ package io.appwrite.models import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast /** * Files List @@ -8,28 +9,30 @@ import com.google.gson.annotations.SerializedName data class FileList( /** * Total number of files documents that matched your query. - * */ @SerializedName("total") val total: Long, /** * List of files. - * */ @SerializedName("files") - val files: List + val files: List, + ) { + fun toMap(): Map = mapOf( + "total" to total as Any, + "files" to files.map { it.toMap() } as Any, + ) + companion object { + @Suppress("UNCHECKED_CAST") - fun from(map: Map) = FileList( + fun from( + map: Map, + ) = FileList( total = (map["total"] as Number).toLong(), - files = (map["files"] as List>).map { File.from(map = it) } + files = (map["files"] as List>).map { File.from(map = it) }, ) } - - fun toMap(): Map = mapOf( - "total" to total as Any, - "files" to files.map { it.toMap() } as Any - ) } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Jwt.kt b/library/src/main/java/io/appwrite/models/Jwt.kt index c871237..f55c103 100644 --- a/library/src/main/java/io/appwrite/models/Jwt.kt +++ b/library/src/main/java/io/appwrite/models/Jwt.kt @@ -1,6 +1,7 @@ package io.appwrite.models import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast /** * JWT @@ -8,19 +9,22 @@ import com.google.gson.annotations.SerializedName data class Jwt( /** * JWT encoded string. - * */ @SerializedName("jwt") - val jwt: String + val jwt: String, + ) { + fun toMap(): Map = mapOf( + "jwt" to jwt as Any, + ) + companion object { + @Suppress("UNCHECKED_CAST") - fun from(map: Map) = Jwt( - jwt = map["jwt"] as String + fun from( + map: Map, + ) = Jwt( + jwt = map["jwt"] as String, ) } - - fun toMap(): Map = mapOf( - "jwt" to jwt as Any - ) } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Language.kt b/library/src/main/java/io/appwrite/models/Language.kt index 045202f..8860aad 100644 --- a/library/src/main/java/io/appwrite/models/Language.kt +++ b/library/src/main/java/io/appwrite/models/Language.kt @@ -1,6 +1,7 @@ package io.appwrite.models import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast /** * Language @@ -8,37 +9,38 @@ import com.google.gson.annotations.SerializedName data class Language( /** * Language name. - * */ @SerializedName("name") val name: String, /** * Language two-character ISO 639-1 codes. - * */ @SerializedName("code") val code: String, /** * Language native name. - * */ @SerializedName("nativeName") - val nativeName: String + val nativeName: String, + ) { + fun toMap(): Map = mapOf( + "name" to name as Any, + "code" to code as Any, + "nativeName" to nativeName as Any, + ) + companion object { + @Suppress("UNCHECKED_CAST") - fun from(map: Map) = Language( + fun from( + map: Map, + ) = Language( name = map["name"] as String, code = map["code"] as String, - nativeName = map["nativeName"] as String + nativeName = map["nativeName"] as String, ) } - - fun toMap(): Map = mapOf( - "name" to name as Any, - "code" to code as Any, - "nativeName" to nativeName as Any - ) } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/LanguageList.kt b/library/src/main/java/io/appwrite/models/LanguageList.kt index 8ca4f5f..07559b9 100644 --- a/library/src/main/java/io/appwrite/models/LanguageList.kt +++ b/library/src/main/java/io/appwrite/models/LanguageList.kt @@ -1,6 +1,7 @@ package io.appwrite.models import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast /** * Languages List @@ -8,28 +9,30 @@ import com.google.gson.annotations.SerializedName data class LanguageList( /** * Total number of languages documents that matched your query. - * */ @SerializedName("total") val total: Long, /** * List of languages. - * */ @SerializedName("languages") - val languages: List + val languages: List, + ) { + fun toMap(): Map = mapOf( + "total" to total as Any, + "languages" to languages.map { it.toMap() } as Any, + ) + companion object { + @Suppress("UNCHECKED_CAST") - fun from(map: Map) = LanguageList( + fun from( + map: Map, + ) = LanguageList( total = (map["total"] as Number).toLong(), - languages = (map["languages"] as List>).map { Language.from(map = it) } + languages = (map["languages"] as List>).map { Language.from(map = it) }, ) } - - fun toMap(): Map = mapOf( - "total" to total as Any, - "languages" to languages.map { it.toMap() } as Any - ) } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Locale.kt b/library/src/main/java/io/appwrite/models/Locale.kt index d8d3fcf..4327545 100644 --- a/library/src/main/java/io/appwrite/models/Locale.kt +++ b/library/src/main/java/io/appwrite/models/Locale.kt @@ -1,6 +1,7 @@ package io.appwrite.models import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast /** * Locale @@ -8,73 +9,70 @@ import com.google.gson.annotations.SerializedName data class Locale( /** * User IP address. - * */ @SerializedName("ip") val ip: String, /** * Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format - * */ @SerializedName("countryCode") val countryCode: String, /** * Country name. This field support localization. - * */ @SerializedName("country") val country: String, /** * Continent code. A two character continent code "AF" for Africa, "AN" for Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" for Oceania, and "SA" for South America. - * */ @SerializedName("continentCode") val continentCode: String, /** * Continent name. This field support localization. - * */ @SerializedName("continent") val continent: String, /** * True if country is part of the Europian Union. - * */ @SerializedName("eu") val eu: Boolean, /** * Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format - * */ @SerializedName("currency") - val currency: String + val currency: String, + ) { + fun toMap(): Map = mapOf( + "ip" to ip as Any, + "countryCode" to countryCode as Any, + "country" to country as Any, + "continentCode" to continentCode as Any, + "continent" to continent as Any, + "eu" to eu as Any, + "currency" to currency as Any, + ) + companion object { + @Suppress("UNCHECKED_CAST") - fun from(map: Map) = Locale( + fun from( + map: Map, + ) = Locale( ip = map["ip"] as String, countryCode = map["countryCode"] as String, country = map["country"] as String, continentCode = map["continentCode"] as String, continent = map["continent"] as String, eu = map["eu"] as Boolean, - currency = map["currency"] as String + currency = map["currency"] as String, ) } - - fun toMap(): Map = mapOf( - "ip" to ip as Any, - "countryCode" to countryCode as Any, - "country" to country as Any, - "continentCode" to continentCode as Any, - "continent" to continent as Any, - "eu" to eu as Any, - "currency" to currency as Any - ) } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Log.kt b/library/src/main/java/io/appwrite/models/Log.kt index 2343352..c2df960 100644 --- a/library/src/main/java/io/appwrite/models/Log.kt +++ b/library/src/main/java/io/appwrite/models/Log.kt @@ -1,6 +1,7 @@ package io.appwrite.models import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast /** * Log @@ -8,154 +9,161 @@ import com.google.gson.annotations.SerializedName data class Log( /** * Event name. - * */ @SerializedName("event") val event: String, /** * User ID. - * */ @SerializedName("userId") val userId: String, /** * User Email. - * */ @SerializedName("userEmail") val userEmail: String, /** * User Name. - * */ @SerializedName("userName") val userName: String, /** * API mode when event triggered. - * */ @SerializedName("mode") val mode: String, /** * IP session in use when the session was created. - * */ @SerializedName("ip") val ip: String, /** * Log creation date in ISO 8601 format. - * */ @SerializedName("time") val time: String, /** * Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). - * */ @SerializedName("osCode") val osCode: String, /** * Operating system name. - * */ @SerializedName("osName") val osName: String, /** * Operating system version. - * */ @SerializedName("osVersion") val osVersion: String, /** * Client type. - * */ @SerializedName("clientType") val clientType: String, /** * Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). - * */ @SerializedName("clientCode") val clientCode: String, /** * Client name. - * */ @SerializedName("clientName") val clientName: String, /** * Client version. - * */ @SerializedName("clientVersion") val clientVersion: String, /** * Client engine name. - * */ @SerializedName("clientEngine") val clientEngine: String, /** * Client engine name. - * */ @SerializedName("clientEngineVersion") val clientEngineVersion: String, /** * Device name. - * */ @SerializedName("deviceName") val deviceName: String, /** * Device brand name. - * */ @SerializedName("deviceBrand") val deviceBrand: String, /** * Device model name. - * */ @SerializedName("deviceModel") val deviceModel: String, /** * Country two-character ISO 3166-1 alpha code. - * */ @SerializedName("countryCode") val countryCode: String, /** * Country name. - * */ @SerializedName("countryName") - val countryName: String + val countryName: String, + ) { + fun toMap(): Map = mapOf( + "event" to event as Any, + "userId" to userId as Any, + "userEmail" to userEmail as Any, + "userName" to userName as Any, + "mode" to mode as Any, + "ip" to ip as Any, + "time" to time as Any, + "osCode" to osCode as Any, + "osName" to osName as Any, + "osVersion" to osVersion as Any, + "clientType" to clientType as Any, + "clientCode" to clientCode as Any, + "clientName" to clientName as Any, + "clientVersion" to clientVersion as Any, + "clientEngine" to clientEngine as Any, + "clientEngineVersion" to clientEngineVersion as Any, + "deviceName" to deviceName as Any, + "deviceBrand" to deviceBrand as Any, + "deviceModel" to deviceModel as Any, + "countryCode" to countryCode as Any, + "countryName" to countryName as Any, + ) + companion object { + @Suppress("UNCHECKED_CAST") - fun from(map: Map) = Log( + fun from( + map: Map, + ) = Log( event = map["event"] as String, userId = map["userId"] as String, userEmail = map["userEmail"] as String, @@ -176,31 +184,7 @@ data class Log( deviceBrand = map["deviceBrand"] as String, deviceModel = map["deviceModel"] as String, countryCode = map["countryCode"] as String, - countryName = map["countryName"] as String + countryName = map["countryName"] as String, ) } - - fun toMap(): Map = mapOf( - "event" to event as Any, - "userId" to userId as Any, - "userEmail" to userEmail as Any, - "userName" to userName as Any, - "mode" to mode as Any, - "ip" to ip as Any, - "time" to time as Any, - "osCode" to osCode as Any, - "osName" to osName as Any, - "osVersion" to osVersion as Any, - "clientType" to clientType as Any, - "clientCode" to clientCode as Any, - "clientName" to clientName as Any, - "clientVersion" to clientVersion as Any, - "clientEngine" to clientEngine as Any, - "clientEngineVersion" to clientEngineVersion as Any, - "deviceName" to deviceName as Any, - "deviceBrand" to deviceBrand as Any, - "deviceModel" to deviceModel as Any, - "countryCode" to countryCode as Any, - "countryName" to countryName as Any - ) } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/LogList.kt b/library/src/main/java/io/appwrite/models/LogList.kt index 47d5680..b9f381c 100644 --- a/library/src/main/java/io/appwrite/models/LogList.kt +++ b/library/src/main/java/io/appwrite/models/LogList.kt @@ -1,6 +1,7 @@ package io.appwrite.models import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast /** * Logs List @@ -8,28 +9,30 @@ import com.google.gson.annotations.SerializedName data class LogList( /** * Total number of logs documents that matched your query. - * */ @SerializedName("total") val total: Long, /** * List of logs. - * */ @SerializedName("logs") - val logs: List + val logs: List, + ) { + fun toMap(): Map = mapOf( + "total" to total as Any, + "logs" to logs.map { it.toMap() } as Any, + ) + companion object { + @Suppress("UNCHECKED_CAST") - fun from(map: Map) = LogList( + fun from( + map: Map, + ) = LogList( total = (map["total"] as Number).toLong(), - logs = (map["logs"] as List>).map { Log.from(map = it) } + logs = (map["logs"] as List>).map { Log.from(map = it) }, ) } - - fun toMap(): Map = mapOf( - "total" to total as Any, - "logs" to logs.map { it.toMap() } as Any - ) } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Membership.kt b/library/src/main/java/io/appwrite/models/Membership.kt index a923fea..96a364f 100644 --- a/library/src/main/java/io/appwrite/models/Membership.kt +++ b/library/src/main/java/io/appwrite/models/Membership.kt @@ -1,6 +1,7 @@ package io.appwrite.models import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast /** * Membership @@ -8,91 +9,98 @@ import com.google.gson.annotations.SerializedName data class Membership( /** * Membership ID. - * */ @SerializedName("\$id") val id: String, /** * Membership creation date in ISO 8601 format. - * */ @SerializedName("\$createdAt") val createdAt: String, /** * Membership update date in ISO 8601 format. - * */ @SerializedName("\$updatedAt") val updatedAt: String, /** * User ID. - * */ @SerializedName("userId") val userId: String, /** * User name. - * */ @SerializedName("userName") val userName: String, /** * User email address. - * */ @SerializedName("userEmail") val userEmail: String, /** * Team ID. - * */ @SerializedName("teamId") val teamId: String, /** * Team name. - * */ @SerializedName("teamName") val teamName: String, /** * Date, the user has been invited to join the team in ISO 8601 format. - * */ @SerializedName("invited") val invited: String, /** * Date, the user has accepted the invitation to join the team in ISO 8601 format. - * */ @SerializedName("joined") val joined: String, /** * User confirmation status, true if the user has joined the team or false otherwise. - * */ @SerializedName("confirm") val confirm: Boolean, /** * User list of roles - * */ @SerializedName("roles") - val roles: List + val roles: List, + ) { + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "\$createdAt" to createdAt as Any, + "\$updatedAt" to updatedAt as Any, + "userId" to userId as Any, + "userName" to userName as Any, + "userEmail" to userEmail as Any, + "teamId" to teamId as Any, + "teamName" to teamName as Any, + "invited" to invited as Any, + "joined" to joined as Any, + "confirm" to confirm as Any, + "roles" to roles as Any, + ) + companion object { + @Suppress("UNCHECKED_CAST") - fun from(map: Map) = Membership( + fun from( + map: Map, + ) = Membership( id = map["\$id"] as String, createdAt = map["\$createdAt"] as String, updatedAt = map["\$updatedAt"] as String, @@ -104,22 +112,7 @@ data class Membership( invited = map["invited"] as String, joined = map["joined"] as String, confirm = map["confirm"] as Boolean, - roles = map["roles"] as List + roles = map["roles"] as List, ) } - - fun toMap(): Map = mapOf( - "\$id" to id as Any, - "\$createdAt" to createdAt as Any, - "\$updatedAt" to updatedAt as Any, - "userId" to userId as Any, - "userName" to userName as Any, - "userEmail" to userEmail as Any, - "teamId" to teamId as Any, - "teamName" to teamName as Any, - "invited" to invited as Any, - "joined" to joined as Any, - "confirm" to confirm as Any, - "roles" to roles as Any - ) } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/MembershipList.kt b/library/src/main/java/io/appwrite/models/MembershipList.kt index 1b7549d..7feaaaa 100644 --- a/library/src/main/java/io/appwrite/models/MembershipList.kt +++ b/library/src/main/java/io/appwrite/models/MembershipList.kt @@ -1,6 +1,7 @@ package io.appwrite.models import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast /** * Memberships List @@ -8,28 +9,30 @@ import com.google.gson.annotations.SerializedName data class MembershipList( /** * Total number of memberships documents that matched your query. - * */ @SerializedName("total") val total: Long, /** * List of memberships. - * */ @SerializedName("memberships") - val memberships: List + val memberships: List, + ) { + fun toMap(): Map = mapOf( + "total" to total as Any, + "memberships" to memberships.map { it.toMap() } as Any, + ) + companion object { + @Suppress("UNCHECKED_CAST") - fun from(map: Map) = MembershipList( + fun from( + map: Map, + ) = MembershipList( total = (map["total"] as Number).toLong(), - memberships = (map["memberships"] as List>).map { Membership.from(map = it) } + memberships = (map["memberships"] as List>).map { Membership.from(map = it) }, ) } - - fun toMap(): Map = mapOf( - "total" to total as Any, - "memberships" to memberships.map { it.toMap() } as Any - ) } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Phone.kt b/library/src/main/java/io/appwrite/models/Phone.kt index bfa3113..28aea2d 100644 --- a/library/src/main/java/io/appwrite/models/Phone.kt +++ b/library/src/main/java/io/appwrite/models/Phone.kt @@ -1,6 +1,7 @@ package io.appwrite.models import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast /** * Phone @@ -8,37 +9,38 @@ import com.google.gson.annotations.SerializedName data class Phone( /** * Phone code. - * */ @SerializedName("code") val code: String, /** * Country two-character ISO 3166-1 alpha code. - * */ @SerializedName("countryCode") val countryCode: String, /** * Country name. - * */ @SerializedName("countryName") - val countryName: String + val countryName: String, + ) { + fun toMap(): Map = mapOf( + "code" to code as Any, + "countryCode" to countryCode as Any, + "countryName" to countryName as Any, + ) + companion object { + @Suppress("UNCHECKED_CAST") - fun from(map: Map) = Phone( + fun from( + map: Map, + ) = Phone( code = map["code"] as String, countryCode = map["countryCode"] as String, - countryName = map["countryName"] as String + countryName = map["countryName"] as String, ) } - - fun toMap(): Map = mapOf( - "code" to code as Any, - "countryCode" to countryCode as Any, - "countryName" to countryName as Any - ) } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/PhoneList.kt b/library/src/main/java/io/appwrite/models/PhoneList.kt index 6dee844..b17de4f 100644 --- a/library/src/main/java/io/appwrite/models/PhoneList.kt +++ b/library/src/main/java/io/appwrite/models/PhoneList.kt @@ -1,6 +1,7 @@ package io.appwrite.models import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast /** * Phones List @@ -8,28 +9,30 @@ import com.google.gson.annotations.SerializedName data class PhoneList( /** * Total number of phones documents that matched your query. - * */ @SerializedName("total") val total: Long, /** * List of phones. - * */ @SerializedName("phones") - val phones: List + val phones: List, + ) { + fun toMap(): Map = mapOf( + "total" to total as Any, + "phones" to phones.map { it.toMap() } as Any, + ) + companion object { + @Suppress("UNCHECKED_CAST") - fun from(map: Map) = PhoneList( + fun from( + map: Map, + ) = PhoneList( total = (map["total"] as Number).toLong(), - phones = (map["phones"] as List>).map { Phone.from(map = it) } + phones = (map["phones"] as List>).map { Phone.from(map = it) }, ) } - - fun toMap(): Map = mapOf( - "total" to total as Any, - "phones" to phones.map { it.toMap() } as Any - ) } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Preferences.kt b/library/src/main/java/io/appwrite/models/Preferences.kt index 0b11e85..309fb98 100644 --- a/library/src/main/java/io/appwrite/models/Preferences.kt +++ b/library/src/main/java/io/appwrite/models/Preferences.kt @@ -1,25 +1,35 @@ package io.appwrite.models import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast /** * Preferences */ -data class Preferences( - val data: Map +data class Preferences( + /** + * Additional properties + */ + @SerializedName("data") + val data: T ) { - companion object { - @Suppress("UNCHECKED_CAST") - fun from(map: Map) = Preferences( - data = map - ) - } - fun toMap(): Map = mapOf( - "data" to data + "data" to data!!.jsonCast(to = Map::class.java) ) - fun convertTo(fromJson: (Map) -> T): T { - return fromJson(data) + companion object { + operator fun invoke( + data: Map + ) = Preferences>( + data + ) + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + nestedType: Class + ) = Preferences( + data = map.jsonCast(to = nestedType) + ) } } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Session.kt b/library/src/main/java/io/appwrite/models/Session.kt index 3510640..7674d72 100644 --- a/library/src/main/java/io/appwrite/models/Session.kt +++ b/library/src/main/java/io/appwrite/models/Session.kt @@ -1,6 +1,7 @@ package io.appwrite.models import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast /** * Session @@ -8,182 +9,189 @@ import com.google.gson.annotations.SerializedName data class Session( /** * Session ID. - * */ @SerializedName("\$id") val id: String, /** * Session creation date in ISO 8601 format. - * */ @SerializedName("\$createdAt") val createdAt: String, /** * User ID. - * */ @SerializedName("userId") val userId: String, /** * Session expiration date in ISO 8601 format. - * */ @SerializedName("expire") val expire: String, /** * Session Provider. - * */ @SerializedName("provider") val provider: String, /** * Session Provider User ID. - * */ @SerializedName("providerUid") val providerUid: String, /** * Session Provider Access Token. - * */ @SerializedName("providerAccessToken") val providerAccessToken: String, /** * The date of when the access token expires in ISO 8601 format. - * */ @SerializedName("providerAccessTokenExpiry") val providerAccessTokenExpiry: String, /** * Session Provider Refresh Token. - * */ @SerializedName("providerRefreshToken") val providerRefreshToken: String, /** * IP in use when the session was created. - * */ @SerializedName("ip") val ip: String, /** * Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). - * */ @SerializedName("osCode") val osCode: String, /** * Operating system name. - * */ @SerializedName("osName") val osName: String, /** * Operating system version. - * */ @SerializedName("osVersion") val osVersion: String, /** * Client type. - * */ @SerializedName("clientType") val clientType: String, /** * Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). - * */ @SerializedName("clientCode") val clientCode: String, /** * Client name. - * */ @SerializedName("clientName") val clientName: String, /** * Client version. - * */ @SerializedName("clientVersion") val clientVersion: String, /** * Client engine name. - * */ @SerializedName("clientEngine") val clientEngine: String, /** * Client engine name. - * */ @SerializedName("clientEngineVersion") val clientEngineVersion: String, /** * Device name. - * */ @SerializedName("deviceName") val deviceName: String, /** * Device brand name. - * */ @SerializedName("deviceBrand") val deviceBrand: String, /** * Device model name. - * */ @SerializedName("deviceModel") val deviceModel: String, /** * Country two-character ISO 3166-1 alpha code. - * */ @SerializedName("countryCode") val countryCode: String, /** * Country name. - * */ @SerializedName("countryName") val countryName: String, /** * Returns true if this the current user session. - * */ @SerializedName("current") - val current: Boolean + val current: Boolean, + ) { + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "\$createdAt" to createdAt as Any, + "userId" to userId as Any, + "expire" to expire as Any, + "provider" to provider as Any, + "providerUid" to providerUid as Any, + "providerAccessToken" to providerAccessToken as Any, + "providerAccessTokenExpiry" to providerAccessTokenExpiry as Any, + "providerRefreshToken" to providerRefreshToken as Any, + "ip" to ip as Any, + "osCode" to osCode as Any, + "osName" to osName as Any, + "osVersion" to osVersion as Any, + "clientType" to clientType as Any, + "clientCode" to clientCode as Any, + "clientName" to clientName as Any, + "clientVersion" to clientVersion as Any, + "clientEngine" to clientEngine as Any, + "clientEngineVersion" to clientEngineVersion as Any, + "deviceName" to deviceName as Any, + "deviceBrand" to deviceBrand as Any, + "deviceModel" to deviceModel as Any, + "countryCode" to countryCode as Any, + "countryName" to countryName as Any, + "current" to current as Any, + ) + companion object { + @Suppress("UNCHECKED_CAST") - fun from(map: Map) = Session( + fun from( + map: Map, + ) = Session( id = map["\$id"] as String, createdAt = map["\$createdAt"] as String, userId = map["userId"] as String, @@ -208,35 +216,7 @@ data class Session( deviceModel = map["deviceModel"] as String, countryCode = map["countryCode"] as String, countryName = map["countryName"] as String, - current = map["current"] as Boolean + current = map["current"] as Boolean, ) } - - fun toMap(): Map = mapOf( - "\$id" to id as Any, - "\$createdAt" to createdAt as Any, - "userId" to userId as Any, - "expire" to expire as Any, - "provider" to provider as Any, - "providerUid" to providerUid as Any, - "providerAccessToken" to providerAccessToken as Any, - "providerAccessTokenExpiry" to providerAccessTokenExpiry as Any, - "providerRefreshToken" to providerRefreshToken as Any, - "ip" to ip as Any, - "osCode" to osCode as Any, - "osName" to osName as Any, - "osVersion" to osVersion as Any, - "clientType" to clientType as Any, - "clientCode" to clientCode as Any, - "clientName" to clientName as Any, - "clientVersion" to clientVersion as Any, - "clientEngine" to clientEngine as Any, - "clientEngineVersion" to clientEngineVersion as Any, - "deviceName" to deviceName as Any, - "deviceBrand" to deviceBrand as Any, - "deviceModel" to deviceModel as Any, - "countryCode" to countryCode as Any, - "countryName" to countryName as Any, - "current" to current as Any - ) } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/SessionList.kt b/library/src/main/java/io/appwrite/models/SessionList.kt index 9891102..c7080e6 100644 --- a/library/src/main/java/io/appwrite/models/SessionList.kt +++ b/library/src/main/java/io/appwrite/models/SessionList.kt @@ -1,6 +1,7 @@ package io.appwrite.models import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast /** * Sessions List @@ -8,28 +9,30 @@ import com.google.gson.annotations.SerializedName data class SessionList( /** * Total number of sessions documents that matched your query. - * */ @SerializedName("total") val total: Long, /** * List of sessions. - * */ @SerializedName("sessions") - val sessions: List + val sessions: List, + ) { + fun toMap(): Map = mapOf( + "total" to total as Any, + "sessions" to sessions.map { it.toMap() } as Any, + ) + companion object { + @Suppress("UNCHECKED_CAST") - fun from(map: Map) = SessionList( + fun from( + map: Map, + ) = SessionList( total = (map["total"] as Number).toLong(), - sessions = (map["sessions"] as List>).map { Session.from(map = it) } + sessions = (map["sessions"] as List>).map { Session.from(map = it) }, ) } - - fun toMap(): Map = mapOf( - "total" to total as Any, - "sessions" to sessions.map { it.toMap() } as Any - ) } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Team.kt b/library/src/main/java/io/appwrite/models/Team.kt index c3b038f..76f7cb2 100644 --- a/library/src/main/java/io/appwrite/models/Team.kt +++ b/library/src/main/java/io/appwrite/models/Team.kt @@ -1,6 +1,7 @@ package io.appwrite.models import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast /** * Team @@ -8,55 +9,54 @@ import com.google.gson.annotations.SerializedName data class Team( /** * Team ID. - * */ @SerializedName("\$id") val id: String, /** * Team creation date in ISO 8601 format. - * */ @SerializedName("\$createdAt") val createdAt: String, /** * Team update date in ISO 8601 format. - * */ @SerializedName("\$updatedAt") val updatedAt: String, /** * Team name. - * */ @SerializedName("name") val name: String, /** * Total number of team members. - * */ @SerializedName("total") - val total: Long + val total: Long, + ) { + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "\$createdAt" to createdAt as Any, + "\$updatedAt" to updatedAt as Any, + "name" to name as Any, + "total" to total as Any, + ) + companion object { + @Suppress("UNCHECKED_CAST") - fun from(map: Map) = Team( + fun from( + map: Map, + ) = Team( id = map["\$id"] as String, createdAt = map["\$createdAt"] as String, updatedAt = map["\$updatedAt"] as String, name = map["name"] as String, - total = (map["total"] as Number).toLong() + total = (map["total"] as Number).toLong(), ) } - - fun toMap(): Map = mapOf( - "\$id" to id as Any, - "\$createdAt" to createdAt as Any, - "\$updatedAt" to updatedAt as Any, - "name" to name as Any, - "total" to total as Any - ) } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/TeamList.kt b/library/src/main/java/io/appwrite/models/TeamList.kt index 4f210b3..ab76ed6 100644 --- a/library/src/main/java/io/appwrite/models/TeamList.kt +++ b/library/src/main/java/io/appwrite/models/TeamList.kt @@ -1,6 +1,7 @@ package io.appwrite.models import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast /** * Teams List @@ -8,28 +9,30 @@ import com.google.gson.annotations.SerializedName data class TeamList( /** * Total number of teams documents that matched your query. - * */ @SerializedName("total") val total: Long, /** * List of teams. - * */ @SerializedName("teams") - val teams: List + val teams: List, + ) { + fun toMap(): Map = mapOf( + "total" to total as Any, + "teams" to teams.map { it.toMap() } as Any, + ) + companion object { + @Suppress("UNCHECKED_CAST") - fun from(map: Map) = TeamList( + fun from( + map: Map, + ) = TeamList( total = (map["total"] as Number).toLong(), - teams = (map["teams"] as List>).map { Team.from(map = it) } + teams = (map["teams"] as List>).map { Team.from(map = it) }, ) } - - fun toMap(): Map = mapOf( - "total" to total as Any, - "teams" to teams.map { it.toMap() } as Any - ) } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Token.kt b/library/src/main/java/io/appwrite/models/Token.kt index 2587776..8c0f0e0 100644 --- a/library/src/main/java/io/appwrite/models/Token.kt +++ b/library/src/main/java/io/appwrite/models/Token.kt @@ -1,6 +1,7 @@ package io.appwrite.models import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast /** * Token @@ -8,55 +9,54 @@ import com.google.gson.annotations.SerializedName data class Token( /** * Token ID. - * */ @SerializedName("\$id") val id: String, /** * Token creation date in ISO 8601 format. - * */ @SerializedName("\$createdAt") val createdAt: String, /** * User ID. - * */ @SerializedName("userId") val userId: String, /** * Token secret key. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. - * */ @SerializedName("secret") val secret: String, /** * Token expiration date in ISO 8601 format. - * */ @SerializedName("expire") - val expire: String + val expire: String, + ) { + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "\$createdAt" to createdAt as Any, + "userId" to userId as Any, + "secret" to secret as Any, + "expire" to expire as Any, + ) + companion object { + @Suppress("UNCHECKED_CAST") - fun from(map: Map) = Token( + fun from( + map: Map, + ) = Token( id = map["\$id"] as String, createdAt = map["\$createdAt"] as String, userId = map["userId"] as String, secret = map["secret"] as String, - expire = map["expire"] as String + expire = map["expire"] as String, ) } - - fun toMap(): Map = mapOf( - "\$id" to id as Any, - "\$createdAt" to createdAt as Any, - "userId" to userId as Any, - "secret" to secret as Any, - "expire" to expire as Any - ) } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index 8241afa..83d41fd 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -3,15 +3,18 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client import io.appwrite.models.* +import io.appwrite.exceptions.AppwriteException +import io.appwrite.extensions.classOf import io.appwrite.WebAuthComponent import androidx.activity.ComponentActivity -import io.appwrite.exceptions.AppwriteException import okhttp3.Cookie -import okhttp3.Response import okhttp3.HttpUrl import okhttp3.HttpUrl.Companion.toHttpUrl import java.io.File +/** + * The Account service allows you to authenticate and manage a user account. +**/ class Account : Service { public constructor (client: Client) : super(client) { } @@ -21,143 +24,187 @@ class Account : Service { * * Get currently logged in user data as JSON object. * - * @return [io.appwrite.models.Account] + * @return [io.appwrite.models.Account] */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun get(): io.appwrite.models.Account { + suspend fun get( + nestedType: Class, + ): io.appwrite.models.Account { val path = "/account" + val params = mutableMapOf( ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.Account = { - io.appwrite.models.Account.from(map = it) - } + val converter: (Any) -> io.appwrite.models.Account = { + io.appwrite.models.Account.from(map = it as Map, nestedType) + } return client.call( "GET", path, headers, params, - responseType = io.appwrite.models.Account::class.java, + responseType = classOf(), converter, ) } - + + /** + * Get Account + * + * Get currently logged in user data as JSON object. + * + * @return [io.appwrite.models.Account] + */ + @Throws(AppwriteException::class) + suspend fun get( + ) = get( + nestedType = classOf(), + ) + /** * Create Account * - * Use this endpoint to allow a new user to register a new account in your - * project. After the user registration completes successfully, you can use - * the [/account/verfication](/docs/client/account#accountCreateVerification) - * route to start verifying the user email address. To allow the new user to - * login to their new account, you need to create a new [account - * session](/docs/client/account#accountCreateSession). + * Use this endpoint to allow a new user to register a new account in your project. After the user registration completes successfully, you can use the [/account/verfication](/docs/client/account#accountCreateVerification) route to start verifying the user email address. To allow the new user to login to their new account, you need to create a new [account session](/docs/client/account#accountCreateSession). * - * @param userId Unique Id. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param userId Unique Id. Choose your own unique ID or pass the string `ID.unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param email User email. * @param password User password. Must be at least 8 chars. * @param name User name. Max length: 128 chars. - * @return [io.appwrite.models.Account] + * @return [io.appwrite.models.Account] */ @JvmOverloads - @Throws(AppwriteException::class) - suspend fun create( - userId: String, - email: String, - password: String, - name: String? = null - ): io.appwrite.models.Account { + suspend fun create( + userId: String, + email: String, + password: String, + name: String? = null, + nestedType: Class, + ): io.appwrite.models.Account { val path = "/account" + val params = mutableMapOf( "userId" to userId, "email" to email, "password" to password, - "name" to name + "name" to name, ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.Account = { - io.appwrite.models.Account.from(map = it) - } + val converter: (Any) -> io.appwrite.models.Account = { + io.appwrite.models.Account.from(map = it as Map, nestedType) + } return client.call( "POST", path, headers, params, - responseType = io.appwrite.models.Account::class.java, + responseType = classOf(), converter, ) } - + /** - * Update Account Email + * Create Account * - * Update currently logged in user account email address. After changing user - * address, the user confirmation status will get reset. A new confirmation - * email is not sent automatically however you can use the send confirmation - * email endpoint again to send the confirmation email. For security measures, - * user password is required to complete this request. - * This endpoint can also be used to convert an anonymous account to a normal - * one, by passing an email address and a new password. - * + * Use this endpoint to allow a new user to register a new account in your project. After the user registration completes successfully, you can use the [/account/verfication](/docs/client/account#accountCreateVerification) route to start verifying the user email address. To allow the new user to login to their new account, you need to create a new [account session](/docs/client/account#accountCreateSession). * + * @param userId Unique Id. Choose your own unique ID or pass the string `ID.unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param email User email. * @param password User password. Must be at least 8 chars. - * @return [io.appwrite.models.Account] + * @param name User name. Max length: 128 chars. + * @return [io.appwrite.models.Account] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun updateEmail( - email: String, - password: String - ): io.appwrite.models.Account { + suspend fun create( + userId: String, + email: String, + password: String, + name: String? = null, + ) = create( + userId, + email, + password, + name, + nestedType = classOf(), + ) + + /** + * Update Email + * + * Update currently logged in user account email address. After changing user address, the user confirmation status will get reset. A new confirmation email is not sent automatically however you can use the send confirmation email endpoint again to send the confirmation email. For security measures, user password is required to complete this request.This endpoint can also be used to convert an anonymous account to a normal one, by passing an email address and a new password. + * + * @param email User email. + * @param password User password. Must be at least 8 chars. + * @return [io.appwrite.models.Account] + */ + suspend fun updateEmail( + email: String, + password: String, + nestedType: Class, + ): io.appwrite.models.Account { val path = "/account/email" + val params = mutableMapOf( "email" to email, - "password" to password + "password" to password, ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.Account = { - io.appwrite.models.Account.from(map = it) - } + val converter: (Any) -> io.appwrite.models.Account = { + io.appwrite.models.Account.from(map = it as Map, nestedType) + } return client.call( "PATCH", path, headers, params, - responseType = io.appwrite.models.Account::class.java, + responseType = classOf(), converter, ) } - + /** - * Create Account JWT + * Update Email * - * Use this endpoint to create a JSON Web Token. You can use the resulting JWT - * to authenticate on behalf of the current user when working with the - * Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes - * from its creation and will be invalid if the user will logout in that time - * frame. + * Update currently logged in user account email address. After changing user address, the user confirmation status will get reset. A new confirmation email is not sent automatically however you can use the send confirmation email endpoint again to send the confirmation email. For security measures, user password is required to complete this request.This endpoint can also be used to convert an anonymous account to a normal one, by passing an email address and a new password. * - * @return [io.appwrite.models.Jwt] + * @param email User email. + * @param password User password. Must be at least 8 chars. + * @return [io.appwrite.models.Account] */ - @JvmOverloads @Throws(AppwriteException::class) - suspend fun createJWT(): io.appwrite.models.Jwt { + suspend fun updateEmail( + email: String, + password: String, + ) = updateEmail( + email, + password, + nestedType = classOf(), + ) + + /** + * Create JWT + * + * Use this endpoint to create a JSON Web Token. You can use the resulting JWT to authenticate on behalf of the current user when working with the Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes from its creation and will be invalid if the user will logout in that time frame. + * + * @return [io.appwrite.models.Jwt] + */ + suspend fun createJWT( + ): io.appwrite.models.Jwt { val path = "/account/jwt" + val params = mutableMapOf( ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.Jwt = { - io.appwrite.models.Jwt.from(map = it) - } + val converter: (Any) -> io.appwrite.models.Jwt = { + io.appwrite.models.Jwt.from(map = it as Map) + } return client.call( "POST", path, @@ -167,31 +214,31 @@ class Account : Service { converter, ) } - + + /** - * List Account Logs + * List Logs * - * Get currently logged in user list of latest security activity logs. Each - * log returns user IP address, location and date and time of log. + * Get currently logged in user list of latest security activity logs. Each log returns user IP address, location and date and time of log. * * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Only supported methods are limit and offset - * @return [io.appwrite.models.LogList] + * @return [io.appwrite.models.LogList] */ @JvmOverloads - @Throws(AppwriteException::class) suspend fun listLogs( - queries: List? = null - ): io.appwrite.models.LogList { + queries: List? = null, + ): io.appwrite.models.LogList { val path = "/account/logs" + val params = mutableMapOf( - "queries" to queries + "queries" to queries, ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.LogList = { - io.appwrite.models.LogList.from(map = it) - } + val converter: (Any) -> io.appwrite.models.LogList = { + io.appwrite.models.LogList.from(map = it as Map) + } return client.call( "GET", path, @@ -201,215 +248,286 @@ class Account : Service { converter, ) } - + + /** - * Update Account Name + * Update Name * * Update currently logged in user account name. * * @param name User name. Max length: 128 chars. - * @return [io.appwrite.models.Account] + * @return [io.appwrite.models.Account] */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun updateName( - name: String - ): io.appwrite.models.Account { + suspend fun updateName( + name: String, + nestedType: Class, + ): io.appwrite.models.Account { val path = "/account/name" + val params = mutableMapOf( - "name" to name + "name" to name, ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.Account = { - io.appwrite.models.Account.from(map = it) - } + val converter: (Any) -> io.appwrite.models.Account = { + io.appwrite.models.Account.from(map = it as Map, nestedType) + } return client.call( "PATCH", path, headers, params, - responseType = io.appwrite.models.Account::class.java, + responseType = classOf(), converter, ) } - + /** - * Update Account Password + * Update Name * - * Update currently logged in user password. For validation, user is required - * to pass in the new password, and the old password. For users created with - * OAuth, Team Invites and Magic URL, oldPassword is optional. + * Update currently logged in user account name. + * + * @param name User name. Max length: 128 chars. + * @return [io.appwrite.models.Account] + */ + @Throws(AppwriteException::class) + suspend fun updateName( + name: String, + ) = updateName( + name, + nestedType = classOf(), + ) + + /** + * Update Password + * + * Update currently logged in user password. For validation, user is required to pass in the new password, and the old password. For users created with OAuth, Team Invites and Magic URL, oldPassword is optional. * * @param password New user password. Must be at least 8 chars. * @param oldPassword Current user password. Must be at least 8 chars. - * @return [io.appwrite.models.Account] + * @return [io.appwrite.models.Account] */ @JvmOverloads - @Throws(AppwriteException::class) - suspend fun updatePassword( - password: String, - oldPassword: String? = null - ): io.appwrite.models.Account { + suspend fun updatePassword( + password: String, + oldPassword: String? = null, + nestedType: Class, + ): io.appwrite.models.Account { val path = "/account/password" + val params = mutableMapOf( "password" to password, - "oldPassword" to oldPassword + "oldPassword" to oldPassword, ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.Account = { - io.appwrite.models.Account.from(map = it) - } + val converter: (Any) -> io.appwrite.models.Account = { + io.appwrite.models.Account.from(map = it as Map, nestedType) + } return client.call( "PATCH", path, headers, params, - responseType = io.appwrite.models.Account::class.java, + responseType = classOf(), converter, ) } - + /** - * Update Account Phone + * Update Password * - * Update the currently logged in user's phone number. After updating the - * phone number, the phone verification status will be reset. A confirmation - * SMS is not sent automatically, however you can use the [POST - * /account/verification/phone](/docs/client/account#accountCreatePhoneVerification) - * endpoint to send a confirmation SMS. + * Update currently logged in user password. For validation, user is required to pass in the new password, and the old password. For users created with OAuth, Team Invites and Magic URL, oldPassword is optional. * - * @param phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. - * @param password User password. Must be at least 8 chars. - * @return [io.appwrite.models.Account] + * @param password New user password. Must be at least 8 chars. + * @param oldPassword Current user password. Must be at least 8 chars. + * @return [io.appwrite.models.Account] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun updatePhone( - phone: String, - password: String - ): io.appwrite.models.Account { + suspend fun updatePassword( + password: String, + oldPassword: String? = null, + ) = updatePassword( + password, + oldPassword, + nestedType = classOf(), + ) + + /** + * Update Phone + * + * Update the currently logged in user's phone number. After updating the phone number, the phone verification status will be reset. A confirmation SMS is not sent automatically, however you can use the [POST /account/verification/phone](/docs/client/account#accountCreatePhoneVerification) endpoint to send a confirmation SMS. + * + * @param phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param password User password. Must be at least 8 chars. + * @return [io.appwrite.models.Account] + */ + suspend fun updatePhone( + phone: String, + password: String, + nestedType: Class, + ): io.appwrite.models.Account { val path = "/account/phone" + val params = mutableMapOf( "phone" to phone, - "password" to password + "password" to password, ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.Account = { - io.appwrite.models.Account.from(map = it) - } + val converter: (Any) -> io.appwrite.models.Account = { + io.appwrite.models.Account.from(map = it as Map, nestedType) + } return client.call( "PATCH", path, headers, params, - responseType = io.appwrite.models.Account::class.java, + responseType = classOf(), converter, ) } - + + /** + * Update Phone + * + * Update the currently logged in user's phone number. After updating the phone number, the phone verification status will be reset. A confirmation SMS is not sent automatically, however you can use the [POST /account/verification/phone](/docs/client/account#accountCreatePhoneVerification) endpoint to send a confirmation SMS. + * + * @param phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param password User password. Must be at least 8 chars. + * @return [io.appwrite.models.Account] + */ + @Throws(AppwriteException::class) + suspend fun updatePhone( + phone: String, + password: String, + ) = updatePhone( + phone, + password, + nestedType = classOf(), + ) + /** * Get Account Preferences * * Get currently logged in user preferences as a key-value object. * - * @return [io.appwrite.models.Preferences] + * @return [io.appwrite.models.Preferences] */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun getPrefs(): io.appwrite.models.Preferences { + suspend fun getPrefs( + nestedType: Class, + ): io.appwrite.models.Preferences { val path = "/account/prefs" + val params = mutableMapOf( ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.Preferences = { - io.appwrite.models.Preferences.from(map = it) - } + val converter: (Any) -> io.appwrite.models.Preferences = { + io.appwrite.models.Preferences.from(map = it as Map, nestedType) + } return client.call( "GET", path, headers, params, - responseType = io.appwrite.models.Preferences::class.java, + responseType = classOf(), converter, ) } - + /** - * Update Account Preferences + * Get Account Preferences * - * Update currently logged in user account preferences. The object you pass is - * stored as is, and replaces any previous value. The maximum allowed prefs - * size is 64kB and throws error if exceeded. + * Get currently logged in user preferences as a key-value object. * - * @param prefs Prefs key-value JSON object. - * @return [io.appwrite.models.Account] + * @return [io.appwrite.models.Preferences] */ - @JvmOverloads @Throws(AppwriteException::class) - suspend fun updatePrefs( - prefs: Any - ): io.appwrite.models.Account { + suspend fun getPrefs( + ) = getPrefs( + nestedType = classOf(), + ) + + /** + * Update Preferences + * + * Update currently logged in user account preferences. The object you pass is stored as is, and replaces any previous value. The maximum allowed prefs size is 64kB and throws error if exceeded. + * + * @param prefs Prefs key-value JSON object. + * @return [io.appwrite.models.Account] + */ + suspend fun updatePrefs( + prefs: Any, + nestedType: Class, + ): io.appwrite.models.Account { val path = "/account/prefs" + val params = mutableMapOf( - "prefs" to prefs + "prefs" to prefs, ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.Account = { - io.appwrite.models.Account.from(map = it) - } + val converter: (Any) -> io.appwrite.models.Account = { + io.appwrite.models.Account.from(map = it as Map, nestedType) + } return client.call( "PATCH", path, headers, params, - responseType = io.appwrite.models.Account::class.java, + responseType = classOf(), converter, ) } - + + /** + * Update Preferences + * + * Update currently logged in user account preferences. The object you pass is stored as is, and replaces any previous value. The maximum allowed prefs size is 64kB and throws error if exceeded. + * + * @param prefs Prefs key-value JSON object. + * @return [io.appwrite.models.Account] + */ + @Throws(AppwriteException::class) + suspend fun updatePrefs( + prefs: Any, + ) = updatePrefs( + prefs, + nestedType = classOf(), + ) + /** * Create Password Recovery * - * Sends the user an email with a temporary secret key for password reset. - * When the user clicks the confirmation link he is redirected back to your - * app password reset URL with the secret key and email address values - * attached to the URL query string. Use the query string params to submit a - * request to the [PUT - * /account/recovery](/docs/client/account#accountUpdateRecovery) endpoint to - * complete the process. The verification link sent to the user's email - * address is valid for 1 hour. + * Sends the user an email with a temporary secret key for password reset. When the user clicks the confirmation link he is redirected back to your app password reset URL with the secret key and email address values attached to the URL query string. Use the query string params to submit a request to the [PUT /account/recovery](/docs/client/account#accountUpdateRecovery) endpoint to complete the process. The verification link sent to the user's email address is valid for 1 hour. * * @param email User email. * @param url URL to redirect the user back to your app from the recovery email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. - * @return [io.appwrite.models.Token] + * @return [io.appwrite.models.Token] */ - @JvmOverloads - @Throws(AppwriteException::class) suspend fun createRecovery( - email: String, - url: String - ): io.appwrite.models.Token { + email: String, + url: String, + ): io.appwrite.models.Token { val path = "/account/recovery" + val params = mutableMapOf( "email" to email, - "url" to url + "url" to url, ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.Token = { - io.appwrite.models.Token.from(map = it) - } + val converter: (Any) -> io.appwrite.models.Token = { + io.appwrite.models.Token.from(map = it as Map) + } return client.call( "POST", path, @@ -419,47 +537,39 @@ class Account : Service { converter, ) } - + + /** * Create Password Recovery (confirmation) * - * Use this endpoint to complete the user account password reset. Both the - * **userId** and **secret** arguments will be passed as query parameters to - * the redirect URL you have provided when sending your request to the [POST - * /account/recovery](/docs/client/account#accountCreateRecovery) endpoint. - * - * Please note that in order to avoid a [Redirect - * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) - * the only valid redirect URLs are the ones from domains you have set when - * adding your platforms in the console interface. + * Use this endpoint to complete the user account password reset. Both the **userId** and **secret** arguments will be passed as query parameters to the redirect URL you have provided when sending your request to the [POST /account/recovery](/docs/client/account#accountCreateRecovery) endpoint.Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. * * @param userId User ID. * @param secret Valid reset token. * @param password New user password. Must be at least 8 chars. * @param passwordAgain Repeat new user password. Must be at least 8 chars. - * @return [io.appwrite.models.Token] + * @return [io.appwrite.models.Token] */ - @JvmOverloads - @Throws(AppwriteException::class) suspend fun updateRecovery( - userId: String, - secret: String, - password: String, - passwordAgain: String - ): io.appwrite.models.Token { + userId: String, + secret: String, + password: String, + passwordAgain: String, + ): io.appwrite.models.Token { val path = "/account/recovery" + val params = mutableMapOf( "userId" to userId, "secret" to secret, "password" to password, - "passwordAgain" to passwordAgain + "passwordAgain" to passwordAgain, ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.Token = { - io.appwrite.models.Token.from(map = it) - } + val converter: (Any) -> io.appwrite.models.Token = { + io.appwrite.models.Token.from(map = it as Map) + } return client.call( "PUT", path, @@ -469,27 +579,27 @@ class Account : Service { converter, ) } - + + /** - * List Account Sessions + * List Sessions * - * Get currently logged in user list of active sessions across different - * devices. + * Get currently logged in user list of active sessions across different devices. * - * @return [io.appwrite.models.SessionList] + * @return [io.appwrite.models.SessionList] */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun listSessions(): io.appwrite.models.SessionList { + suspend fun listSessions( + ): io.appwrite.models.SessionList { val path = "/account/sessions" + val params = mutableMapOf( ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.SessionList = { - io.appwrite.models.SessionList.from(map = it) - } + val converter: (Any) -> io.appwrite.models.SessionList = { + io.appwrite.models.SessionList.from(map = it as Map) + } return client.call( "GET", path, @@ -499,23 +609,23 @@ class Account : Service { converter, ) } - + + /** - * Delete All Account Sessions + * Delete Sessions * - * Delete all sessions from the user account and remove any sessions cookies - * from the end client. + * Delete all sessions from the user account and remove any sessions cookies from the end client. * - * @return [Any] + * @return [Any] */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun deleteSessions(): Any { + suspend fun deleteSessions( + ): Any { val path = "/account/sessions" + val params = mutableMapOf( ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) return client.call( "DELETE", @@ -525,31 +635,27 @@ class Account : Service { responseType = Any::class.java, ) } - + + /** * Create Anonymous Session * - * Use this endpoint to allow a new user to register an anonymous account in - * your project. This route will also create a new session for the user. To - * allow the new user to convert an anonymous account to a normal account, you - * need to update its [email and - * password](/docs/client/account#accountUpdateEmail) or create an [OAuth2 - * session](/docs/client/account#accountCreateOAuth2Session). + * Use this endpoint to allow a new user to register an anonymous account in your project. This route will also create a new session for the user. To allow the new user to convert an anonymous account to a normal account, you need to update its [email and password](/docs/client/account#accountUpdateEmail) or create an [OAuth2 session](/docs/client/account#accountCreateOAuth2Session). * - * @return [io.appwrite.models.Session] + * @return [io.appwrite.models.Session] */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun createAnonymousSession(): io.appwrite.models.Session { + suspend fun createAnonymousSession( + ): io.appwrite.models.Session { val path = "/account/sessions/anonymous" + val params = mutableMapOf( ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.Session = { - io.appwrite.models.Session.from(map = it) - } + val converter: (Any) -> io.appwrite.models.Session = { + io.appwrite.models.Session.from(map = it as Map) + } return client.call( "POST", path, @@ -559,34 +665,33 @@ class Account : Service { converter, ) } - + + /** - * Create Account Session with Email + * Create Email Session * - * Allow the user to login into their account by providing a valid email and - * password combination. This route will create a new session for the user. + * Allow the user to login into their account by providing a valid email and password combination. This route will create a new session for the user.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](/docs/authentication#limits). * * @param email User email. * @param password User password. Must be at least 8 chars. - * @return [io.appwrite.models.Session] + * @return [io.appwrite.models.Session] */ - @JvmOverloads - @Throws(AppwriteException::class) suspend fun createEmailSession( - email: String, - password: String - ): io.appwrite.models.Session { + email: String, + password: String, + ): io.appwrite.models.Session { val path = "/account/sessions/email" + val params = mutableMapOf( "email" to email, - "password" to password + "password" to password, ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.Session = { - io.appwrite.models.Session.from(map = it) - } + val converter: (Any) -> io.appwrite.models.Session = { + io.appwrite.models.Session.from(map = it as Map) + } return client.call( "POST", path, @@ -596,46 +701,37 @@ class Account : Service { converter, ) } - + + /** * Create Magic URL session * - * Sends the user an email with a secret key for creating a session. If the - * provided user ID has not be registered, a new user will be created. When - * the user clicks the link in the email, the user is redirected back to the - * URL you provided with the secret key and userId values attached to the URL - * query string. Use the query string parameters to submit a request to the - * [PUT - * /account/sessions/magic-url](/docs/client/account#accountUpdateMagicURLSession) - * endpoint to complete the login process. The link sent to the user's email - * address is valid for 1 hour. If you are on a mobile device you can leave - * the URL parameter empty, so that the login completion will be handled by - * your Appwrite instance by default. - * - * @param userId Unique Id. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * Sends the user an email with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [PUT /account/sessions/magic-url](/docs/client/account#accountUpdateMagicURLSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour. If you are on a mobile device you can leave the URL parameter empty, so that the login completion will be handled by your Appwrite instance by default.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](/docs/authentication#limits). + * + * @param userId Unique Id. Choose your own unique ID or pass the string `ID.unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param email User email. * @param url URL to redirect the user back to your app from the magic URL login. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. - * @return [io.appwrite.models.Token] + * @return [io.appwrite.models.Token] */ @JvmOverloads - @Throws(AppwriteException::class) suspend fun createMagicURLSession( - userId: String, - email: String, - url: String? = null - ): io.appwrite.models.Token { + userId: String, + email: String, + url: String? = null, + ): io.appwrite.models.Token { val path = "/account/sessions/magic-url" + val params = mutableMapOf( "userId" to userId, "email" to email, - "url" to url + "url" to url, ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.Token = { - io.appwrite.models.Token.from(map = it) - } + val converter: (Any) -> io.appwrite.models.Token = { + io.appwrite.models.Token.from(map = it as Map) + } return client.call( "POST", path, @@ -645,43 +741,33 @@ class Account : Service { converter, ) } - + + /** * Create Magic URL session (confirmation) * - * Use this endpoint to complete creating the session with the Magic URL. Both - * the **userId** and **secret** arguments will be passed as query parameters - * to the redirect URL you have provided when sending your request to the - * [POST - * /account/sessions/magic-url](/docs/client/account#accountCreateMagicURLSession) - * endpoint. - * - * Please note that in order to avoid a [Redirect - * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) - * the only valid redirect URLs are the ones from domains you have set when - * adding your platforms in the console interface. + * Use this endpoint to complete creating the session with the Magic URL. Both the **userId** and **secret** arguments will be passed as query parameters to the redirect URL you have provided when sending your request to the [POST /account/sessions/magic-url](/docs/client/account#accountCreateMagicURLSession) endpoint.Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. * * @param userId User ID. * @param secret Valid verification token. - * @return [io.appwrite.models.Session] + * @return [io.appwrite.models.Session] */ - @JvmOverloads - @Throws(AppwriteException::class) suspend fun updateMagicURLSession( - userId: String, - secret: String - ): io.appwrite.models.Session { + userId: String, + secret: String, + ): io.appwrite.models.Session { val path = "/account/sessions/magic-url" + val params = mutableMapOf( "userId" to userId, - "secret" to secret + "secret" to secret, ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.Session = { - io.appwrite.models.Session.from(map = it) - } + val converter: (Any) -> io.appwrite.models.Session = { + io.appwrite.models.Session.from(map = it as Map) + } return client.call( "PUT", path, @@ -691,44 +777,33 @@ class Account : Service { converter, ) } - + + /** - * Create Account Session with OAuth2 - * - * Allow the user to login to their account using the OAuth2 provider of their - * choice. Each OAuth2 provider should be enabled from the Appwrite console - * first. Use the success and failure arguments to provide a redirect URL's - * back to your app when login is completed. - * - * If there is already an active session, the new session will be attached to - * the logged-in account. If there are no active sessions, the server will - * attempt to look for a user with the same email address as the email - * received from the OAuth2 provider and attach the new session to the - * existing user. If no matching user is found - the server will create a new - * user.. - * + * Create OAuth2 Session + * + * Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL's back to your app when login is completed.If there is already an active session, the new session will be attached to the logged-in account. If there are no active sessions, the server will attempt to look for a user with the same email address as the email received from the OAuth2 provider and attach the new session to the existing user. If no matching user is found - the server will create a new user.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](/docs/authentication#limits). * * @param provider OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, github, gitlab, google, linkedin, microsoft, notion, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoom. * @param success URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param failure URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param scopes A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long. - * */ @JvmOverloads - @Throws(AppwriteException::class) suspend fun createOAuth2Session( - activity: ComponentActivity, - provider: String, - success: String? = null, - failure: String? = null, - scopes: List? = null - ) { - val path = "/account/sessions/oauth2/{provider}".replace("{provider}", provider) + activity: ComponentActivity, + provider: String, + success: String? = null, + failure: String? = null, + scopes: List? = null, + ) { + val path = "/account/sessions/oauth2/{provider}" + .replace("{provider}", provider) + val params = mutableMapOf( "success" to success, "failure" to failure, "scopes" to scopes, - "project" to client.config["project"] ) val query = mutableListOf() params.forEach { @@ -773,38 +848,33 @@ class Account : Service { ) } } - + + /** * Create Phone session * - * Sends the user an SMS with a secret key for creating a session. If the - * provided user ID has not be registered, a new user will be created. Use the - * returned user ID and secret and submit a request to the [PUT - * /account/sessions/phone](/docs/client/account#accountUpdatePhoneSession) - * endpoint to complete the login process. The secret sent to the user's phone - * is valid for 15 minutes. + * Sends the user an SMS with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [PUT /account/sessions/phone](/docs/client/account#accountUpdatePhoneSession) endpoint to complete the login process. The secret sent to the user's phone is valid for 15 minutes.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](/docs/authentication#limits). * - * @param userId Unique Id. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param userId Unique Id. Choose your own unique ID or pass the string `ID.unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. - * @return [io.appwrite.models.Token] + * @return [io.appwrite.models.Token] */ - @JvmOverloads - @Throws(AppwriteException::class) suspend fun createPhoneSession( - userId: String, - phone: String - ): io.appwrite.models.Token { + userId: String, + phone: String, + ): io.appwrite.models.Token { val path = "/account/sessions/phone" + val params = mutableMapOf( "userId" to userId, - "phone" to phone + "phone" to phone, ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.Token = { - io.appwrite.models.Token.from(map = it) - } + val converter: (Any) -> io.appwrite.models.Token = { + io.appwrite.models.Token.from(map = it as Map) + } return client.call( "POST", path, @@ -814,37 +884,33 @@ class Account : Service { converter, ) } - + + /** * Create Phone Session (confirmation) * - * Use this endpoint to complete creating a session with SMS. Use the - * **userId** from the - * [createPhoneSession](/docs/client/account#accountCreatePhoneSession) - * endpoint and the **secret** received via SMS to successfully update and - * confirm the phone session. + * Use this endpoint to complete creating a session with SMS. Use the **userId** from the [createPhoneSession](/docs/client/account#accountCreatePhoneSession) endpoint and the **secret** received via SMS to successfully update and confirm the phone session. * * @param userId User ID. * @param secret Valid verification token. - * @return [io.appwrite.models.Session] + * @return [io.appwrite.models.Session] */ - @JvmOverloads - @Throws(AppwriteException::class) suspend fun updatePhoneSession( - userId: String, - secret: String - ): io.appwrite.models.Session { + userId: String, + secret: String, + ): io.appwrite.models.Session { val path = "/account/sessions/phone" + val params = mutableMapOf( "userId" to userId, - "secret" to secret + "secret" to secret, ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.Session = { - io.appwrite.models.Session.from(map = it) - } + val converter: (Any) -> io.appwrite.models.Session = { + io.appwrite.models.Session.from(map = it as Map) + } return client.call( "PUT", path, @@ -854,30 +920,30 @@ class Account : Service { converter, ) } - + + /** - * Get Session By ID + * Get Session * - * Use this endpoint to get a logged in user's session using a Session ID. - * Inputting 'current' will return the current session being used. + * Use this endpoint to get a logged in user's session using a Session ID. Inputting 'current' will return the current session being used. * * @param sessionId Session ID. Use the string 'current' to get the current device session. - * @return [io.appwrite.models.Session] + * @return [io.appwrite.models.Session] */ - @JvmOverloads - @Throws(AppwriteException::class) suspend fun getSession( - sessionId: String - ): io.appwrite.models.Session { - val path = "/account/sessions/{sessionId}".replace("{sessionId}", sessionId) + sessionId: String, + ): io.appwrite.models.Session { + val path = "/account/sessions/{sessionId}" + .replace("{sessionId}", sessionId) + val params = mutableMapOf( ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.Session = { - io.appwrite.models.Session.from(map = it) - } + val converter: (Any) -> io.appwrite.models.Session = { + io.appwrite.models.Session.from(map = it as Map) + } return client.call( "GET", path, @@ -887,31 +953,30 @@ class Account : Service { converter, ) } - + + /** - * Update Session (Refresh Tokens) + * Update OAuth Session (Refresh Tokens) * - * Access tokens have limited lifespan and expire to mitigate security risks. - * If session was created using an OAuth provider, this route can be used to - * "refresh" the access token. + * Access tokens have limited lifespan and expire to mitigate security risks. If session was created using an OAuth provider, this route can be used to "refresh" the access token. * * @param sessionId Session ID. Use the string 'current' to update the current device session. - * @return [io.appwrite.models.Session] + * @return [io.appwrite.models.Session] */ - @JvmOverloads - @Throws(AppwriteException::class) suspend fun updateSession( - sessionId: String - ): io.appwrite.models.Session { - val path = "/account/sessions/{sessionId}".replace("{sessionId}", sessionId) + sessionId: String, + ): io.appwrite.models.Session { + val path = "/account/sessions/{sessionId}" + .replace("{sessionId}", sessionId) + val params = mutableMapOf( ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.Session = { - io.appwrite.models.Session.from(map = it) - } + val converter: (Any) -> io.appwrite.models.Session = { + io.appwrite.models.Session.from(map = it as Map) + } return client.call( "PATCH", path, @@ -921,28 +986,26 @@ class Account : Service { converter, ) } - + + /** - * Delete Account Session + * Delete Session * - * Use this endpoint to log out the currently logged in user from all their - * account sessions across all of their different devices. When using the - * Session ID argument, only the unique session ID provided is deleted. - * + * Use this endpoint to log out the currently logged in user from all their account sessions across all of their different devices. When using the Session ID argument, only the unique session ID provided is deleted. * * @param sessionId Session ID. Use the string 'current' to delete the current device session. - * @return [Any] + * @return [Any] */ - @JvmOverloads - @Throws(AppwriteException::class) suspend fun deleteSession( - sessionId: String - ): Any { - val path = "/account/sessions/{sessionId}".replace("{sessionId}", sessionId) + sessionId: String, + ): Any { + val path = "/account/sessions/{sessionId}" + .replace("{sessionId}", sessionId) + val params = mutableMapOf( ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) return client.call( "DELETE", @@ -952,75 +1015,73 @@ class Account : Service { responseType = Any::class.java, ) } - + + /** - * Update Account Status + * Update Status * - * Block the currently logged in user account. Behind the scene, the user - * record is not deleted but permanently blocked from any access. To - * completely delete a user, use the Users API instead. + * Block the currently logged in user account. Behind the scene, the user record is not deleted but permanently blocked from any access. To completely delete a user, use the Users API instead. * - * @return [io.appwrite.models.Account] + * @return [io.appwrite.models.Account] */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun updateStatus(): io.appwrite.models.Account { + suspend fun updateStatus( + nestedType: Class, + ): io.appwrite.models.Account { val path = "/account/status" + val params = mutableMapOf( ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.Account = { - io.appwrite.models.Account.from(map = it) - } + val converter: (Any) -> io.appwrite.models.Account = { + io.appwrite.models.Account.from(map = it as Map, nestedType) + } return client.call( "PATCH", path, headers, params, - responseType = io.appwrite.models.Account::class.java, + responseType = classOf(), converter, ) } - + + /** + * Update Status + * + * Block the currently logged in user account. Behind the scene, the user record is not deleted but permanently blocked from any access. To completely delete a user, use the Users API instead. + * + * @return [io.appwrite.models.Account] + */ + @Throws(AppwriteException::class) + suspend fun updateStatus( + ) = updateStatus( + nestedType = classOf(), + ) + /** * Create Email Verification * - * Use this endpoint to send a verification message to your user email address - * to confirm they are the valid owners of that address. Both the **userId** - * and **secret** arguments will be passed as query parameters to the URL you - * have provided to be attached to the verification email. The provided URL - * should redirect the user back to your app and allow you to complete the - * verification process by verifying both the **userId** and **secret** - * parameters. Learn more about how to [complete the verification - * process](/docs/client/account#accountUpdateEmailVerification). The - * verification link sent to the user's email address is valid for 7 days. - * - * Please note that in order to avoid a [Redirect - * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), - * the only valid redirect URLs are the ones from domains you have set when - * adding your platforms in the console interface. - * + * Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](/docs/client/account#accountUpdateEmailVerification). The verification link sent to the user's email address is valid for 7 days.Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. * * @param url URL to redirect the user back to your app from the verification email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. - * @return [io.appwrite.models.Token] + * @return [io.appwrite.models.Token] */ - @JvmOverloads - @Throws(AppwriteException::class) suspend fun createVerification( - url: String - ): io.appwrite.models.Token { + url: String, + ): io.appwrite.models.Token { val path = "/account/verification" + val params = mutableMapOf( - "url" to url + "url" to url, ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.Token = { - io.appwrite.models.Token.from(map = it) - } + val converter: (Any) -> io.appwrite.models.Token = { + io.appwrite.models.Token.from(map = it as Map) + } return client.call( "POST", path, @@ -1030,36 +1091,33 @@ class Account : Service { converter, ) } - + + /** * Create Email Verification (confirmation) * - * Use this endpoint to complete the user email verification process. Use both - * the **userId** and **secret** parameters that were attached to your app URL - * to verify the user email ownership. If confirmed this route will return a - * 200 status code. + * Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code. * * @param userId User ID. * @param secret Valid verification token. - * @return [io.appwrite.models.Token] + * @return [io.appwrite.models.Token] */ - @JvmOverloads - @Throws(AppwriteException::class) suspend fun updateVerification( - userId: String, - secret: String - ): io.appwrite.models.Token { + userId: String, + secret: String, + ): io.appwrite.models.Token { val path = "/account/verification" + val params = mutableMapOf( "userId" to userId, - "secret" to secret + "secret" to secret, ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.Token = { - io.appwrite.models.Token.from(map = it) - } + val converter: (Any) -> io.appwrite.models.Token = { + io.appwrite.models.Token.from(map = it as Map) + } return client.call( "PUT", path, @@ -1069,31 +1127,27 @@ class Account : Service { converter, ) } - + + /** * Create Phone Verification * - * Use this endpoint to send a verification SMS to the currently logged in - * user. This endpoint is meant for use after updating a user's phone number - * using the [accountUpdatePhone](/docs/client/account#accountUpdatePhone) - * endpoint. Learn more about how to [complete the verification - * process](/docs/client/account#accountUpdatePhoneVerification). The - * verification code sent to the user's phone number is valid for 15 minutes. + * Use this endpoint to send a verification SMS to the currently logged in user. This endpoint is meant for use after updating a user's phone number using the [accountUpdatePhone](/docs/client/account#accountUpdatePhone) endpoint. Learn more about how to [complete the verification process](/docs/client/account#accountUpdatePhoneVerification). The verification code sent to the user's phone number is valid for 15 minutes. * - * @return [io.appwrite.models.Token] + * @return [io.appwrite.models.Token] */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun createPhoneVerification(): io.appwrite.models.Token { + suspend fun createPhoneVerification( + ): io.appwrite.models.Token { val path = "/account/verification/phone" + val params = mutableMapOf( ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.Token = { - io.appwrite.models.Token.from(map = it) - } + val converter: (Any) -> io.appwrite.models.Token = { + io.appwrite.models.Token.from(map = it as Map) + } return client.call( "POST", path, @@ -1103,36 +1157,33 @@ class Account : Service { converter, ) } - + + /** * Create Phone Verification (confirmation) * - * Use this endpoint to complete the user phone verification process. Use the - * **userId** and **secret** that were sent to your user's phone number to - * verify the user email ownership. If confirmed this route will return a 200 - * status code. + * Use this endpoint to complete the user phone verification process. Use the **userId** and **secret** that were sent to your user's phone number to verify the user email ownership. If confirmed this route will return a 200 status code. * * @param userId User ID. * @param secret Valid verification token. - * @return [io.appwrite.models.Token] + * @return [io.appwrite.models.Token] */ - @JvmOverloads - @Throws(AppwriteException::class) suspend fun updatePhoneVerification( - userId: String, - secret: String - ): io.appwrite.models.Token { + userId: String, + secret: String, + ): io.appwrite.models.Token { val path = "/account/verification/phone" + val params = mutableMapOf( "userId" to userId, - "secret" to secret + "secret" to secret, ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.Token = { - io.appwrite.models.Token.from(map = it) - } + val converter: (Any) -> io.appwrite.models.Token = { + io.appwrite.models.Token.from(map = it as Map) + } return client.call( "PUT", path, @@ -1142,5 +1193,6 @@ class Account : Service { converter, ) } - + + } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/services/Avatars.kt b/library/src/main/java/io/appwrite/services/Avatars.kt index 2853e59..74980b9 100644 --- a/library/src/main/java/io/appwrite/services/Avatars.kt +++ b/library/src/main/java/io/appwrite/services/Avatars.kt @@ -4,12 +4,15 @@ import android.net.Uri import io.appwrite.Client import io.appwrite.models.* import io.appwrite.exceptions.AppwriteException +import io.appwrite.extensions.classOf import okhttp3.Cookie -import okhttp3.Response import okhttp3.HttpUrl import okhttp3.HttpUrl.Companion.toHttpUrl import java.io.File +/** + * The Avatars service aims to help you complete everyday tasks related to your app image, icons, and avatars. +**/ class Avatars : Service { public constructor (client: Client) : super(client) { } @@ -17,36 +20,28 @@ class Avatars : Service { /** * Get Browser Icon * - * You can use this endpoint to show different browser icons to your users. - * The code argument receives the browser code as it appears in your user [GET - * /account/sessions](/docs/client/account#accountGetSessions) endpoint. Use - * width, height and quality arguments to change the output settings. - * - * When one dimension is specified and the other is 0, the image is scaled - * with preserved aspect ratio. If both dimensions are 0, the API provides an - * image at source quality. If dimensions are not specified, the default size - * of image returned is 100x100px. + * You can use this endpoint to show different browser icons to your users. The code argument receives the browser code as it appears in your user [GET /account/sessions](/docs/client/account#accountGetSessions) endpoint. Use width, height and quality arguments to change the output settings.When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. * * @param code Browser Code. * @param width Image width. Pass an integer between 0 to 2000. Defaults to 100. * @param height Image height. Pass an integer between 0 to 2000. Defaults to 100. * @param quality Image quality. Pass an integer between 0 to 100. Defaults to 100. - * @return [ByteArray] + * @return [ByteArray] */ @JvmOverloads - @Throws(AppwriteException::class) suspend fun getBrowser( - code: String, - width: Long? = null, - height: Long? = null, - quality: Long? = null - ): ByteArray { - val path = "/avatars/browsers/{code}".replace("{code}", code) + code: String, + width: Long? = null, + height: Long? = null, + quality: Long? = null, + ): ByteArray { + val path = "/avatars/browsers/{code}" + .replace("{code}", code) + val params = mutableMapOf( "width" to width, "height" to height, "quality" to quality, - "project" to client.config["project"] ) return client.call( "GET", @@ -55,40 +50,33 @@ class Avatars : Service { responseType = ByteArray::class.java ) } - + + /** * Get Credit Card Icon * - * The credit card endpoint will return you the icon of the credit card - * provider you need. Use width, height and quality arguments to change the - * output settings. - * - * When one dimension is specified and the other is 0, the image is scaled - * with preserved aspect ratio. If both dimensions are 0, the API provides an - * image at source quality. If dimensions are not specified, the default size - * of image returned is 100x100px. - * + * The credit card endpoint will return you the icon of the credit card provider you need. Use width, height and quality arguments to change the output settings.When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. * * @param code Credit Card Code. Possible values: amex, argencard, cabal, censosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa, mir, maestro. * @param width Image width. Pass an integer between 0 to 2000. Defaults to 100. * @param height Image height. Pass an integer between 0 to 2000. Defaults to 100. * @param quality Image quality. Pass an integer between 0 to 100. Defaults to 100. - * @return [ByteArray] + * @return [ByteArray] */ @JvmOverloads - @Throws(AppwriteException::class) suspend fun getCreditCard( - code: String, - width: Long? = null, - height: Long? = null, - quality: Long? = null - ): ByteArray { - val path = "/avatars/credit-cards/{code}".replace("{code}", code) + code: String, + width: Long? = null, + height: Long? = null, + quality: Long? = null, + ): ByteArray { + val path = "/avatars/credit-cards/{code}" + .replace("{code}", code) + val params = mutableMapOf( "width" to width, "height" to height, "quality" to quality, - "project" to client.config["project"] ) return client.call( "GET", @@ -97,26 +85,23 @@ class Avatars : Service { responseType = ByteArray::class.java ) } - + + /** * Get Favicon * - * Use this endpoint to fetch the favorite icon (AKA favicon) of any remote - * website URL. - * + * Use this endpoint to fetch the favorite icon (AKA favicon) of any remote website URL. * * @param url Website URL which you want to fetch the favicon from. - * @return [ByteArray] + * @return [ByteArray] */ - @JvmOverloads - @Throws(AppwriteException::class) suspend fun getFavicon( - url: String - ): ByteArray { + url: String, + ): ByteArray { val path = "/avatars/favicon" + val params = mutableMapOf( "url" to url, - "project" to client.config["project"] ) return client.call( "GET", @@ -125,41 +110,33 @@ class Avatars : Service { responseType = ByteArray::class.java ) } - + + /** * Get Country Flag * - * You can use this endpoint to show different country flags icons to your - * users. The code argument receives the 2 letter country code. Use width, - * height and quality arguments to change the output settings. Country codes - * follow the [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) standard. - * - * When one dimension is specified and the other is 0, the image is scaled - * with preserved aspect ratio. If both dimensions are 0, the API provides an - * image at source quality. If dimensions are not specified, the default size - * of image returned is 100x100px. - * + * You can use this endpoint to show different country flags icons to your users. The code argument receives the 2 letter country code. Use width, height and quality arguments to change the output settings. Country codes follow the [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) standard.When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. * * @param code Country Code. ISO Alpha-2 country code format. * @param width Image width. Pass an integer between 0 to 2000. Defaults to 100. * @param height Image height. Pass an integer between 0 to 2000. Defaults to 100. * @param quality Image quality. Pass an integer between 0 to 100. Defaults to 100. - * @return [ByteArray] + * @return [ByteArray] */ @JvmOverloads - @Throws(AppwriteException::class) suspend fun getFlag( - code: String, - width: Long? = null, - height: Long? = null, - quality: Long? = null - ): ByteArray { - val path = "/avatars/flags/{code}".replace("{code}", code) + code: String, + width: Long? = null, + height: Long? = null, + quality: Long? = null, + ): ByteArray { + val path = "/avatars/flags/{code}" + .replace("{code}", code) + val params = mutableMapOf( "width" to width, "height" to height, "quality" to quality, - "project" to client.config["project"] ) return client.call( "GET", @@ -168,39 +145,30 @@ class Avatars : Service { responseType = ByteArray::class.java ) } - + + /** * Get Image from URL * - * Use this endpoint to fetch a remote image URL and crop it to any image size - * you want. This endpoint is very useful if you need to crop and display - * remote images in your app or in case you want to make sure a 3rd party - * image is properly served using a TLS protocol. - * - * When one dimension is specified and the other is 0, the image is scaled - * with preserved aspect ratio. If both dimensions are 0, the API provides an - * image at source quality. If dimensions are not specified, the default size - * of image returned is 400x400px. - * + * Use this endpoint to fetch a remote image URL and crop it to any image size you want. This endpoint is very useful if you need to crop and display remote images in your app or in case you want to make sure a 3rd party image is properly served using a TLS protocol.When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 400x400px. * * @param url Image URL which you want to crop. * @param width Resize preview image width, Pass an integer between 0 to 2000. Defaults to 400. * @param height Resize preview image height, Pass an integer between 0 to 2000. Defaults to 400. - * @return [ByteArray] + * @return [ByteArray] */ @JvmOverloads - @Throws(AppwriteException::class) suspend fun getImage( - url: String, - width: Long? = null, - height: Long? = null - ): ByteArray { + url: String, + width: Long? = null, + height: Long? = null, + ): ByteArray { val path = "/avatars/image" + val params = mutableMapOf( "url" to url, "width" to width, "height" to height, - "project" to client.config["project"] ) return client.call( "GET", @@ -209,48 +177,33 @@ class Avatars : Service { responseType = ByteArray::class.java ) } - + + /** * Get User Initials * - * Use this endpoint to show your user initials avatar icon on your website or - * app. By default, this route will try to print your logged-in user name or - * email initials. You can also overwrite the user name if you pass the 'name' - * parameter. If no name is given and no user is logged, an empty avatar will - * be returned. - * - * You can use the color and background params to change the avatar colors. By - * default, a random theme will be selected. The random theme will persist for - * the user's initials when reloading the same theme will always return for - * the same initials. - * - * When one dimension is specified and the other is 0, the image is scaled - * with preserved aspect ratio. If both dimensions are 0, the API provides an - * image at source quality. If dimensions are not specified, the default size - * of image returned is 100x100px. - * + * Use this endpoint to show your user initials avatar icon on your website or app. By default, this route will try to print your logged-in user name or email initials. You can also overwrite the user name if you pass the 'name' parameter. If no name is given and no user is logged, an empty avatar will be returned.You can use the color and background params to change the avatar colors. By default, a random theme will be selected. The random theme will persist for the user's initials when reloading the same theme will always return for the same initials.When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. * * @param name Full Name. When empty, current user name or email will be used. Max length: 128 chars. * @param width Image width. Pass an integer between 0 to 2000. Defaults to 100. * @param height Image height. Pass an integer between 0 to 2000. Defaults to 100. * @param background Changes background color. By default a random color will be picked and stay will persistent to the given name. - * @return [ByteArray] + * @return [ByteArray] */ @JvmOverloads - @Throws(AppwriteException::class) suspend fun getInitials( - name: String? = null, - width: Long? = null, - height: Long? = null, - background: String? = null - ): ByteArray { + name: String? = null, + width: Long? = null, + height: Long? = null, + background: String? = null, + ): ByteArray { val path = "/avatars/initials" + val params = mutableMapOf( "name" to name, "width" to width, "height" to height, "background" to background, - "project" to client.config["project"] ) return client.call( "GET", @@ -259,35 +212,33 @@ class Avatars : Service { responseType = ByteArray::class.java ) } - + + /** * Get QR Code * - * Converts a given plain text to a QR code image. You can use the query - * parameters to change the size and style of the resulting image. - * + * Converts a given plain text to a QR code image. You can use the query parameters to change the size and style of the resulting image. * * @param text Plain text to be converted to QR code image. * @param size QR code size. Pass an integer between 1 to 1000. Defaults to 400. * @param margin Margin from edge. Pass an integer between 0 to 10. Defaults to 1. * @param download Return resulting image with 'Content-Disposition: attachment ' headers for the browser to start downloading it. Pass 0 for no header, or 1 for otherwise. Default value is set to 0. - * @return [ByteArray] + * @return [ByteArray] */ @JvmOverloads - @Throws(AppwriteException::class) suspend fun getQR( - text: String, - size: Long? = null, - margin: Long? = null, - download: Boolean? = null - ): ByteArray { + text: String, + size: Long? = null, + margin: Long? = null, + download: Boolean? = null, + ): ByteArray { val path = "/avatars/qr" + val params = mutableMapOf( "text" to text, "size" to size, "margin" to margin, "download" to download, - "project" to client.config["project"] ) return client.call( "GET", @@ -296,5 +247,6 @@ class Avatars : Service { responseType = ByteArray::class.java ) } - + + } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/services/Databases.kt b/library/src/main/java/io/appwrite/services/Databases.kt index 350ec05..45d6864 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -4,10 +4,13 @@ import android.net.Uri import io.appwrite.Client import io.appwrite.models.* import io.appwrite.exceptions.AppwriteException +import io.appwrite.extensions.classOf import okhttp3.Cookie -import okhttp3.Response import java.io.File +/** + * The Databases service allows you to create structured collections of documents, query and filter lists of documents +**/ class Databases : Service { public constructor (client: Client) : super(client) { } @@ -15,169 +18,277 @@ class Databases : Service { /** * List Documents * - * Get a list of all the user's documents in a given collection. You can use - * the query params to filter your results. On admin mode, this endpoint will - * return a list of all of documents belonging to the provided collectionId. - * [Learn more about different API modes](/docs/admin). + * Get a list of all the user's documents in a given collection. You can use the query params to filter your results. * * @param databaseId Database ID. * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. - * @return [io.appwrite.models.DocumentList] + * @return [io.appwrite.models.DocumentList] */ @JvmOverloads - @Throws(AppwriteException::class) - suspend fun listDocuments( - databaseId: String, - collectionId: String, - queries: List? = null - ): io.appwrite.models.DocumentList { - val path = "/databases/{databaseId}/collections/{collectionId}/documents".replace("{databaseId}", databaseId).replace("{collectionId}", collectionId) + suspend fun listDocuments( + databaseId: String, + collectionId: String, + queries: List? = null, + nestedType: Class, + ): io.appwrite.models.DocumentList { + val path = "/databases/{databaseId}/collections/{collectionId}/documents" + .replace("{databaseId}", databaseId) + .replace("{collectionId}", collectionId) + val params = mutableMapOf( - "queries" to queries + "queries" to queries, ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.DocumentList = { - io.appwrite.models.DocumentList.from(map = it) - } + val converter: (Any) -> io.appwrite.models.DocumentList = { + io.appwrite.models.DocumentList.from(map = it as Map, nestedType) + } return client.call( "GET", path, headers, params, - responseType = io.appwrite.models.DocumentList::class.java, + responseType = classOf(), converter, ) } - + + /** + * List Documents + * + * Get a list of all the user's documents in a given collection. You can use the query params to filter your results. + * + * @param databaseId Database ID. + * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. + * @return [io.appwrite.models.DocumentList] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun listDocuments( + databaseId: String, + collectionId: String, + queries: List? = null, + ) = listDocuments( + databaseId, + collectionId, + queries, + nestedType = classOf(), + ) + /** * Create Document * - * Create a new Document. Before using this route, you should create a new - * collection resource using either a [server - * integration](/docs/server/databases#databasesCreateCollection) API or - * directly from your database console. + * Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](/docs/server/databases#databasesCreateCollection) API or directly from your database console. * * @param databaseId Database ID. * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. - * @param documentId Document ID. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param documentId Document ID. Choose your own unique ID or pass the string `ID.unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param data Document data as JSON object. * @param permissions An array of permissions strings. By default the current user is granted with all permissions. [Learn more about permissions](/docs/permissions). - * @return [io.appwrite.models.Document] + * @return [io.appwrite.models.Document] */ @JvmOverloads - @Throws(AppwriteException::class) - suspend fun createDocument( - databaseId: String, - collectionId: String, - documentId: String, - data: Any, - permissions: List? = null - ): io.appwrite.models.Document { - val path = "/databases/{databaseId}/collections/{collectionId}/documents".replace("{databaseId}", databaseId).replace("{collectionId}", collectionId) + suspend fun createDocument( + databaseId: String, + collectionId: String, + documentId: String, + data: Any, + permissions: List? = null, + nestedType: Class, + ): io.appwrite.models.Document { + val path = "/databases/{databaseId}/collections/{collectionId}/documents" + .replace("{databaseId}", databaseId) + .replace("{collectionId}", collectionId) + val params = mutableMapOf( "documentId" to documentId, "data" to data, - "permissions" to permissions + "permissions" to permissions, ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.Document = { - io.appwrite.models.Document.from(map = it) - } + val converter: (Any) -> io.appwrite.models.Document = { + io.appwrite.models.Document.from(map = it as Map, nestedType) + } return client.call( "POST", path, headers, params, - responseType = io.appwrite.models.Document::class.java, + responseType = classOf(), converter, ) } - + + /** + * Create Document + * + * Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](/docs/server/databases#databasesCreateCollection) API or directly from your database console. + * + * @param databaseId Database ID. + * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. + * @param documentId Document ID. Choose your own unique ID or pass the string `ID.unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param data Document data as JSON object. + * @param permissions An array of permissions strings. By default the current user is granted with all permissions. [Learn more about permissions](/docs/permissions). + * @return [io.appwrite.models.Document] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun createDocument( + databaseId: String, + collectionId: String, + documentId: String, + data: Any, + permissions: List? = null, + ) = createDocument( + databaseId, + collectionId, + documentId, + data, + permissions, + nestedType = classOf(), + ) + /** * Get Document * - * Get a document by its unique ID. This endpoint response returns a JSON - * object with the document data. + * Get a document by its unique ID. This endpoint response returns a JSON object with the document data. * * @param databaseId Database ID. * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). * @param documentId Document ID. - * @return [io.appwrite.models.Document] + * @return [io.appwrite.models.Document] */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun getDocument( - databaseId: String, - collectionId: String, - documentId: String - ): io.appwrite.models.Document { - val path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}".replace("{databaseId}", databaseId).replace("{collectionId}", collectionId).replace("{documentId}", documentId) + suspend fun getDocument( + databaseId: String, + collectionId: String, + documentId: String, + nestedType: Class, + ): io.appwrite.models.Document { + val path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" + .replace("{databaseId}", databaseId) + .replace("{collectionId}", collectionId) + .replace("{documentId}", documentId) + val params = mutableMapOf( ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.Document = { - io.appwrite.models.Document.from(map = it) - } + val converter: (Any) -> io.appwrite.models.Document = { + io.appwrite.models.Document.from(map = it as Map, nestedType) + } return client.call( "GET", path, headers, params, - responseType = io.appwrite.models.Document::class.java, + responseType = classOf(), converter, ) } - + + /** + * Get Document + * + * Get a document by its unique ID. This endpoint response returns a JSON object with the document data. + * + * @param databaseId Database ID. + * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param documentId Document ID. + * @return [io.appwrite.models.Document] + */ + @Throws(AppwriteException::class) + suspend fun getDocument( + databaseId: String, + collectionId: String, + documentId: String, + ) = getDocument( + databaseId, + collectionId, + documentId, + nestedType = classOf(), + ) + /** * Update Document * - * Update a document by its unique ID. Using the patch method you can pass - * only specific fields that will get updated. + * Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated. * * @param databaseId Database ID. * @param collectionId Collection ID. * @param documentId Document ID. * @param data Document data as JSON object. Include only attribute and value pairs to be updated. * @param permissions An array of permissions strings. By default the current permissions are inherited. [Learn more about permissions](/docs/permissions). - * @return [io.appwrite.models.Document] + * @return [io.appwrite.models.Document] */ @JvmOverloads - @Throws(AppwriteException::class) - suspend fun updateDocument( - databaseId: String, - collectionId: String, - documentId: String, - data: Any? = null, - permissions: List? = null - ): io.appwrite.models.Document { - val path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}".replace("{databaseId}", databaseId).replace("{collectionId}", collectionId).replace("{documentId}", documentId) + suspend fun updateDocument( + databaseId: String, + collectionId: String, + documentId: String, + data: Any? = null, + permissions: List? = null, + nestedType: Class, + ): io.appwrite.models.Document { + val path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" + .replace("{databaseId}", databaseId) + .replace("{collectionId}", collectionId) + .replace("{documentId}", documentId) + val params = mutableMapOf( "data" to data, - "permissions" to permissions + "permissions" to permissions, ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.Document = { - io.appwrite.models.Document.from(map = it) - } + val converter: (Any) -> io.appwrite.models.Document = { + io.appwrite.models.Document.from(map = it as Map, nestedType) + } return client.call( "PATCH", path, headers, params, - responseType = io.appwrite.models.Document::class.java, + responseType = classOf(), converter, ) } - + + /** + * Update Document + * + * Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated. + * + * @param databaseId Database ID. + * @param collectionId Collection ID. + * @param documentId Document ID. + * @param data Document data as JSON object. Include only attribute and value pairs to be updated. + * @param permissions An array of permissions strings. By default the current permissions are inherited. [Learn more about permissions](/docs/permissions). + * @return [io.appwrite.models.Document] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun updateDocument( + databaseId: String, + collectionId: String, + documentId: String, + data: Any? = null, + permissions: List? = null, + ) = updateDocument( + databaseId, + collectionId, + documentId, + data, + permissions, + nestedType = classOf(), + ) + /** * Delete Document * @@ -186,20 +297,22 @@ class Databases : Service { * @param databaseId Database ID. * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). * @param documentId Document ID. - * @return [Any] + * @return [Any] */ - @JvmOverloads - @Throws(AppwriteException::class) suspend fun deleteDocument( - databaseId: String, - collectionId: String, - documentId: String - ): Any { - val path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}".replace("{databaseId}", databaseId).replace("{collectionId}", collectionId).replace("{documentId}", documentId) + databaseId: String, + collectionId: String, + documentId: String, + ): Any { + val path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" + .replace("{databaseId}", databaseId) + .replace("{collectionId}", collectionId) + .replace("{documentId}", documentId) + val params = mutableMapOf( ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) return client.call( "DELETE", @@ -209,5 +322,6 @@ class Databases : Service { responseType = Any::class.java, ) } - + + } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/services/Functions.kt b/library/src/main/java/io/appwrite/services/Functions.kt index adb5c7a..90b4867 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -4,75 +4,46 @@ import android.net.Uri import io.appwrite.Client import io.appwrite.models.* import io.appwrite.exceptions.AppwriteException +import io.appwrite.extensions.classOf import okhttp3.Cookie -import okhttp3.Response import java.io.File +/** + * The Functions Service allows you view, create and manage your Cloud Functions. +**/ class Functions : Service { public constructor (client: Client) : super(client) { } - /** - * Retry Build - * - * @param functionId Function ID. - * @param deploymentId Deployment ID. - * @param buildId Build unique ID. - * @return [Any] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun retryBuild( - functionId: String, - deploymentId: String, - buildId: String - ): Any { - val path = "/functions/{functionId}/deployments/{deploymentId}/builds/{buildId}".replace("{functionId}", functionId).replace("{deploymentId}", deploymentId).replace("{buildId}", buildId) - val params = mutableMapOf( - ) - val headers = mutableMapOf( - "content-type" to "application/json" - ) - return client.call( - "POST", - path, - headers, - params, - responseType = Any::class.java, - ) - } - /** * List Executions * - * Get a list of all the current user function execution logs. You can use the - * query params to filter your results. On admin mode, this endpoint will - * return a list of all of the project's executions. [Learn more about - * different API modes](/docs/admin). + * Get a list of all the current user function execution logs. You can use the query params to filter your results. * * @param functionId Function ID. * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: trigger, status, statusCode, duration * @param search Search term to filter your list results. Max length: 256 chars. - * @return [io.appwrite.models.ExecutionList] + * @return [io.appwrite.models.ExecutionList] */ @JvmOverloads - @Throws(AppwriteException::class) suspend fun listExecutions( - functionId: String, - queries: List? = null, - search: String? = null - ): io.appwrite.models.ExecutionList { - val path = "/functions/{functionId}/executions".replace("{functionId}", functionId) + functionId: String, + queries: List? = null, + search: String? = null, + ): io.appwrite.models.ExecutionList { + val path = "/functions/{functionId}/executions" + .replace("{functionId}", functionId) + val params = mutableMapOf( "queries" to queries, - "search" to search + "search" to search, ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.ExecutionList = { - io.appwrite.models.ExecutionList.from(map = it) - } + val converter: (Any) -> io.appwrite.models.ExecutionList = { + io.appwrite.models.ExecutionList.from(map = it as Map) + } return client.call( "GET", path, @@ -82,38 +53,37 @@ class Functions : Service { converter, ) } - + + /** * Create Execution * - * Trigger a function execution. The returned object will return you the - * current execution status. You can ping the `Get Execution` endpoint to get - * updates on the current execution status. Once this endpoint is called, your - * function execution process will start asynchronously. + * Trigger a function execution. The returned object will return you the current execution status. You can ping the `Get Execution` endpoint to get updates on the current execution status. Once this endpoint is called, your function execution process will start asynchronously. * * @param functionId Function ID. * @param data String of custom data to send to function. * @param async Execute code in the background. Default value is false. - * @return [io.appwrite.models.Execution] + * @return [io.appwrite.models.Execution] */ @JvmOverloads - @Throws(AppwriteException::class) suspend fun createExecution( - functionId: String, - data: String? = null, - async: Boolean? = null - ): io.appwrite.models.Execution { - val path = "/functions/{functionId}/executions".replace("{functionId}", functionId) + functionId: String, + data: String? = null, + async: Boolean? = null, + ): io.appwrite.models.Execution { + val path = "/functions/{functionId}/executions" + .replace("{functionId}", functionId) + val params = mutableMapOf( "data" to data, - "async" to async + "async" to async, ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.Execution = { - io.appwrite.models.Execution.from(map = it) - } + val converter: (Any) -> io.appwrite.models.Execution = { + io.appwrite.models.Execution.from(map = it as Map) + } return client.call( "POST", path, @@ -123,7 +93,8 @@ class Functions : Service { converter, ) } - + + /** * Get Execution * @@ -131,23 +102,24 @@ class Functions : Service { * * @param functionId Function ID. * @param executionId Execution ID. - * @return [io.appwrite.models.Execution] + * @return [io.appwrite.models.Execution] */ - @JvmOverloads - @Throws(AppwriteException::class) suspend fun getExecution( - functionId: String, - executionId: String - ): io.appwrite.models.Execution { - val path = "/functions/{functionId}/executions/{executionId}".replace("{functionId}", functionId).replace("{executionId}", executionId) + functionId: String, + executionId: String, + ): io.appwrite.models.Execution { + val path = "/functions/{functionId}/executions/{executionId}" + .replace("{functionId}", functionId) + .replace("{executionId}", executionId) + val params = mutableMapOf( ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.Execution = { - io.appwrite.models.Execution.from(map = it) - } + val converter: (Any) -> io.appwrite.models.Execution = { + io.appwrite.models.Execution.from(map = it as Map) + } return client.call( "GET", path, @@ -157,5 +129,6 @@ class Functions : Service { converter, ) } - + + } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/services/Graphql.kt b/library/src/main/java/io/appwrite/services/Graphql.kt new file mode 100644 index 0000000..7ac28b5 --- /dev/null +++ b/library/src/main/java/io/appwrite/services/Graphql.kt @@ -0,0 +1,86 @@ +package io.appwrite.services + +import android.net.Uri +import io.appwrite.Client +import io.appwrite.models.* +import io.appwrite.exceptions.AppwriteException +import io.appwrite.extensions.classOf +import okhttp3.Cookie +import java.io.File + +/** + * The GraphQL API allows you to query and mutate your Appwrite server using GraphQL. +**/ +class Graphql : Service { + + public constructor (client: Client) : super(client) { } + + /** + * GraphQL Endpoint + * + * Execute a GraphQL mutation. + * + * @param query The query or queries to execute. + * @return [Any] + */ + suspend fun query( + query: Any, + ): Any { + val path = "/graphql" + + val params = mutableMapOf( + "query" to query, + ) + val headers = mutableMapOf( + "x-sdk-graphql" to "true", + "content-type" to "application/json", + ) + val converter: (Any) -> Any = { + it + } + return client.call( + "POST", + path, + headers, + params, + responseType = Any::class.java, + converter, + ) + } + + + /** + * GraphQL Endpoint + * + * Execute a GraphQL mutation. + * + * @param query The query or queries to execute. + * @return [Any] + */ + suspend fun mutation( + query: Any, + ): Any { + val path = "/graphql/mutation" + + val params = mutableMapOf( + "query" to query, + ) + val headers = mutableMapOf( + "x-sdk-graphql" to "true", + "content-type" to "application/json", + ) + val converter: (Any) -> Any = { + it + } + return client.call( + "POST", + path, + headers, + params, + responseType = Any::class.java, + converter, + ) + } + + +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/services/Locale.kt b/library/src/main/java/io/appwrite/services/Locale.kt index feb3dec..ff6d988 100644 --- a/library/src/main/java/io/appwrite/services/Locale.kt +++ b/library/src/main/java/io/appwrite/services/Locale.kt @@ -4,10 +4,13 @@ import android.net.Uri import io.appwrite.Client import io.appwrite.models.* import io.appwrite.exceptions.AppwriteException +import io.appwrite.extensions.classOf import okhttp3.Cookie -import okhttp3.Response import java.io.File +/** + * The Locale service allows you to customize your app based on your users' location. +**/ class Locale : Service { public constructor (client: Client) : super(client) { } @@ -15,27 +18,22 @@ class Locale : Service { /** * Get User Locale * - * Get the current user location based on IP. Returns an object with user - * country code, country name, continent name, continent code, ip address and - * suggested currency. You can use the locale header to get the data in a - * supported language. - * - * ([IP Geolocation by DB-IP](https://db-ip.com)) + * Get the current user location based on IP. Returns an object with user country code, country name, continent name, continent code, ip address and suggested currency. You can use the locale header to get the data in a supported language.([IP Geolocation by DB-IP](https://db-ip.com)) * - * @return [io.appwrite.models.Locale] + * @return [io.appwrite.models.Locale] */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun get(): io.appwrite.models.Locale { + suspend fun get( + ): io.appwrite.models.Locale { val path = "/locale" + val params = mutableMapOf( ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.Locale = { - io.appwrite.models.Locale.from(map = it) - } + val converter: (Any) -> io.appwrite.models.Locale = { + io.appwrite.models.Locale.from(map = it as Map) + } return client.call( "GET", path, @@ -45,27 +43,27 @@ class Locale : Service { converter, ) } - + + /** * List Continents * - * List of all continents. You can use the locale header to get the data in a - * supported language. + * List of all continents. You can use the locale header to get the data in a supported language. * - * @return [io.appwrite.models.ContinentList] + * @return [io.appwrite.models.ContinentList] */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun listContinents(): io.appwrite.models.ContinentList { + suspend fun listContinents( + ): io.appwrite.models.ContinentList { val path = "/locale/continents" + val params = mutableMapOf( ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.ContinentList = { - io.appwrite.models.ContinentList.from(map = it) - } + val converter: (Any) -> io.appwrite.models.ContinentList = { + io.appwrite.models.ContinentList.from(map = it as Map) + } return client.call( "GET", path, @@ -75,27 +73,27 @@ class Locale : Service { converter, ) } - + + /** * List Countries * - * List of all countries. You can use the locale header to get the data in a - * supported language. + * List of all countries. You can use the locale header to get the data in a supported language. * - * @return [io.appwrite.models.CountryList] + * @return [io.appwrite.models.CountryList] */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun listCountries(): io.appwrite.models.CountryList { + suspend fun listCountries( + ): io.appwrite.models.CountryList { val path = "/locale/countries" + val params = mutableMapOf( ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.CountryList = { - io.appwrite.models.CountryList.from(map = it) - } + val converter: (Any) -> io.appwrite.models.CountryList = { + io.appwrite.models.CountryList.from(map = it as Map) + } return client.call( "GET", path, @@ -105,27 +103,27 @@ class Locale : Service { converter, ) } - + + /** * List EU Countries * - * List of all countries that are currently members of the EU. You can use the - * locale header to get the data in a supported language. + * List of all countries that are currently members of the EU. You can use the locale header to get the data in a supported language. * - * @return [io.appwrite.models.CountryList] + * @return [io.appwrite.models.CountryList] */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun listCountriesEU(): io.appwrite.models.CountryList { + suspend fun listCountriesEU( + ): io.appwrite.models.CountryList { val path = "/locale/countries/eu" + val params = mutableMapOf( ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.CountryList = { - io.appwrite.models.CountryList.from(map = it) - } + val converter: (Any) -> io.appwrite.models.CountryList = { + io.appwrite.models.CountryList.from(map = it as Map) + } return client.call( "GET", path, @@ -135,27 +133,27 @@ class Locale : Service { converter, ) } - + + /** * List Countries Phone Codes * - * List of all countries phone codes. You can use the locale header to get the - * data in a supported language. + * List of all countries phone codes. You can use the locale header to get the data in a supported language. * - * @return [io.appwrite.models.PhoneList] + * @return [io.appwrite.models.PhoneList] */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun listCountriesPhones(): io.appwrite.models.PhoneList { + suspend fun listCountriesPhones( + ): io.appwrite.models.PhoneList { val path = "/locale/countries/phones" + val params = mutableMapOf( ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.PhoneList = { - io.appwrite.models.PhoneList.from(map = it) - } + val converter: (Any) -> io.appwrite.models.PhoneList = { + io.appwrite.models.PhoneList.from(map = it as Map) + } return client.call( "GET", path, @@ -165,28 +163,27 @@ class Locale : Service { converter, ) } - + + /** * List Currencies * - * List of all currencies, including currency symbol, name, plural, and - * decimal digits for all major and minor currencies. You can use the locale - * header to get the data in a supported language. + * List of all currencies, including currency symbol, name, plural, and decimal digits for all major and minor currencies. You can use the locale header to get the data in a supported language. * - * @return [io.appwrite.models.CurrencyList] + * @return [io.appwrite.models.CurrencyList] */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun listCurrencies(): io.appwrite.models.CurrencyList { + suspend fun listCurrencies( + ): io.appwrite.models.CurrencyList { val path = "/locale/currencies" + val params = mutableMapOf( ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.CurrencyList = { - io.appwrite.models.CurrencyList.from(map = it) - } + val converter: (Any) -> io.appwrite.models.CurrencyList = { + io.appwrite.models.CurrencyList.from(map = it as Map) + } return client.call( "GET", path, @@ -196,27 +193,27 @@ class Locale : Service { converter, ) } - + + /** * List Languages * - * List of all languages classified by ISO 639-1 including 2-letter code, name - * in English, and name in the respective language. + * List of all languages classified by ISO 639-1 including 2-letter code, name in English, and name in the respective language. * - * @return [io.appwrite.models.LanguageList] + * @return [io.appwrite.models.LanguageList] */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun listLanguages(): io.appwrite.models.LanguageList { + suspend fun listLanguages( + ): io.appwrite.models.LanguageList { val path = "/locale/languages" + val params = mutableMapOf( ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.LanguageList = { - io.appwrite.models.LanguageList.from(map = it) - } + val converter: (Any) -> io.appwrite.models.LanguageList = { + io.appwrite.models.LanguageList.from(map = it as Map) + } return client.call( "GET", path, @@ -226,5 +223,6 @@ class Locale : Service { converter, ) } - + + } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index 0d22f47..6aec906 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -4,12 +4,15 @@ import android.net.Uri import io.appwrite.Client import io.appwrite.models.* import io.appwrite.exceptions.AppwriteException +import io.appwrite.extensions.classOf import okhttp3.Cookie -import okhttp3.Response import okhttp3.HttpUrl import okhttp3.HttpUrl.Companion.toHttpUrl import java.io.File +/** + * The Storage service allows you to manage your project files. +**/ class Storage : Service { public constructor (client: Client) : super(client) { } @@ -17,33 +20,32 @@ class Storage : Service { /** * List Files * - * Get a list of all the user files. You can use the query params to filter - * your results. On admin mode, this endpoint will return a list of all of the - * project's files. [Learn more about different API modes](/docs/admin). + * Get a list of all the user files. You can use the query params to filter your results. * * @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket). * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, signature, mimeType, sizeOriginal, chunksTotal, chunksUploaded * @param search Search term to filter your list results. Max length: 256 chars. - * @return [io.appwrite.models.FileList] + * @return [io.appwrite.models.FileList] */ @JvmOverloads - @Throws(AppwriteException::class) suspend fun listFiles( - bucketId: String, - queries: List? = null, - search: String? = null - ): io.appwrite.models.FileList { - val path = "/storage/buckets/{bucketId}/files".replace("{bucketId}", bucketId) + bucketId: String, + queries: List? = null, + search: String? = null, + ): io.appwrite.models.FileList { + val path = "/storage/buckets/{bucketId}/files" + .replace("{bucketId}", bucketId) + val params = mutableMapOf( "queries" to queries, - "search" to search + "search" to search, ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.FileList = { - io.appwrite.models.FileList.from(map = it) - } + val converter: (Any) -> io.appwrite.models.FileList = { + io.appwrite.models.FileList.from(map = it as Map) + } return client.call( "GET", path, @@ -53,55 +55,41 @@ class Storage : Service { converter, ) } - + + /** * Create File * - * Create a new file. Before using this route, you should create a new bucket - * resource using either a [server - * integration](/docs/server/storage#storageCreateBucket) API or directly from - * your Appwrite console. - * - * Larger files should be uploaded using multiple requests with the - * [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range) - * header to send a partial request with a maximum supported chunk of `5MB`. - * The `content-range` header values should always be in bytes. - * - * When the first request is sent, the server will return the **File** object, - * and the subsequent part request must include the file's **id** in - * `x-appwrite-id` header to allow the server to know that the partial upload - * is for the existing file and not for a new one. - * - * If you're creating a new file using one of the Appwrite SDKs, all the - * chunking logic will be managed by the SDK internally. - * + * Create a new file. Before using this route, you should create a new bucket resource using either a [server integration](/docs/server/storage#storageCreateBucket) API or directly from your Appwrite console.Larger files should be uploaded using multiple requests with the [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range) header to send a partial request with a maximum supported chunk of `5MB`. The `content-range` header values should always be in bytes.When the first request is sent, the server will return the **File** object, and the subsequent part request must include the file's **id** in `x-appwrite-id` header to allow the server to know that the partial upload is for the existing file and not for a new one.If you're creating a new file using one of the Appwrite SDKs, all the chunking logic will be managed by the SDK internally. * * @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket). - * @param fileId File ID. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param fileId File ID. Choose your own unique ID or pass the string `ID.unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param file Binary file. * @param permissions An array of permission strings. By default the current user is granted with all permissions. [Learn more about permissions](/docs/permissions). - * @return [io.appwrite.models.File] + * @return [io.appwrite.models.File] */ @JvmOverloads - @Throws(AppwriteException::class) suspend fun createFile( - bucketId: String, - fileId: String, - file: InputFile, - permissions: List? = null, onProgress: ((UploadProgress) -> Unit)? = null - ): io.appwrite.models.File { - val path = "/storage/buckets/{bucketId}/files".replace("{bucketId}", bucketId) + bucketId: String, + fileId: String, + file: InputFile, + permissions: List? = null, + onProgress: ((UploadProgress) -> Unit)? = null + ): io.appwrite.models.File { + val path = "/storage/buckets/{bucketId}/files" + .replace("{bucketId}", bucketId) + val params = mutableMapOf( "fileId" to fileId, "file" to file, - "permissions" to permissions + "permissions" to permissions, ) val headers = mutableMapOf( - "content-type" to "multipart/form-data" + "content-type" to "multipart/form-data", ) - val converter: (Map) -> io.appwrite.models.File = { - io.appwrite.models.File.from(map = it) - } + val converter: (Any) -> io.appwrite.models.File = { + io.appwrite.models.File.from(map = it as Map) + } val idParamName: String? = "fileId" val paramName = "file" return client.chunkedUpload( @@ -115,32 +103,33 @@ class Storage : Service { onProgress, ) } - + + /** * Get File * - * Get a file by its unique ID. This endpoint response returns a JSON object - * with the file metadata. + * Get a file by its unique ID. This endpoint response returns a JSON object with the file metadata. * * @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket). * @param fileId File ID. - * @return [io.appwrite.models.File] + * @return [io.appwrite.models.File] */ - @JvmOverloads - @Throws(AppwriteException::class) suspend fun getFile( - bucketId: String, - fileId: String - ): io.appwrite.models.File { - val path = "/storage/buckets/{bucketId}/files/{fileId}".replace("{bucketId}", bucketId).replace("{fileId}", fileId) + bucketId: String, + fileId: String, + ): io.appwrite.models.File { + val path = "/storage/buckets/{bucketId}/files/{fileId}" + .replace("{bucketId}", bucketId) + .replace("{fileId}", fileId) + val params = mutableMapOf( ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.File = { - io.appwrite.models.File.from(map = it) - } + val converter: (Any) -> io.appwrite.models.File = { + io.appwrite.models.File.from(map = it as Map) + } return client.call( "GET", path, @@ -150,35 +139,37 @@ class Storage : Service { converter, ) } - + + /** * Update File * - * Update a file by its unique ID. Only users with write permissions have - * access to update this resource. + * Update a file by its unique ID. Only users with write permissions have access to update this resource. * * @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket). * @param fileId File unique ID. * @param permissions An array of permission string. By default the current permissions are inherited. [Learn more about permissions](/docs/permissions). - * @return [io.appwrite.models.File] + * @return [io.appwrite.models.File] */ @JvmOverloads - @Throws(AppwriteException::class) suspend fun updateFile( - bucketId: String, - fileId: String, - permissions: List? = null - ): io.appwrite.models.File { - val path = "/storage/buckets/{bucketId}/files/{fileId}".replace("{bucketId}", bucketId).replace("{fileId}", fileId) + bucketId: String, + fileId: String, + permissions: List? = null, + ): io.appwrite.models.File { + val path = "/storage/buckets/{bucketId}/files/{fileId}" + .replace("{bucketId}", bucketId) + .replace("{fileId}", fileId) + val params = mutableMapOf( - "permissions" to permissions + "permissions" to permissions, ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.File = { - io.appwrite.models.File.from(map = it) - } + val converter: (Any) -> io.appwrite.models.File = { + io.appwrite.models.File.from(map = it as Map) + } return client.call( "PUT", path, @@ -188,28 +179,29 @@ class Storage : Service { converter, ) } - + + /** * Delete File * - * Delete a file by its unique ID. Only users with write permissions have - * access to delete this resource. + * Delete a file by its unique ID. Only users with write permissions have access to delete this resource. * * @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket). * @param fileId File ID. - * @return [Any] + * @return [Any] */ - @JvmOverloads - @Throws(AppwriteException::class) suspend fun deleteFile( - bucketId: String, - fileId: String - ): Any { - val path = "/storage/buckets/{bucketId}/files/{fileId}".replace("{bucketId}", bucketId).replace("{fileId}", fileId) + bucketId: String, + fileId: String, + ): Any { + val path = "/storage/buckets/{bucketId}/files/{fileId}" + .replace("{bucketId}", bucketId) + .replace("{fileId}", fileId) + val params = mutableMapOf( ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) return client.call( "DELETE", @@ -219,27 +211,26 @@ class Storage : Service { responseType = Any::class.java, ) } - + + /** * Get File for Download * - * Get a file content by its unique ID. The endpoint response return with a - * 'Content-Disposition: attachment' header that tells the browser to start - * downloading the file to user downloads directory. + * Get a file content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory. * * @param bucketId Storage bucket ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket). * @param fileId File ID. - * @return [ByteArray] + * @return [ByteArray] */ - @JvmOverloads - @Throws(AppwriteException::class) suspend fun getFileDownload( - bucketId: String, - fileId: String - ): ByteArray { - val path = "/storage/buckets/{bucketId}/files/{fileId}/download".replace("{bucketId}", bucketId).replace("{fileId}", fileId) + bucketId: String, + fileId: String, + ): ByteArray { + val path = "/storage/buckets/{bucketId}/files/{fileId}/download" + .replace("{bucketId}", bucketId) + .replace("{fileId}", fileId) + val params = mutableMapOf( - "project" to client.config["project"] ) return client.call( "GET", @@ -248,15 +239,12 @@ class Storage : Service { responseType = ByteArray::class.java ) } - + + /** * Get File Preview * - * Get a file preview image. Currently, this method supports preview for image - * files (jpg, png, and gif), other supported formats, like pdf, docs, slides, - * and spreadsheets, will return the file icon image. You can also pass query - * string arguments for cutting and resizing your preview image. Preview is - * supported only for image files smaller than 10MB. + * Get a file preview image. Currently, this method supports preview for image files (jpg, png, and gif), other supported formats, like pdf, docs, slides, and spreadsheets, will return the file icon image. You can also pass query string arguments for cutting and resizing your preview image. Preview is supported only for image files smaller than 10MB. * * @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket). * @param fileId File ID @@ -271,26 +259,28 @@ class Storage : Service { * @param rotation Preview image rotation in degrees. Pass an integer between -360 and 360. * @param background Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix. * @param output Output format type (jpeg, jpg, png, gif and webp). - * @return [ByteArray] + * @return [ByteArray] */ @JvmOverloads - @Throws(AppwriteException::class) suspend fun getFilePreview( - bucketId: String, - fileId: String, - width: Long? = null, - height: Long? = null, - gravity: String? = null, - quality: Long? = null, - borderWidth: Long? = null, - borderColor: String? = null, - borderRadius: Long? = null, - opacity: Double? = null, - rotation: Long? = null, - background: String? = null, - output: String? = null - ): ByteArray { - val path = "/storage/buckets/{bucketId}/files/{fileId}/preview".replace("{bucketId}", bucketId).replace("{fileId}", fileId) + bucketId: String, + fileId: String, + width: Long? = null, + height: Long? = null, + gravity: String? = null, + quality: Long? = null, + borderWidth: Long? = null, + borderColor: String? = null, + borderRadius: Long? = null, + opacity: Double? = null, + rotation: Long? = null, + background: String? = null, + output: String? = null, + ): ByteArray { + val path = "/storage/buckets/{bucketId}/files/{fileId}/preview" + .replace("{bucketId}", bucketId) + .replace("{fileId}", fileId) + val params = mutableMapOf( "width" to width, "height" to height, @@ -303,7 +293,6 @@ class Storage : Service { "rotation" to rotation, "background" to background, "output" to output, - "project" to client.config["project"] ) return client.call( "GET", @@ -312,27 +301,26 @@ class Storage : Service { responseType = ByteArray::class.java ) } - + + /** * Get File for View * - * Get a file content by its unique ID. This endpoint is similar to the - * download method but returns with no 'Content-Disposition: attachment' - * header. + * Get a file content by its unique ID. This endpoint is similar to the download method but returns with no 'Content-Disposition: attachment' header. * * @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket). * @param fileId File ID. - * @return [ByteArray] + * @return [ByteArray] */ - @JvmOverloads - @Throws(AppwriteException::class) suspend fun getFileView( - bucketId: String, - fileId: String - ): ByteArray { - val path = "/storage/buckets/{bucketId}/files/{fileId}/view".replace("{bucketId}", bucketId).replace("{fileId}", fileId) + bucketId: String, + fileId: String, + ): ByteArray { + val path = "/storage/buckets/{bucketId}/files/{fileId}/view" + .replace("{bucketId}", bucketId) + .replace("{fileId}", fileId) + val params = mutableMapOf( - "project" to client.config["project"] ) return client.call( "GET", @@ -341,5 +329,6 @@ class Storage : Service { responseType = ByteArray::class.java ) } - + + } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt index de74fb7..68f0b0a 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -4,10 +4,13 @@ import android.net.Uri import io.appwrite.Client import io.appwrite.models.* import io.appwrite.exceptions.AppwriteException +import io.appwrite.extensions.classOf import okhttp3.Cookie -import okhttp3.Response import java.io.File +/** + * The Teams service allows you to group users of your project and to enable them to share read and write access to your project resources +**/ class Teams : Service { public constructor (client: Client) : super(client) { } @@ -15,33 +18,29 @@ class Teams : Service { /** * List Teams * - * Get a list of all the teams in which the current user is a member. You can - * use the parameters to filter your results. - * - * In admin mode, this endpoint returns a list of all the teams in the current - * project. [Learn more about different API modes](/docs/admin). + * Get a list of all the teams in which the current user is a member. You can use the parameters to filter your results. * * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, total * @param search Search term to filter your list results. Max length: 256 chars. - * @return [io.appwrite.models.TeamList] + * @return [io.appwrite.models.TeamList] */ @JvmOverloads - @Throws(AppwriteException::class) suspend fun list( - queries: List? = null, - search: String? = null - ): io.appwrite.models.TeamList { + queries: List? = null, + search: String? = null, + ): io.appwrite.models.TeamList { val path = "/teams" + val params = mutableMapOf( "queries" to queries, - "search" to search + "search" to search, ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.TeamList = { - io.appwrite.models.TeamList.from(map = it) - } + val converter: (Any) -> io.appwrite.models.TeamList = { + io.appwrite.models.TeamList.from(map = it as Map) + } return client.call( "GET", path, @@ -51,38 +50,37 @@ class Teams : Service { converter, ) } - + + /** * Create Team * - * Create a new team. The user who creates the team will automatically be - * assigned as the owner of the team. Only the users with the owner role can - * invite new members, add new owners and delete or update the team. + * Create a new team. The user who creates the team will automatically be assigned as the owner of the team. Only the users with the owner role can invite new members, add new owners and delete or update the team. * - * @param teamId Team ID. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param teamId Team ID. Choose your own unique ID or pass the string `ID.unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param name Team name. Max length: 128 chars. * @param roles Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. A role can be any string. Learn more about [roles and permissions](/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. - * @return [io.appwrite.models.Team] + * @return [io.appwrite.models.Team] */ @JvmOverloads - @Throws(AppwriteException::class) suspend fun create( - teamId: String, - name: String, - roles: List? = null - ): io.appwrite.models.Team { + teamId: String, + name: String, + roles: List? = null, + ): io.appwrite.models.Team { val path = "/teams" + val params = mutableMapOf( "teamId" to teamId, "name" to name, - "roles" to roles + "roles" to roles, ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.Team = { - io.appwrite.models.Team.from(map = it) - } + val converter: (Any) -> io.appwrite.models.Team = { + io.appwrite.models.Team.from(map = it as Map) + } return client.call( "POST", path, @@ -92,29 +90,30 @@ class Teams : Service { converter, ) } - + + /** * Get Team * * Get a team by its ID. All team members have read access for this resource. * * @param teamId Team ID. - * @return [io.appwrite.models.Team] + * @return [io.appwrite.models.Team] */ - @JvmOverloads - @Throws(AppwriteException::class) suspend fun get( - teamId: String - ): io.appwrite.models.Team { - val path = "/teams/{teamId}".replace("{teamId}", teamId) + teamId: String, + ): io.appwrite.models.Team { + val path = "/teams/{teamId}" + .replace("{teamId}", teamId) + val params = mutableMapOf( ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.Team = { - io.appwrite.models.Team.from(map = it) - } + val converter: (Any) -> io.appwrite.models.Team = { + io.appwrite.models.Team.from(map = it as Map) + } return client.call( "GET", path, @@ -124,33 +123,33 @@ class Teams : Service { converter, ) } - + + /** * Update Team * - * Update a team using its ID. Only members with the owner role can update the - * team. + * Update a team using its ID. Only members with the owner role can update the team. * * @param teamId Team ID. * @param name New team name. Max length: 128 chars. - * @return [io.appwrite.models.Team] + * @return [io.appwrite.models.Team] */ - @JvmOverloads - @Throws(AppwriteException::class) suspend fun update( - teamId: String, - name: String - ): io.appwrite.models.Team { - val path = "/teams/{teamId}".replace("{teamId}", teamId) + teamId: String, + name: String, + ): io.appwrite.models.Team { + val path = "/teams/{teamId}" + .replace("{teamId}", teamId) + val params = mutableMapOf( - "name" to name + "name" to name, ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.Team = { - io.appwrite.models.Team.from(map = it) - } + val converter: (Any) -> io.appwrite.models.Team = { + io.appwrite.models.Team.from(map = it as Map) + } return client.call( "PUT", path, @@ -160,26 +159,26 @@ class Teams : Service { converter, ) } - + + /** * Delete Team * - * Delete a team using its ID. Only team members with the owner role can - * delete the team. + * Delete a team using its ID. Only team members with the owner role can delete the team. * * @param teamId Team ID. - * @return [Any] + * @return [Any] */ - @JvmOverloads - @Throws(AppwriteException::class) suspend fun delete( - teamId: String - ): Any { - val path = "/teams/{teamId}".replace("{teamId}", teamId) + teamId: String, + ): Any { + val path = "/teams/{teamId}" + .replace("{teamId}", teamId) + val params = mutableMapOf( ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) return client.call( "DELETE", @@ -189,36 +188,37 @@ class Teams : Service { responseType = Any::class.java, ) } - + + /** * List Team Memberships * - * Use this endpoint to list a team's members using the team's ID. All team - * members have read access to this endpoint. + * Use this endpoint to list a team's members using the team's ID. All team members have read access to this endpoint. * * @param teamId Team ID. * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, teamId, invited, joined, confirm * @param search Search term to filter your list results. Max length: 256 chars. - * @return [io.appwrite.models.MembershipList] + * @return [io.appwrite.models.MembershipList] */ @JvmOverloads - @Throws(AppwriteException::class) suspend fun listMemberships( - teamId: String, - queries: List? = null, - search: String? = null - ): io.appwrite.models.MembershipList { - val path = "/teams/{teamId}/memberships".replace("{teamId}", teamId) + teamId: String, + queries: List? = null, + search: String? = null, + ): io.appwrite.models.MembershipList { + val path = "/teams/{teamId}/memberships" + .replace("{teamId}", teamId) + val params = mutableMapOf( "queries" to queries, - "search" to search + "search" to search, ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.MembershipList = { - io.appwrite.models.MembershipList.from(map = it) - } + val converter: (Any) -> io.appwrite.models.MembershipList = { + io.appwrite.models.MembershipList.from(map = it as Map) + } return client.call( "GET", path, @@ -228,55 +228,43 @@ class Teams : Service { converter, ) } - + + /** * Create Team Membership * - * Invite a new member to join your team. If initiated from the client SDK, an - * email with a link to join the team will be sent to the member's email - * address and an account will be created for them should they not be signed - * up already. If initiated from server-side SDKs, the new member will - * automatically be added to the team. - * - * Use the 'url' parameter to redirect the user from the invitation email back - * to your app. When the user is redirected, use the [Update Team Membership - * Status](/docs/client/teams#teamsUpdateMembershipStatus) endpoint to allow - * the user to accept the invitation to the team. - * - * Please note that to avoid a [Redirect - * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) - * the only valid redirect URL's are the once from domains you have set when - * adding your platforms in the console interface. + * Invite a new member to join your team. If initiated from the client SDK, an email with a link to join the team will be sent to the member's email address and an account will be created for them should they not be signed up already. If initiated from server-side SDKs, the new member will automatically be added to the team.Use the 'url' parameter to redirect the user from the invitation email back to your app. When the user is redirected, use the [Update Team Membership Status](/docs/client/teams#teamsUpdateMembershipStatus) endpoint to allow the user to accept the invitation to the team. Please note that to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) the only valid redirect URL's are the once from domains you have set when adding your platforms in the console interface. * * @param teamId Team ID. * @param email Email of the new team member. * @param roles Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. * @param url URL to redirect the user back to your app from the invitation email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param name Name of the new team member. Max length: 128 chars. - * @return [io.appwrite.models.Membership] + * @return [io.appwrite.models.Membership] */ @JvmOverloads - @Throws(AppwriteException::class) suspend fun createMembership( - teamId: String, - email: String, - roles: List, - url: String, - name: String? = null - ): io.appwrite.models.Membership { - val path = "/teams/{teamId}/memberships".replace("{teamId}", teamId) + teamId: String, + email: String, + roles: List, + url: String, + name: String? = null, + ): io.appwrite.models.Membership { + val path = "/teams/{teamId}/memberships" + .replace("{teamId}", teamId) + val params = mutableMapOf( "email" to email, "roles" to roles, "url" to url, - "name" to name + "name" to name, ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.Membership = { - io.appwrite.models.Membership.from(map = it) - } + val converter: (Any) -> io.appwrite.models.Membership = { + io.appwrite.models.Membership.from(map = it as Map) + } return client.call( "POST", path, @@ -286,71 +274,72 @@ class Teams : Service { converter, ) } - + + /** * Get Team Membership * - * Get a team member by the membership unique id. All team members have read - * access for this resource. + * Get a team member by the membership unique id. All team members have read access for this resource. * * @param teamId Team ID. * @param membershipId Membership ID. - * @return [io.appwrite.models.MembershipList] + * @return [io.appwrite.models.Membership] */ - @JvmOverloads - @Throws(AppwriteException::class) suspend fun getMembership( - teamId: String, - membershipId: String - ): io.appwrite.models.MembershipList { - val path = "/teams/{teamId}/memberships/{membershipId}".replace("{teamId}", teamId).replace("{membershipId}", membershipId) + teamId: String, + membershipId: String, + ): io.appwrite.models.Membership { + val path = "/teams/{teamId}/memberships/{membershipId}" + .replace("{teamId}", teamId) + .replace("{membershipId}", membershipId) + val params = mutableMapOf( ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.MembershipList = { - io.appwrite.models.MembershipList.from(map = it) - } + val converter: (Any) -> io.appwrite.models.Membership = { + io.appwrite.models.Membership.from(map = it as Map) + } return client.call( "GET", path, headers, params, - responseType = io.appwrite.models.MembershipList::class.java, + responseType = io.appwrite.models.Membership::class.java, converter, ) } - + + /** * Update Membership Roles * - * Modify the roles of a team member. Only team members with the owner role - * have access to this endpoint. Learn more about [roles and - * permissions](/docs/permissions). + * Modify the roles of a team member. Only team members with the owner role have access to this endpoint. Learn more about [roles and permissions](/docs/permissions). * * @param teamId Team ID. * @param membershipId Membership ID. * @param roles An array of strings. Use this param to set the user's roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. - * @return [io.appwrite.models.Membership] + * @return [io.appwrite.models.Membership] */ - @JvmOverloads - @Throws(AppwriteException::class) suspend fun updateMembershipRoles( - teamId: String, - membershipId: String, - roles: List - ): io.appwrite.models.Membership { - val path = "/teams/{teamId}/memberships/{membershipId}".replace("{teamId}", teamId).replace("{membershipId}", membershipId) + teamId: String, + membershipId: String, + roles: List, + ): io.appwrite.models.Membership { + val path = "/teams/{teamId}/memberships/{membershipId}" + .replace("{teamId}", teamId) + .replace("{membershipId}", membershipId) + val params = mutableMapOf( - "roles" to roles + "roles" to roles, ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.Membership = { - io.appwrite.models.Membership.from(map = it) - } + val converter: (Any) -> io.appwrite.models.Membership = { + io.appwrite.models.Membership.from(map = it as Map) + } return client.call( "PATCH", path, @@ -360,29 +349,29 @@ class Teams : Service { converter, ) } - + + /** * Delete Team Membership * - * This endpoint allows a user to leave a team or for a team owner to delete - * the membership of any other team member. You can also use this endpoint to - * delete a user membership even if it is not accepted. + * This endpoint allows a user to leave a team or for a team owner to delete the membership of any other team member. You can also use this endpoint to delete a user membership even if it is not accepted. * * @param teamId Team ID. * @param membershipId Membership ID. - * @return [Any] + * @return [Any] */ - @JvmOverloads - @Throws(AppwriteException::class) suspend fun deleteMembership( - teamId: String, - membershipId: String - ): Any { - val path = "/teams/{teamId}/memberships/{membershipId}".replace("{teamId}", teamId).replace("{membershipId}", membershipId) + teamId: String, + membershipId: String, + ): Any { + val path = "/teams/{teamId}/memberships/{membershipId}" + .replace("{teamId}", teamId) + .replace("{membershipId}", membershipId) + val params = mutableMapOf( ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) return client.call( "DELETE", @@ -392,43 +381,39 @@ class Teams : Service { responseType = Any::class.java, ) } - + + /** * Update Team Membership Status * - * Use this endpoint to allow a user to accept an invitation to join a team - * after being redirected back to your app from the invitation email received - * by the user. - * - * If the request is successful, a session for the user is automatically - * created. - * + * Use this endpoint to allow a user to accept an invitation to join a team after being redirected back to your app from the invitation email received by the user.If the request is successful, a session for the user is automatically created. * * @param teamId Team ID. * @param membershipId Membership ID. * @param userId User ID. * @param secret Secret key. - * @return [io.appwrite.models.Membership] + * @return [io.appwrite.models.Membership] */ - @JvmOverloads - @Throws(AppwriteException::class) suspend fun updateMembershipStatus( - teamId: String, - membershipId: String, - userId: String, - secret: String - ): io.appwrite.models.Membership { - val path = "/teams/{teamId}/memberships/{membershipId}/status".replace("{teamId}", teamId).replace("{membershipId}", membershipId) + teamId: String, + membershipId: String, + userId: String, + secret: String, + ): io.appwrite.models.Membership { + val path = "/teams/{teamId}/memberships/{membershipId}/status" + .replace("{teamId}", teamId) + .replace("{membershipId}", membershipId) + val params = mutableMapOf( "userId" to userId, - "secret" to secret + "secret" to secret, ) val headers = mutableMapOf( - "content-type" to "application/json" + "content-type" to "application/json", ) - val converter: (Map) -> io.appwrite.models.Membership = { - io.appwrite.models.Membership.from(map = it) - } + val converter: (Any) -> io.appwrite.models.Membership = { + io.appwrite.models.Membership.from(map = it as Map) + } return client.call( "PATCH", path, @@ -438,5 +423,6 @@ class Teams : Service { converter, ) } - + + } \ No newline at end of file